Merge pull request #1441 from jimmythedog/1440-fix-msoft-refresh-token

dexidp#1440 Add offline_access scope, if required
This commit is contained in:
Nándor István Krácser 2020-07-08 16:13:26 +02:00 committed by GitHub
commit 62efe7bf07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,9 @@ const (
// Microsoft requires this scope to list groups the user is a member of // Microsoft requires this scope to list groups the user is a member of
// and resolve their ids to groups names. // and resolve their ids to groups names.
scopeGroups = "directory.read.all" scopeGroups = "directory.read.all"
// Microsoft requires this scope to return a refresh token
// see https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#offline_access
scopeOfflineAccess = "offline_access"
) )
// Config holds configuration options for microsoft logins. // Config holds configuration options for microsoft logins.
@ -122,6 +125,10 @@ func (c *microsoftConnector) oauth2Config(scopes connector.Scopes) *oauth2.Confi
microsoftScopes = append(microsoftScopes, scopeGroups) microsoftScopes = append(microsoftScopes, scopeGroups)
} }
if scopes.OfflineAccess {
microsoftScopes = append(microsoftScopes, scopeOfflineAccess)
}
return &oauth2.Config{ return &oauth2.Config{
ClientID: c.clientID, ClientID: c.clientID,
ClientSecret: c.clientSecret, ClientSecret: c.clientSecret,