Describe the bug When I use the [oauth2-login] tag, the [Login with OAuth 2.0] and [Login with OpenID Identity] form are displayed on the page at the same time. I just want to display the [login with OAuth 2.0] form. At the same time, what should I do if I want to remove the [DefaultLoginPageGeneratingFilter] by the [namespace configuration].
To Reproduce
<sec:http>
<sec:intercept-url pattern="/" access="permitAll()" />
<sec:intercept-url pattern="/index" access="isAuthenticated()" />
<sec:intercept-url pattern="/helloworld" access="hasRole('CUSTOMER')" />
<sec:oauth2-login/>
</sec:http>
<sec:client-registrations>
<sec:client-registration registration-id="keycloak"
client-id="myclient"
provider-id="keycloak".../>
<sec:provider provider-id="keycloak".../>
</sec:client-registrations>
Expected behavior I want to use oauth2 to log in through keydepot. The keydepot login link displayed in the default login page.
the img:
my spring seucrity version
<!-- spring security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
<version>5.7.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.7.2</version>
</dependency>
Findings: AuthenticationConfigBuilder#createLoginPageFilterIfNeeded()
if (this.oauth2LoginFilterId != null) {
**loginPageFilter.addConstructorArgReference(this.oauth2LoginFilterId);**
loginPageFilter.addPropertyValue("Oauth2LoginEnabled", true);
loginPageFilter.addPropertyValue("Oauth2AuthenticationUrlToClientName", this.oauth2LoginLinks);
}
DefaultLoginPageGeneratingFilter
public DefaultLoginPageGeneratingFilter(AbstractAuthenticationProcessingFilter filter) {
if (filter instanceof UsernamePasswordAuthenticationFilter) {
this.init((UsernamePasswordAuthenticationFilter)filter, (AbstractAuthenticationProcessingFilter)null);
} else {
**this.init((UsernamePasswordAuthenticationFilter)null, filter);**
}
}
public DefaultLoginPageGeneratingFilter(UsernamePasswordAuthenticationFilter authFilter, AbstractAuthenticationProcessingFilter openIDFilter) {
this.init(authFilter, openIDFilter);
}
private void init(UsernamePasswordAuthenticationFilter authFilter, AbstractAuthenticationProcessingFilter openIDFilter) {
...
if (openIDFilter != null) {
this.initOpenIdFilter(openIDFilter);
}
}
private void initOpenIdFilter(AbstractAuthenticationProcessingFilter openIDFilter) {
this.openIdEnabled = true;
this.openIDusernameParameter = "openid_identifier";
...
}
Comment From: jzheaux
Thanks for getting in touch! It feels like this is a question that would be better suited to Stack Overflow. We prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add more detail if you feel this is a genuine bug.
Comment From: carolinachamas
@guohao-91 Do you have any news about this? I'm facing the same and I couldn't disable it. Have you created it in stackoverflow?