From 62c62f74f21e02e8355b15afcae79d543e2b6f50 Mon Sep 17 00:00:00 2001 From: HuckOps <1059231721@qq.com> Date: Mon, 1 Dec 2025 16:29:01 +0800 Subject: [PATCH] refactor: align struct fields with OpenID Connect specification This change adds Name, Picture, GivenName, FamilyName in the UserInfo structure to solve the problem of not being able to obtain user information in some scenarios --- oidc/oidc.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/oidc/oidc.go b/oidc/oidc.go index 2659518..e0f1724 100644 --- a/oidc/oidc.go +++ b/oidc/oidc.go @@ -325,6 +325,10 @@ type UserInfo struct { Profile string `json:"profile"` Email string `json:"email"` EmailVerified bool `json:"email_verified"` + Name string `json:"name"` + Picture string `json:"picture"` + GivenName string `json:"given_name"` + FamilyName string `json:"family_name"` claims []byte } @@ -337,6 +341,12 @@ type userInfoRaw struct { // https://forums.aws.amazon.com/thread.jspa?messageID=949441󧳁 and // https://discuss.elastic.co/t/openid-error-after-authenticating-against-aws-cognito/206018/11 EmailVerified stringAsBool `json:"email_verified"` + // Align the fields in the OpenID example + //https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse + Name string `json:"name"` + Picture string `json:"picture"` + GivenName string `json:"given_name"` + FamilyName string `json:"family_name"` } // Claims unmarshals the raw JSON object claims into the provided object. @@ -397,6 +407,10 @@ func (p *Provider) UserInfo(ctx context.Context, tokenSource oauth2.TokenSource) Email: userInfo.Email, EmailVerified: bool(userInfo.EmailVerified), claims: body, + Name: userInfo.Name, + Picture: userInfo.Picture, + GivenName: userInfo.GivenName, + FamilyName: userInfo.FamilyName, }, nil }