mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-18 16:18:28 +00:00
feat: if OAuth2 is disabled return 'Not found' for openid configuration (#8426)
- If a Forgejo has disabled being a OAuth2 provider via `[oauth2].ENABLED = false` then return 'Not found' when clients requests `.well-known/openid-configuration` to reflect that OAuth2 is not supported. - This allows clients to query if Forgejo has OAuth2 enabled. - Resolves forgejo/forgejo#6978 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8426 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
74981d9e97
commit
288c56f5d3
2 changed files with 26 additions and 9 deletions
|
@ -668,6 +668,11 @@ func GrantApplicationOAuth(ctx *context.Context) {
|
|||
|
||||
// OIDCWellKnown generates JSON so OIDC clients know Gitea's capabilities
|
||||
func OIDCWellKnown(ctx *context.Context) {
|
||||
if !setting.OAuth2.Enabled {
|
||||
ctx.Status(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["SigningKey"] = oauth2.DefaultSigningKey
|
||||
ctx.Data["Issuer"] = strings.TrimSuffix(setting.AppURL, "/")
|
||||
ctx.JSONTemplate("user/auth/oidc_wellknown")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue