Skip to content

SAML2 customizable URLs #8873

Closed
Closed

Description

@JoakimLofgren

Expected Behavior

I want to be able to change all SAML2 URLs to be able to e.g. add a prefix.

Current Behavior

Some URLs are customizable, like Saml2LoginConfigurer.loginProcessingUrl.
While some are not, e.g. Saml2LoginConfigurer.AuthenticationRequestEndpointConfig.filterProcessingUrl (/saml2/authenticate/{registrationId}).

Context

A workaround for adding a path prefix is using the server.servlet.context-path.
But this doesn't work if you want to tweak URLs to be similar to an already existing solution created with the old SAML module.

Although assuming you want /auth as a prefix, and after login you want to redirect to the root / and not /auth/,
you cannot use the default success handler. You need to create a custom one with a redirect strategy which is not context relative.

Activity

  1. added
    status: waiting-for-triage
    type: enhancement
    on Jul 23, 2020
  2. jzheaux commented on Jul 23, 2020

    @jzheaux
    Collaborator

    @JoakimLofgren I think it makes sense to simplify configuring the URL for creating an AuthnRequest.

    If we follow the pattern established in OAuth2LoginConfigurer, I think most decisions will be fairly straightforward. For example, it would be nice to do:

    http
        .saml2Login(saml2 -> saml2
            .authenticationRequestEndpoint(authn -> authn
                .baseUri(myCustomUri)
            )
        );

    Then that would be quite similar to:

    http
        .oauth2Login(oauth2 -> oauth2
            .authorizationEndpoint(authz -> authz
                .baseUri(myCustomUri)
            )
        );

    Would you be able to submit a PR along those lines to enhance the DSL? It would also be quite nice to update the Kotlin DSL while you are at it.

  3. self-assigned this
    on Jul 23, 2020
  4. added
    in: saml2
    status: waiting-for-feedback
    and removed
    status: waiting-for-triage
    on Jul 23, 2020
  5. JoakimLofgren commented on Jul 29, 2020

    @JoakimLofgren
    ContributorAuthor

    Sure. After #8864 is finished.

  6. added
    status: feedback-provided
    and removed
    status: waiting-for-feedback
    on Jul 29, 2020
  7. jzheaux commented on Dec 3, 2020

    @jzheaux
    Collaborator

    After a bit more experimentation with it, I think the following is easier to read:

    http
        .saml2Login(saml2 -> saml2
            .loginProcessingUrl("/saml2/response/{registrationId}")
            .authenticationRequestUri("/saml2/request/{registrationId}")
        );

    I like it because it has less hierarchy.

  8. jzheaux commented on Dec 3, 2020

    @jzheaux
    Collaborator

    @JoakimLofgren are you still able to contribute a PR to add support for configuring the Saml2WebSsoAuthenticationRequestFilter URI?

  9. added
    status: ideal-for-contribution
    on Dec 15, 2020
  10. chelseakohli commented on Apr 12, 2021

    @chelseakohli

    Hey, I am kind of stuck on being not able to change default entityId & replyUrl in AuthRequest. My SP is running on http, so the urls for entityId & replyUrl are being generated for http. But by making some firewall changes, publicly website access is only by https. So basically I want the urls in AuthRequest to be https.

  11. jzheaux commented on Apr 21, 2021

    @jzheaux
    Collaborator

    @chelseakohli, this would probably be better as a StackOverflow question, so please consider posting there if my answer here doesn't address your question and also update your comment with the StackOverflow link.

    You can customize the AuthnRequest by configuring the OpenSamlAuthenticationRequestFactory:

    @Bean 
    Saml2AuthenticationRequestFactory authenticationRequestFactory() {
        OpenSamlAuthenticationRequestFactory factory =
                new OpenSamlAuthenticationRequestFactory();
        factory.setAuthenticationRequestContextConverter((context) -> {
            // construct the AuthnRequest
        });
    }
  12. 4 remaining items

  13. bramhaag commented on Feb 18, 2022

    @bramhaag

    Any progress?

  14. jzheaux commented on Feb 18, 2022

    @jzheaux
    Collaborator

    While some are not, e.g. Saml2LoginConfigurer.AuthenticationRequestEndpointConfig.filterProcessingUrl (/saml2/authenticate/{registrationId})

    @JoakimLofgren, I've created #10840 to specifically address the authentication request URI. Are there any other endpoints that you would like to see addressed? If not, I'll close this issue in favor of #10840.

  15. added
    status: waiting-for-feedback
    and removed
    status: feedback-provided
    status: ideal-for-contribution
    on Feb 18, 2022
  16. spring-projects-issues commented on Feb 25, 2022

    @spring-projects-issues

    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.

  17. added
    status: feedback-reminder
    on Feb 25, 2022
  18. JoakimLofgren commented on Feb 26, 2022

    @JoakimLofgren
    ContributorAuthor

    Sounds good. 👍

  19. added a commit that references this issue on Jun 5, 2022
    c82528f
  20. added a commit that references this issue on Jun 6, 2022
    f4049c1
  21. removed
    status: waiting-for-feedback
    status: feedback-reminder
    on Jun 6, 2022
  22. added this to the 6.0.0-M6 milestone on Jun 6, 2022
  23. removed this from the 6.0.0-M6 milestone on Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: saml2type: enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions