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

SAML SSO Service preferred binding type from IDP metadata #16454

Closed
codemasterover9000 opened this issue Jan 20, 2025 · 3 comments
Closed

SAML SSO Service preferred binding type from IDP metadata #16454

codemasterover9000 opened this issue Jan 20, 2025 · 3 comments
Assignees
Labels
in: saml2 An issue in SAML2 modules status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement

Comments

@codemasterover9000
Copy link

Expected Behavior

Allow The RelyingPartyRegistrations.fromMetadata*() methods to select a prefered binding type from the IDP metadata document.

Current Behavior

The RelyingPartyRegistrations.fromMetadata*() methods now pick the first binding type it comes across that is either redirect of post. So the order in which they appear in de IDP metadata document determines the used binding type.

Context

Due to security policies we need to use the POST binding if it is available. Currently implemented this by parsing the IDP metadata "manually".

@codemasterover9000 codemasterover9000 added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Jan 20, 2025
@sjohnr sjohnr added the in: saml2 An issue in SAML2 modules label Jan 23, 2025
@jzheaux
Copy link
Contributor

jzheaux commented Jan 28, 2025

Hi, @codemasterover9000, thanks for the suggestion.

With the introduction of AssertingPartyMetadataRepository, this is simpler than it once was:

AssertingPartyMetadataRepository idps = OpenSaml5AssertingPartyMetadataRepository.
        withMetadataLocation("https://ap.example.org");

private RelyingPartyRegistration.Builder ensurePostBinding() {
    OpenSamlAssertingPartyDetails idp = (OpenSamlAssertingPartyDetails) assertingParties.iterator().next();
    RelyingPartyRegistration.Builder builder = RelyingPartyRegistration.withAssertingPartyMetadata(idp);   
    if (hasPostBinding(idp.getEntityDescriptor())) {
        builder.assertingPartyMetadata((party) -> party.singleSignOnServiceBinding(Saml2MessageBinding.POST))
    }
    return builder;
}

The nice thing about this approach is that OpenSaml5AssertingPartyMetadataRepository periodically refreshes the metadata, which is handy if you are getting it from an HTTPS endpoint:

@Component
public class PostEnsuringRelyingPartyRegistrationRepository implements IterableRelyingPartyRegistrationRepository {
    private final AssertingPartyMetadataRepository idps = ...;

    @Override 
    public RelyingPartyRegistration findByRegistrationId(String registrationId) {
         RelyingPartyRegistration.Builder builder = ensurePostBinding()
         // sp customizations
         return builder.build();
    }

    // ...
}

Does something like this address your use case?

@jzheaux jzheaux added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 28, 2025
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Feb 4, 2025
@codemasterover9000
Copy link
Author

@jzheaux Thanks for the response. This is a good solution and as you said with the added benefit of periodically updating the metadata.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: saml2 An issue in SAML2 modules status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants