Skip to content

Commit

Permalink
Adjust scopes to be in line with the Microsoft Identity Platform v2.
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauchli <[email protected]>
  • Loading branch information
Christian Brauchli committed Mar 18, 2021
1 parent 83ad7bc commit b033017
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions connector/microsoft/microsoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const (
)

const (
// Microsoft requires this scope to access user's profile
scopeUser = "user.read"
// Microsoft requires this scope to list groups the user is a member of
// and resolve their ids to groups names.
scopeGroups = "directory.read.all"
// Microsoft requires the scopes to start with openid
scopeOpenId = "openid"
// Get the permissions configured on the application registration
// see https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#the-default-scope
scopeDefault = "https://graph.microsoft.com/.default"
// 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"
Expand Down Expand Up @@ -124,10 +124,8 @@ func (c *microsoftConnector) groupsRequired(groupScope bool) bool {
}

func (c *microsoftConnector) oauth2Config(scopes connector.Scopes) *oauth2.Config {
microsoftScopes := []string{scopeUser}
if c.groupsRequired(scopes.Groups) {
microsoftScopes = append(microsoftScopes, scopeGroups)
}
microsoftScopes := []string{scopeOpenId}
microsoftScopes = append(microsoftScopes, scopeDefault)

if scopes.OfflineAccess {
microsoftScopes = append(microsoftScopes, scopeOfflineAccess)
Expand Down

0 comments on commit b033017

Please sign in to comment.