Try to make gitlab authentication stable

This commit is contained in:
nemunaire 2022-09-04 21:44:03 +02:00
parent 6bef42a71e
commit f572058f79

View File

@ -57,10 +57,17 @@ func initializeGitLabOIDC(router *gin.Engine, authrouter *gin.RouterGroup, admin
} }
if _, err := os.Stat(OAUTH_GITLAB_FILE); err == nil { if _, err := os.Stat(OAUTH_GITLAB_FILE); err == nil {
gitlabToken, err = loadOAuth2Token(OAUTH_GITLAB_FILE) tk, err := loadOAuth2Token(OAUTH_GITLAB_FILE)
if err != nil { if err != nil {
log.Println("Unable to load OAuth2 Token:", err.Error()) log.Println("Unable to load OAuth2 Token:", err.Error())
} }
tsource := oauth2.ReuseTokenSource(gitlabToken, gitlaboauth2Config.TokenSource(context.Background(), tk))
gitlabToken, err = tsource.Token()
if err != nil {
log.Fatal("Unable to regenerate GitLab token:", err)
}
log.Println(gitlabToken)
} }
} }