@@ -47,12 +47,12 @@ type jsonCaller interface {
4747}
4848
4949var aadTrustedHostList = map [string ]bool {
50- "login.windows.net" : true , // Microsoft Azure Worldwide - Used in validation scenarios where host is not this list
51- "login.partner.microsoftonline.cn" : true , // Microsoft Azure China
52- "login.microsoftonline.de" : true , // Microsoft Azure Blackforest
53- "login-us.microsoftonline.com" : true , // Microsoft Azure US Government - Legacy
54- "login.microsoftonline.us" : true , // Microsoft Azure US Government
55- "login.microsoftonline.com" : true , // Microsoft Azure Worldwide
50+ "login.windows.net" : true , // Microsoft Azure Worldwide - Used in validation scenarios where host is not this list
51+ "login.partner.microsoftonline.cn" : true , // Microsoft Azure China
52+ "login.microsoftonline.de" : true , // Microsoft Azure Blackforest
53+ "login-us.microsoftonline.com" : true , // Microsoft Azure US Government - Legacy
54+ "login.microsoftonline.us" : true , // Microsoft Azure US Government
55+ "login.microsoftonline.com" : true , // Microsoft Azure Worldwide
5656}
5757
5858// TrustedHost checks if an AAD host is trusted/valid.
@@ -358,7 +358,16 @@ type Info struct {
358358
359359// NewInfoFromAuthorityURI creates an AuthorityInfo instance from the authority URL provided.
360360func NewInfoFromAuthorityURI (authority string , validateAuthority bool , instanceDiscoveryDisabled bool ) (Info , error ) {
361- u , err := url .Parse (strings .ToLower (authority ))
361+
362+ cannonicalAuthority := authority
363+
364+ // suffix authority with / if it doesn't have one
365+ if ! strings .HasSuffix (authority , "/" ) {
366+ cannonicalAuthority += "/"
367+ }
368+
369+ u , err := url .Parse (strings .ToLower (cannonicalAuthority ))
370+
362371 if err != nil {
363372 return Info {}, fmt .Errorf ("couldn't parse authority url: %w" , err )
364373 }
@@ -376,7 +385,7 @@ func NewInfoFromAuthorityURI(authority string, validateAuthority bool, instanceD
376385 case "adfs" :
377386 authorityType = ADFS
378387 case "dstsv2" :
379- if len (pathParts ) != 3 {
388+ if len (pathParts ) != 4 {
380389 return Info {}, fmt .Errorf ("dSTS authority must be an https URL such as https://<authority>/dstsv2/%s" , DSTSTenant )
381390 }
382391 if pathParts [2 ] != DSTSTenant {
@@ -392,7 +401,7 @@ func NewInfoFromAuthorityURI(authority string, validateAuthority bool, instanceD
392401 // u.Host includes the port, if any, which is required for private cloud deployments
393402 return Info {
394403 Host : u .Host ,
395- CanonicalAuthorityURI : authority ,
404+ CanonicalAuthorityURI : cannonicalAuthority ,
396405 AuthorityType : authorityType ,
397406 ValidateAuthority : validateAuthority ,
398407 Tenant : tenant ,
0 commit comments