Skip to content

Commit

Permalink
Allow AudienceRestriction to be missing
Browse files Browse the repository at this point in the history
re #198
  • Loading branch information
Stephen Kress authored and crewjam committed May 8, 2019
1 parent d288d9a commit ca21de9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (sp *ServiceProvider) validateAssertion(assertion *Assertion, possibleReque
return fmt.Errorf("Conditions is expired")
}

audienceRestrictionsValid := false
audienceRestrictionsValid := len(assertion.Conditions.AudienceRestrictions) == 0
for _, audienceRestriction := range assertion.Conditions.AudienceRestrictions {
if audienceRestriction.Audience.Value == sp.MetadataURL.String() {
audienceRestrictionsValid = true
Expand Down
5 changes: 5 additions & 0 deletions service_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,11 @@ func (test *ServiceProviderTest) TestInvalidAssertions(c *C) {
c.Assert(err.Error(), Equals, "Conditions AudienceRestriction does not contain \"https://15661444.ngrok.io/saml2/metadata\"")
assertion = Assertion{}
xml.Unmarshal(assertionBuf, &assertion)

// Not having an audience is not an error
assertion.Conditions.AudienceRestrictions = []AudienceRestriction{}
err = s.validateAssertion(&assertion, []string{"id-9e61753d64e928af5a7a341a97f420c9"}, TimeNow())
c.Assert(err, Equals, nil)
}

func (test *ServiceProviderTest) TestRealWorldKeyInfoHasRSAPublicKeyNotX509Cert(c *C) {
Expand Down

0 comments on commit ca21de9

Please sign in to comment.