mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
refactor(oauth): move build url logic to service
This commit is contained in:
parent
c5c06b307a
commit
60040e90d0
3 changed files with 20 additions and 17 deletions
|
@ -165,3 +165,21 @@ func (*Service) GetUsername(token string, settings *portainer.OAuthSettings) (st
|
|||
Body: body,
|
||||
}
|
||||
}
|
||||
|
||||
// BuildLoginURL creates a login url for the oauth provider
|
||||
func (*Service) BuildLoginURL(oauthSettings portainer.OAuthSettings) string {
|
||||
endpoint := oauth2.Endpoint{
|
||||
AuthURL: oauthSettings.AuthorizationURI,
|
||||
TokenURL: oauthSettings.AccessTokenURI,
|
||||
}
|
||||
|
||||
oauthConfig := &oauth2.Config{
|
||||
ClientID: oauthSettings.ClientID,
|
||||
ClientSecret: oauthSettings.ClientSecret,
|
||||
Endpoint: endpoint,
|
||||
RedirectURL: oauthSettings.RedirectURI,
|
||||
Scopes: strings.Split(oauthSettings.Scopes, ","),
|
||||
}
|
||||
|
||||
return oauthConfig.AuthCodeURL("portainer")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue