40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
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"`
|
|
GrantTypesSupported []string `json:"grant_types_supported"`
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
encoder := json.NewEncoder(w)
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
if err := encoder.Encode(Response{
|
|
TokenEndpoint: h.cfg.Uri + "/api/v1/oauth/token",
|
|
AuthorizationEndpoint: h.cfg.Uri + "/api/v1/oauth/authorize",
|
|
JwksURI: h.cfg.Uri + "/.well-known/jwks.json",
|
|
Issuer: h.cfg.Uri,
|
|
EndSessionEndpoint: h.cfg.Uri + "/api/v1/oauth/logout",
|
|
GrantTypesSupported: []string{
|
|
"authorization_code",
|
|
"refresh_token",
|
|
},
|
|
}); err != nil {
|
|
web.Error(w, "failed to encode response", http.StatusInternalServerError)
|
|
}
|
|
}
|