feat: split oauth endpoints into files
This commit is contained in:
31
internal/oauth/openid.go
Normal file
31
internal/oauth/openid.go
Normal file
@ -0,0 +1,31 @@
|
||||
package oauth
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"gitea.local/admin/hspguard/internal/web"
|
||||
)
|
||||
|
||||
func (h *OAuthHandler) OpenIdConfiguration(w http.ResponseWriter, r *http.Request) {
|
||||
type Response struct {
|
||||
TokenEndpoint string `json:"token_endpoint"`
|
||||
AuthorizationEndpoint string `json:"authorization_endpoint"`
|
||||
JwksURI string `json:"jwks_uri"`
|
||||
Issuer string `json:"issuer"`
|
||||
EndSessionEndpoint string `json:"end_session_endpoint"`
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
if err := encoder.Encode(Response{
|
||||
TokenEndpoint: h.cfg.Jwt.Issuer + "/api/v1/oauth/token",
|
||||
AuthorizationEndpoint: h.cfg.Jwt.Issuer + "/auth",
|
||||
JwksURI: h.cfg.Jwt.Issuer + "/.well-known/jwks.json",
|
||||
Issuer: h.cfg.Jwt.Issuer,
|
||||
EndSessionEndpoint: h.cfg.Jwt.Issuer + "/api/v1/oauth/logout",
|
||||
}); err != nil {
|
||||
web.Error(w, "failed to encode response", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user