spring-projects / spring-projects/spring-session

SpringSessionRememberMeServices does not use RememberMeAuthenticationToken

Open
#3,439 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Describe the bug
If a security context has been created via a "remember me" mechanism rather than fresh credentials, this should be expressed via a RememberMeAuthenticationToken. This is required so that assertions such as fullyAuthenticated() work correctly.

To Reproduce
Spring Boot application with the following config:

@Bean 
public SecurityFilterChain securityFilterChain(HttpSecurity http) {
    return http.securityMatcher("/**")
        .formLogin(config -> config.permitAll())
        .rememberMe(config -> config.rememberMeServices(new SpringSessionRememberMeServices())
        .authorizeHttpRequests(authorize -> authorize
            .requestMatchers("/sensitive").fullyAuthenticated()
            .anyRequest().authenticated()
        ).build();
}
  1. Start server and browser
  2. Login to application with "remember me" selected
  3. Visit /sensitive
  4. Restart browser
  5. Visit /sensitive

Expected behavior
Accessing /sensitive should trigger a login flow, as with the default .rememberMe() behaviour.

Additional context
Due to the implementation of just extending the current session, there is no way to tell whether the user has entered their credentials in the current browser session or not.

If "wontfix", then there should at least be a big warning somewhere that this breaks fullyAuthenticated().

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the SpringSessionRememberMeServices entry point and trace how a remembered session restores the security context. Reproduce the supplied Spring Boot flow, then verify that visiting /sensitive after restarting the browser triggers login through fullyAuthenticated().

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
authentication, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.