From b45c49d3a4422556cad2bcece63f79baf4ba9bb8 Mon Sep 17 00:00:00 2001 From: Yaodong Yu <2814461814@qq.com> Date: Wed, 29 Mar 2023 22:18:12 +0800 Subject: [PATCH] feat: fix incorrect preferred_username field mapping in OIDC (#1697) --- idp/casdoor.go | 4 ++-- idp/custom.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/idp/casdoor.go b/idp/casdoor.go index 04a140ee..67b810cf 100644 --- a/idp/casdoor.go +++ b/idp/casdoor.go @@ -108,8 +108,8 @@ func (idp *CasdoorIdProvider) GetToken(code string) (*oauth2.Token, error) { type CasdoorUserInfo struct { Id string `json:"sub"` - Name string `json:"name"` - DisplayName string `json:"preferred_username"` + Name string `json:"preferred_username,omitempty"` + DisplayName string `json:"name"` Email string `json:"email"` AvatarUrl string `json:"picture"` Status string `json:"status"` diff --git a/idp/custom.go b/idp/custom.go index abd51714..5447272b 100644 --- a/idp/custom.go +++ b/idp/custom.go @@ -61,8 +61,8 @@ func (idp *CustomIdProvider) GetToken(code string) (*oauth2.Token, error) { type CustomUserInfo struct { Id string `json:"sub"` - Name string `json:"name"` - DisplayName string `json:"preferred_username"` + Name string `json:"preferred_username,omitempty"` + DisplayName string `json:"name"` Email string `json:"email"` AvatarUrl string `json:"picture"` Status string `json:"status"`