Skip to content

Commit

Permalink
Merge pull request #1 from open-ch/microsoft-oidc-fix
Browse files Browse the repository at this point in the history
FIX: Fix Microsoft connector and adjust workflow
  • Loading branch information
schuhu authored Oct 8, 2021
2 parents 67ba7a1 + bcdbc04 commit 84b4b56
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Calculate Docker image tags
id: tags
env:
DOCKER_IMAGES: "ghcr.io/dexidp/dex dexidp/dex"
DOCKER_IMAGES: "ghcr.io/schuhu/dex"
run: |
case $GITHUB_REF in
refs/tags/*) VERSION=${GITHUB_REF#refs/tags/};;
Expand Down Expand Up @@ -64,12 +64,12 @@ jobs:
password: ${{ github.token }}
if: github.event_name == 'push'

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: github.event_name == 'push'
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# if: github.event_name == 'push'

- name: Build and push
uses: docker/build-push-action@v2
Expand Down
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 @@ -130,10 +130,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 84b4b56

Please sign in to comment.