Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate audience with entityIssuer if present, use redirectURI otherwise #896

Merged
merged 1 commit into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/saml-connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ connectors:
# insecureSkipSignatureValidation: true

# Optional: Issuer value for AuthnRequest
# Must be contained within the "AudienceRestriction" attribute in all responses
# If not set, redirectURI will be used for audience validation
entityIssuer: https://dex.example.com/callback

# Optional: Issuer value for SAML Response
Expand Down
8 changes: 6 additions & 2 deletions connector/saml/saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,21 +466,25 @@ func (p *provider) validateConditions(assertion *assertion) error {
}
}
// Validates audience
audienceValue := p.entityIssuer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me, but do you think it'd be better to make entityIssuer required? I'm a little on the fence, but it seems like this is important when verifying the audience restrictions.

Would like to know what sounds more reasonable to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'll be ok as long as we make it clear in the documentation. Let me add it.

if audienceValue == "" {
audienceValue = p.redirectURI
}
audienceRestriction := conditions.AudienceRestriction
if audienceRestriction != nil {
audiences := audienceRestriction.Audiences
if audiences != nil && len(audiences) > 0 {
values := make([]string, len(audiences))
issuerInAudiences := false
for i, audience := range audiences {
if audience.Value == p.redirectURI {
if audience.Value == audienceValue {
issuerInAudiences = true
break
}
values[i] = audience.Value
}
if !issuerInAudiences {
return fmt.Errorf("required audience %s was not in Response audiences %s", p.redirectURI, values)
return fmt.Errorf("required audience %s was not in Response audiences %s", audienceValue, values)
}
}
}
Expand Down