-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
in: configAn issue in spring-security-configAn issue in spring-security-configstatus: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: breaks-passivityA change that breaks passivity with the previous releaseA change that breaks passivity with the previous releasetype: bugA general bugA general bug
Milestone
Description
Summary
When using a Form Login, a single OAuth2 provider and the auto-generated login page, the auto-configured AuthenticationEntryPoint
will redirect to the provider immediately, bypassing the login page and effectively preventing form login.
Actual Behavior
When trying to access a protected resource, spring security will immediately redirect to the OAuth2 provider's authentication page instead of the local login page.
Expected Behavior
When Form Login is configured, the login page should never be skipped.
Configuration
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated()
.and()
.oauth2Login()
.and()
.oauth2Client()
.and()
.formLogin().permitAll();
}
spring.security.oauth2.client.registration.facebook.client-id=some-id
spring.security.oauth2.client.registration.facebook.client-secret=some-secret
Version
5.1.4-RELEASE, not sure as of which version this happens.
Sample
I don't have a sample, but I found the exact location of the bug:
Lines 444 to 453 in 2c136f7
if (loginUrlToClientName.size() == 1) { | |
// Setup auto-redirect to provider login page | |
// when only 1 client is configured | |
this.updateAuthenticationDefaults(); | |
this.updateAccessDefaults(http); | |
String providerLoginPage = loginUrlToClientName.keySet().iterator().next(); | |
this.registerAuthenticationEntryPoint(http, this.getLoginEntryPoint(http, providerLoginPage)); | |
} else { | |
super.init(http); | |
} |
The condition should check whether Form Login is enabled and don't apply the shortcut if it is.
rhamedy
Metadata
Metadata
Assignees
Labels
in: configAn issue in spring-security-configAn issue in spring-security-configstatus: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: breaks-passivityA change that breaks passivity with the previous releaseA change that breaks passivity with the previous releasetype: bugA general bugA general bug