1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

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>
This commit is contained in:
Shivaram Lingamneni
2024-07-25 14:36:05 +02:00
committed by GitHub
parent bae87dfb09
commit ecc8f2b047
2 changed files with 10 additions and 4 deletions

View File

@@ -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
}
}
}