Skip to content

Commit

Permalink
idp: handle assertions where no ACS url is specified (crewjam#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
crewjam authored Feb 21, 2018
1 parent 16d16c2 commit 794aa92
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions identity_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,36 @@ func (req *IdpAuthnRequest) getACSEndpoint() error {
}
}

// Some service providers, like the Microsoft Azure AD service provider, issue
// assertion requests that don't specify an ACS url at all.
if req.Request.AssertionConsumerServiceURL == "" && req.Request.AssertionConsumerServiceIndex == "" {
// find a default ACS binding in the metadata that we can use
for _, spssoDescriptor := range req.ServiceProviderMetadata.SPSSODescriptors {
for _, spAssertionConsumerService := range spssoDescriptor.AssertionConsumerServices {
if spAssertionConsumerService.IsDefault != nil && *spAssertionConsumerService.IsDefault {
switch spAssertionConsumerService.Binding {
case HTTPPostBinding, HTTPRedirectBinding:
req.SPSSODescriptor = &spssoDescriptor
req.ACSEndpoint = &spAssertionConsumerService
return nil
}
}
}
}

// if we can't find a default, use *any* ACS binding
for _, spssoDescriptor := range req.ServiceProviderMetadata.SPSSODescriptors {
for _, spAssertionConsumerService := range spssoDescriptor.AssertionConsumerServices {
switch spAssertionConsumerService.Binding {
case HTTPPostBinding, HTTPRedirectBinding:
req.SPSSODescriptor = &spssoDescriptor
req.ACSEndpoint = &spAssertionConsumerService
return nil
}
}
}
}

return os.ErrNotExist // no ACS url found or specified
}

Expand Down

0 comments on commit 794aa92

Please sign in to comment.