Skip to content

ServerHttpSecurity: oauth2Login() ignores securityContextRepository() #7222

Closed

Description

@ilgrosso

In org.springframework.security.config.web.server.ServerHttpSecurity.OAuth2LoginSpec#configure, the line

authenticationFilter.setSecurityContextRepository(new WebSessionServerSecurityContextRepository());

does not take into account ServerHttpSecurity.this.securityContextRepository (which has the same default value, but can be customized by invoking securityContextRepository()) and blindly creates a new instance of WebSessionServerSecurityContextRepository.

Activity

  1. jzheaux commented on Aug 8, 2019

    @jzheaux
    Collaborator

    The JavaDoc for ServerHttpSecurity#securityContextRepository states:

    It does not impact how the {@code SecurityContext} is saved which is configured on a per {@link AuthenticationWebFilter} basis

    The way that HttpBasicSpec and FormLoginSpec are configured is as follows:

    http
        .httpBasic()
            .securityContextRepository(...)

    and

    http
        .formLogin()
            .securityContextRepository(...)

    Given the JavaDoc and the way that other authentication mechanisms work, it would seem to be preferable instead to add a securityContextRepository method to the oauth2Login DSL:

    http
        .oauth2Login()
            .securityContextRepository(...)

    Would you be willing to provide a PR along those lines instead? It would be one that introduces securityContextRepository(...) to OAuth2LoginSpec.

  2. added
    in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
    and removed on Aug 8, 2019
  3. added this to the 5.2.0.RC1 milestone on Aug 8, 2019
  4. self-assigned this
    on Aug 8, 2019
  5. ilgrosso commented on Aug 9, 2019

    @ilgrosso
    ContributorAuthor

    @jzheaux thanks for review; here's the new PR: #7244

  6. added a commit that references this issue on Aug 26, 2019
    7ab367e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: enhancementA general enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions