Merge pull request #13126 from Thoro/fix-10913-oidc-error-after-restart

fix #10913: initialize oidc provider before calling Load
This commit is contained in:
Wenkai Yin(尹文开) 2020-10-14 10:13:52 +08:00 committed by GitHub
commit 4d78fd4e4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -241,6 +241,11 @@ func refreshToken(ctx context.Context, token *Token) (*Token, error) {
// UserInfoFromToken tries to call the UserInfo endpoint of the OIDC provider, and consolidate with ID token
// to generate a UserInfo object, if the ID token is not in the input token struct, some attributes will be empty
func UserInfoFromToken(ctx context.Context, token *Token) (*UserInfo, error) {
// #10913: preload the configuration, in case it was not previously loaded by the UI
_, err := provider.get()
if err != nil {
return nil, err
}
setting := provider.setting.Load().(models.OIDCSetting)
local, err := userInfoFromIDToken(ctx, token, setting)
if err != nil {