aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/auth
diff options
context:
space:
mode:
authorShivaram Lingamneni <slingamn@cs.stanford.edu>2024-07-25 14:36:05 +0200
committerGitHub <noreply@github.com>2024-07-25 12:36:05 +0000
commitecc8f2b047be405f39d81ae17280e478116845e3 (patch)
tree82ecda5de1d7ea895f9c980f0b7f2dbb13710ca6 /routers/web/auth
parentbae87dfb0958e6a2920c905e51c2a026b7b71ca6 (diff)
downloadgitea-ecc8f2b047be405f39d81ae17280e478116845e3.tar.gz
gitea-ecc8f2b047be405f39d81ae17280e478116845e3.zip
add `username` to OIDC introspection response (#31688)
This field is specified as optional here: https://datatracker.ietf.org/doc/html/rfc7662#section-2.2 It's used by some OIDC integrations, e.g. https://emersion.fr/blog/2022/irc-and-oauth2/ Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'routers/web/auth')
-rw-r--r--routers/web/auth/oauth.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 204248d63f..7988dc96a4 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -353,8 +353,9 @@ func IntrospectOAuth(ctx *context.Context) {
}
var response struct {
- Active bool `json:"active"`
- Scope string `json:"scope,omitempty"`
+ Active bool `json:"active"`
+ Scope string `json:"scope,omitempty"`
+ Username string `json:"username,omitempty"`
jwt.RegisteredClaims
}
@@ -371,6 +372,9 @@ func IntrospectOAuth(ctx *context.Context) {
response.Audience = []string{app.ClientID}
response.Subject = fmt.Sprint(grant.UserID)
}
+ if user, err := user_model.GetUserByID(ctx, grant.UserID); err == nil {
+ response.Username = user.Name
+ }
}
}