refactor: generate a verifier on every oauth auth session

This commit is contained in:
Stavros
2025-10-19 19:03:32 +03:00
parent 97639ae903
commit 5482430907
5 changed files with 20 additions and 8 deletions

View File

@@ -48,10 +48,7 @@ func (google *GoogleOAuthService) Init() error {
httpClient := &http.Client{}
ctx := context.Background()
ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient)
verifier := oauth2.GenerateVerifier()
google.context = ctx
google.verifier = verifier
return nil
}
@@ -65,6 +62,12 @@ func (oauth *GoogleOAuthService) GenerateState() string {
return state
}
func (google *GoogleOAuthService) GenerateVerifier() string {
verifier := oauth2.GenerateVerifier()
google.verifier = verifier
return verifier
}
func (google *GoogleOAuthService) GetAuthURL(state string) string {
return google.config.AuthCodeURL(state, oauth2.AccessTypeOffline, oauth2.S256ChallengeOption(google.verifier))
}