Skip to content

Commit 4f95806

Browse files
authored
Use "organizations" not "common" as the default authority (#1374)
Organizations supports using both work/school accounts as well as personal accounts. This matches the default that the `az` CLI uses when logging in. Fixes #1366
1 parent 28ddb71 commit 4f95806

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

cli/azd/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 0.5.0-beta.2 (2023-01-12)
4+
5+
### Bugs Fixed
6+
7+
- [[#1366]](https://github.com/Azure/azure-dev/issues/1366) Login not possible with personal account after upgrade to 0.5.0.
8+
39
## 0.5.0-beta.1 (2023-01-11)
410

511
### Features Added

cli/azd/pkg/auth/manager.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ const cCurrentUserKey = "auth.account.currentUser"
3838
// it ourselves. The value should be a string as specified by [strconv.ParseBool].
3939
const cUseAzCliAuthKey = "auth.useAzCliAuth"
4040

41+
// cDefaultAuthority is the default authority to use when a specific tenant is not presented. We use "organizations" to
42+
// allow both work/school accounts and personal accounts (this matches the default authority the `az` CLI uses when logging
43+
// in).
44+
const cDefaultAuthority = "https://login.microsoftonline.com/organizations"
45+
4146
// The scopes to request when acquiring our token during the login flow or when requesting a token to validate if the client
4247
// is logged in.
4348
var cLoginScopes = []string{azure.ManagementScope}
@@ -83,6 +88,7 @@ func NewManager(configManager config.UserConfigManager) (*Manager, error) {
8388

8489
options := []public.Option{
8590
public.WithCache(newCache(cacheRoot)),
91+
public.WithAuthority(cDefaultAuthority),
8692
}
8793

8894
publicClientApp, err := public.New(cAZD_CLIENT_ID, options...)
@@ -161,6 +167,9 @@ func (m *Manager) CredentialForCurrentUser(
161167

162168
newOptions := make([]public.Option, 0, len(m.publicClientOptions)+1)
163169
newOptions = append(newOptions, m.publicClientOptions...)
170+
171+
// It is important that this option comes after the saved public client options since it will
172+
// override the default authority.
164173
newOptions = append(newOptions, public.WithAuthority(newAuthority))
165174

166175
clientWithNewTenant, err := public.New(cAZD_CLIENT_ID, newOptions...)

cli/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.0-beta.1
1+
0.5.0-beta.2

0 commit comments

Comments
 (0)