Skip to content

Commit 9bf4a83

Browse files
authored
Fix WithTenantID("adfs") regression (#529)
1 parent 37930fb commit 9bf4a83

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

apps/internal/oauth/ops/authority/authority.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ func NewInfoFromAuthorityURI(authority string, validateAuthority bool, instanceD
380380
return Info{}, errors.New(`authority must be an URL such as "https://login.microsoftonline.com/<your tenant>"`)
381381
}
382382

383-
var authorityType, tenant string
384-
switch pathParts[1] {
383+
authorityType := AAD
384+
tenant := pathParts[1]
385+
switch tenant {
385386
case "adfs":
386387
authorityType = ADFS
387388
case "dstsv2":
@@ -393,9 +394,6 @@ func NewInfoFromAuthorityURI(authority string, validateAuthority bool, instanceD
393394
}
394395
authorityType = DSTS
395396
tenant = DSTSTenant
396-
default:
397-
authorityType = AAD
398-
tenant = pathParts[1]
399397
}
400398

401399
// u.Host includes the port, if any, which is required for private cloud deployments

apps/internal/oauth/ops/authority/authority_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ func TestAuthorityParsing(t *testing.T) {
330330
}{
331331
"AAD with slash": {"https://login.microsoftonline.com/common/", "MSSTS", "https://login.microsoftonline.com/common/", "common"},
332332
"AAD without slash": {"https://login.microsoftonline.com/common", "MSSTS", "https://login.microsoftonline.com/common/", "common"},
333-
"ADFS with slash": {"https://adfs.example.com/adfs/", "ADFS", "https://adfs.example.com/adfs/", ""},
334-
"ADFS without slash": {"https://adfs.example.com/adfs", "ADFS", "https://adfs.example.com/adfs/", ""},
333+
"ADFS with slash": {"https://adfs.example.com/adfs/", "ADFS", "https://adfs.example.com/adfs/", "adfs"},
334+
"ADFS without slash": {"https://adfs.example.com/adfs", "ADFS", "https://adfs.example.com/adfs/", "adfs"},
335335
"dSTS with slash": {dSTSWithSlash, "DSTS", dSTSWithSlash, DSTSTenant},
336336
"dSTS without slash": {dSTSNoSlash, "DSTS", dSTSWithSlash, DSTSTenant},
337337
}
@@ -364,6 +364,7 @@ func TestAuthParamsWithTenant(t *testing.T) {
364364
}{
365365
"do nothing if tenant override is empty": {authority: host + uuid1, tenant: "", expectedAuthority: host + uuid1},
366366
"do nothing if tenant override is empty for ADFS": {authority: host + "adfs", tenant: "", expectedAuthority: host + "adfs"},
367+
`do nothing if tenant override is adfs for ADFS`: {authority: host + "adfs", tenant: "adfs", expectedAuthority: host + "adfs"},
367368
"do nothing if tenant override equals tenant": {authority: host + uuid1, tenant: uuid1, expectedAuthority: host + uuid1},
368369

369370
"override common to tenant": {authority: host + "common", tenant: uuid1, expectedAuthority: host + uuid1},

0 commit comments

Comments
 (0)