spring-projects / spring-projects/spring-security
Spring Security x509 won't allow multiple authentication
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Summary
With form login, you can re-authenticate a user via username/password at any time with Spring Security. With x509 authentication, this doesn't work and Spring always returns the last cert seen, even if you clear the context.
Actual Behavior
With http.x509() enabled, Spring Security acquires a cert but won't allow the user re-authenticate with another cert unless the SSL state is cleared on the browser or if the browser is closed and re-opened (unless you're on IE and request a new session).
Expected Behavior
With x509 enabled, I expect to have a way to re-authenticate the user by displaying a cert dialog again. With form login, you would just ask for their credentials and pass that in to the authentication manager. With cert based, it's a PreAuthenticatedAuthorizationToken so there's nothing new for us to authenticate with.
Configuration
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.mvcMatchers("/home").hasAnyAuthority("ADMIN")
.mvcMatchers("/**").permitAll()
.and()
.x509()
.subjectPrincipalRegex("CN=(.*?),")
.userDetailsService(userDetailsService());
}
@Bean
public UserDetailsService userDetailsService()
{
return new UserDetailsService() {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return new User(username, "", Arrays.asList(new SimpleGrantedAuthority("ADMIN")));
}
};
}
Version
2.0.4.Release. This issue is also observed on 1.5.12.Release.
Sample
See full example @ https://github.com/subatron/spring-security-x509-complete
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the http.x509() configuration and the PreAuthenticatedAuthorizationToken behavior described in the issue, then reproduce the problem using the linked spring-security-x509-complete sample. Done means a user can trigger certificate-based re-authentication with a different certificate without clearing browser SSL state or restarting the browser.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100