From 09bba2746c7d9b3181efc10fdb29c59c582f4eb1 Mon Sep 17 00:00:00 2001 From: Elena Grahovac Date: Wed, 13 Dec 2017 15:17:04 +0100 Subject: [PATCH] microsoft: improve azure active directory endpoint Rename AzureActiveDirectoryEndpoint to AzureADEndpoint. Add default tenant ("common"). Delete azure package (azure.Endpoint duplicates microsoft.AzureADEndpoint). Change-Id: I48a7679ffddd984f5744a64edfa4df958c18ed66 Reviewed-on: https://go-review.googlesource.com/83696 Reviewed-by: JBD --- azure/azure.go | 16 ---------------- microsoft/microsoft.go | 8 ++++++-- 2 files changed, 6 insertions(+), 18 deletions(-) delete mode 100644 azure/azure.go diff --git a/azure/azure.go b/azure/azure.go deleted file mode 100644 index 171b264..0000000 --- a/azure/azure.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The oauth2 Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package azure provides constants for using OAuth2 to access Azure Active Directory (Azure AD). -package azure - -import ( - "golang.org/x/oauth2" -) - -// Endpoint is the Azure Active Directory (Azure AD) OAuth 2.0 endpoint. -var Endpoint = oauth2.Endpoint{ - AuthURL: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", - TokenURL: "https://login.microsoftonline.com/common/oauth2/v2.0/token", -} diff --git a/microsoft/microsoft.go b/microsoft/microsoft.go index 2fe8afc..3ffbc57 100644 --- a/microsoft/microsoft.go +++ b/microsoft/microsoft.go @@ -15,11 +15,15 @@ var LiveConnectEndpoint = oauth2.Endpoint{ TokenURL: "https://login.live.com/oauth20_token.srf", } -// AzureActiveDirectoryEndpoint returns a new oauth2.Endpoint for the given tenant at Azure Active Directory. +// AzureADEndpoint returns a new oauth2.Endpoint for the given tenant at Azure Active Directory. +// If tenant is empty, it uses the tenant called `common`. // // For more information see: // https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints -func AzureActiveDirectoryEndpoint(tenant string) oauth2.Endpoint { +func AzureADEndpoint(tenant string) oauth2.Endpoint { + if tenant == "" { + tenant = "common" + } return oauth2.Endpoint{ AuthURL: "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0/authorize", TokenURL: "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0/token",