0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-28 01:58:20 +01:00

add well-known config for OIDC (#15355)

* add well-known config for OIDC

* spacing per feedback

* Update oidc_wellknown.tmpl

* add id_token

* Update oidc_wellknown.tmpl

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
techknowlogick 2021-04-15 22:32:00 -04:00 committed by GitHub
parent 6a7090b41d
commit 024ef3940f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 0 deletions

View File

@ -18,6 +18,9 @@ insert_final_newline = false
[templates/swagger/v1_json.tmpl]
indent_style = space
[templates/user/auth/oidc_wellknown.tmpl]
indent_style = space
[Makefile]
indent_style = tab

View File

@ -336,6 +336,7 @@ func RegisterRoutes(m *web.Route) {
// Routers.
// for health check
m.Get("/", routers.Home)
m.Get("/.well-known/openid-configuration", user.OIDCWellKnown)
m.Group("/explore", func() {
m.Get("", func(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/explore/repos")

View File

@ -389,6 +389,16 @@ func GrantApplicationOAuth(ctx *context.Context) {
ctx.Redirect(redirect.String(), 302)
}
// OIDCWellKnown generates JSON so OIDC clients know Gitea's capabilities
func OIDCWellKnown(ctx *context.Context) {
t := ctx.Render.TemplateLookup("user/auth/oidc_wellknown")
ctx.Resp.Header().Set("Content-Type", "application/json")
if err := t.Execute(ctx.Resp, ctx.Data); err != nil {
log.Error("%v", err)
ctx.Error(http.StatusInternalServerError)
}
}
// AccessTokenOAuth manages all access token requests by the client
func AccessTokenOAuth(ctx *context.Context) {
form := *web.GetForm(ctx).(*forms.AccessTokenForm)

View File

@ -0,0 +1,9 @@
{
"issuer": "{{AppUrl | JSEscape | Safe}}",
"authorization_endpoint": "{{AppUrl | JSEscape | Safe}}login/oauth/authorize",
"token_endpoint": "{{AppUrl | JSEscape | Safe}}login/oauth/access_token",
"response_types_supported": [
"code",
"id_token"
]
}