summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authortechknowlogick <techknowlogick@gitea.io>2021-04-15 22:32:00 -0400
committerGitHub <noreply@github.com>2021-04-15 22:32:00 -0400
commit024ef3940f016fe3b4100d4cd1e9f8d99ccb12ba (patch)
tree7ac5d572b03b558a1c2cde4c3c78c99cfe574815 /routers
parent6a7090b41df6e0a782f04707af60ebfbec9db0a5 (diff)
downloadgitea-024ef3940f016fe3b4100d4cd1e9f8d99ccb12ba.tar.gz
gitea-024ef3940f016fe3b4100d4cd1e9f8d99ccb12ba.zip
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>
Diffstat (limited to 'routers')
-rw-r--r--routers/routes/web.go1
-rw-r--r--routers/user/oauth.go10
2 files changed, 11 insertions, 0 deletions
diff --git a/routers/routes/web.go b/routers/routes/web.go
index 4815680c99..a8d64b4c44 100644
--- a/routers/routes/web.go
+++ b/routers/routes/web.go
@@ -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")
diff --git a/routers/user/oauth.go b/routers/user/oauth.go
index c8c846c687..ae06efd0c0 100644
--- a/routers/user/oauth.go
+++ b/routers/user/oauth.go
@@ -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)