From 80a73b95d2194d227e797b62d2b9afceb7a13273 Mon Sep 17 00:00:00 2001
From: Kevin Lyda <kevin@ie.suberic.net>
Date: Mon, 4 Jun 2018 16:40:28 +0100
Subject: [PATCH] Enable new auth provider; set scopes.

---
 server/auth/microsoft/microsoft.go | 3 ++-
 server/server.go                   | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/server/auth/microsoft/microsoft.go b/server/auth/microsoft/microsoft.go
index fc0a60c7..11528b99 100644
--- a/server/auth/microsoft/microsoft.go
+++ b/server/auth/microsoft/microsoft.go
@@ -5,7 +5,7 @@ import (
 	"net/http"
 	"strings"
 
-	"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
+	//"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
 	"github.com/nsheridan/cashier/server/auth"
 	"github.com/nsheridan/cashier/server/config"
 	"github.com/nsheridan/cashier/server/metrics"
@@ -44,6 +44,7 @@ func New(c *config.Auth) (*Config, error) {
 			ClientSecret: c.OauthClientSecret,
 			RedirectURL:  c.OauthCallbackURL,
 			Endpoint:     microsoft.AzureADEndpoint(c.ProviderOpts["tenant"]),
+			Scopes:       []string{"openid", "profile", "email"},
 		},
 		tenant:    c.ProviderOpts["tenant"],
 		whitelist: uw,
diff --git a/server/server.go b/server/server.go
index 97b3c637..c990b176 100644
--- a/server/server.go
+++ b/server/server.go
@@ -16,6 +16,7 @@ import (
 	"github.com/nsheridan/cashier/server/auth/github"
 	"github.com/nsheridan/cashier/server/auth/gitlab"
 	"github.com/nsheridan/cashier/server/auth/google"
+	"github.com/nsheridan/cashier/server/auth/microsoft"
 	"github.com/nsheridan/cashier/server/config"
 	"github.com/nsheridan/cashier/server/metrics"
 	"github.com/nsheridan/cashier/server/signer"
@@ -88,12 +89,14 @@ func Run(conf *config.Config) {
 	metrics.Register()
 
 	switch conf.Auth.Provider {
-	case "google":
-		authprovider, err = google.New(conf.Auth)
 	case "github":
 		authprovider, err = github.New(conf.Auth)
 	case "gitlab":
 		authprovider, err = gitlab.New(conf.Auth)
+	case "google":
+		authprovider, err = google.New(conf.Auth)
+	case "microsoft":
+		authprovider, err = microsoft.New(conf.Auth)
 	default:
 		log.Fatalf("Unknown provider %s\n", conf.Auth.Provider)
 	}
-- 
GitLab