Remove spring-security-openid
Closes gh-10773
This commit is contained in:
@@ -280,7 +280,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
|
||||
* </ol>
|
||||
* @param request from which to extract parameters and perform the authentication
|
||||
* @param response the response, which may be needed if the implementation has to do a
|
||||
* redirect as part of a multi-stage authentication process (such as OpenID).
|
||||
* redirect as part of a multi-stage authentication process (such as OIDC).
|
||||
* @return the authenticated user token, or null if authentication is incomplete.
|
||||
* @throws AuthenticationException if authentication fails.
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,6 @@ import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.WebAttributes;
|
||||
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -63,8 +62,6 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
|
||||
private boolean formLoginEnabled;
|
||||
|
||||
private boolean openIdEnabled;
|
||||
|
||||
private boolean oauth2LoginEnabled;
|
||||
|
||||
private boolean saml2LoginEnabled;
|
||||
@@ -77,12 +74,6 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
|
||||
private String rememberMeParameter;
|
||||
|
||||
private String openIDauthenticationUrl;
|
||||
|
||||
private String openIDusernameParameter;
|
||||
|
||||
private String openIDrememberMeParameter;
|
||||
|
||||
private Map<String, String> oauth2AuthenticationUrlToClientName;
|
||||
|
||||
private Map<String, String> saml2AuthenticationUrlToProviderName;
|
||||
@@ -92,31 +83,13 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
public DefaultLoginPageGeneratingFilter() {
|
||||
}
|
||||
|
||||
public DefaultLoginPageGeneratingFilter(AbstractAuthenticationProcessingFilter filter) {
|
||||
if (filter instanceof UsernamePasswordAuthenticationFilter) {
|
||||
init((UsernamePasswordAuthenticationFilter) filter, null);
|
||||
}
|
||||
else {
|
||||
init(null, filter);
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultLoginPageGeneratingFilter(UsernamePasswordAuthenticationFilter authFilter,
|
||||
AbstractAuthenticationProcessingFilter openIDFilter) {
|
||||
init(authFilter, openIDFilter);
|
||||
}
|
||||
|
||||
private void init(UsernamePasswordAuthenticationFilter authFilter,
|
||||
AbstractAuthenticationProcessingFilter openIDFilter) {
|
||||
public DefaultLoginPageGeneratingFilter(UsernamePasswordAuthenticationFilter authFilter) {
|
||||
this.loginPageUrl = DEFAULT_LOGIN_PAGE_URL;
|
||||
this.logoutSuccessUrl = DEFAULT_LOGIN_PAGE_URL + "?logout";
|
||||
this.failureUrl = DEFAULT_LOGIN_PAGE_URL + "?" + ERROR_PARAMETER_NAME;
|
||||
if (authFilter != null) {
|
||||
initAuthFilter(authFilter);
|
||||
}
|
||||
if (openIDFilter != null) {
|
||||
initOpenIdFilter(openIDFilter);
|
||||
}
|
||||
}
|
||||
|
||||
private void initAuthFilter(UsernamePasswordAuthenticationFilter authFilter) {
|
||||
@@ -128,15 +101,6 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
}
|
||||
}
|
||||
|
||||
private void initOpenIdFilter(AbstractAuthenticationProcessingFilter openIDFilter) {
|
||||
this.openIdEnabled = true;
|
||||
this.openIDusernameParameter = "openid_identifier";
|
||||
if (openIDFilter.getRememberMeServices() instanceof AbstractRememberMeServices) {
|
||||
this.openIDrememberMeParameter = ((AbstractRememberMeServices) openIDFilter.getRememberMeServices())
|
||||
.getParameter();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a Function used to resolve a Map of the hidden inputs where the key is the
|
||||
* name of the input and the value is the value of the input. Typically this is used
|
||||
@@ -149,7 +113,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.formLoginEnabled || this.openIdEnabled || this.oauth2LoginEnabled || this.saml2LoginEnabled;
|
||||
return this.formLoginEnabled || this.oauth2LoginEnabled || this.saml2LoginEnabled;
|
||||
}
|
||||
|
||||
public void setLogoutSuccessUrl(String logoutSuccessUrl) {
|
||||
@@ -172,10 +136,6 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
this.formLoginEnabled = formLoginEnabled;
|
||||
}
|
||||
|
||||
public void setOpenIdEnabled(boolean openIdEnabled) {
|
||||
this.openIdEnabled = openIdEnabled;
|
||||
}
|
||||
|
||||
public void setOauth2LoginEnabled(boolean oauth2LoginEnabled) {
|
||||
this.oauth2LoginEnabled = oauth2LoginEnabled;
|
||||
}
|
||||
@@ -198,15 +158,6 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
|
||||
public void setRememberMeParameter(String rememberMeParameter) {
|
||||
this.rememberMeParameter = rememberMeParameter;
|
||||
this.openIDrememberMeParameter = rememberMeParameter;
|
||||
}
|
||||
|
||||
public void setOpenIDauthenticationUrl(String openIDauthenticationUrl) {
|
||||
this.openIDauthenticationUrl = openIDauthenticationUrl;
|
||||
}
|
||||
|
||||
public void setOpenIDusernameParameter(String openIDusernameParameter) {
|
||||
this.openIDusernameParameter = openIDusernameParameter;
|
||||
}
|
||||
|
||||
public void setOauth2AuthenticationUrlToClientName(Map<String, String> oauth2AuthenticationUrlToClientName) {
|
||||
@@ -282,19 +233,6 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
sb.append(" <button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\">Sign in</button>\n");
|
||||
sb.append(" </form>\n");
|
||||
}
|
||||
if (this.openIdEnabled) {
|
||||
sb.append(" <form name=\"oidf\" class=\"form-signin\" method=\"post\" action=\"" + contextPath
|
||||
+ this.openIDauthenticationUrl + "\">\n");
|
||||
sb.append(" <h2 class=\"form-signin-heading\">Login with OpenID Identity</h2>\n");
|
||||
sb.append(createError(loginError, errorMsg) + createLogoutSuccess(logoutSuccess) + " <p>\n");
|
||||
sb.append(" <label for=\"username\" class=\"sr-only\">Identity</label>\n");
|
||||
sb.append(" <input type=\"text\" id=\"username\" name=\"" + this.openIDusernameParameter
|
||||
+ "\" class=\"form-control\" placeholder=\"Username\" required autofocus>\n");
|
||||
sb.append(" </p>\n");
|
||||
sb.append(createRememberMe(this.openIDrememberMeParameter) + renderHiddenInputs(request));
|
||||
sb.append(" <button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\">Sign in</button>\n");
|
||||
sb.append(" </form>\n");
|
||||
}
|
||||
if (this.oauth2LoginEnabled) {
|
||||
sb.append("<h2 class=\"form-signin-heading\">Login with OAuth 2.0</h2>");
|
||||
sb.append(createError(loginError, errorMsg));
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -29,8 +27,6 @@ import org.springframework.context.support.MessageSourceAccessor;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.SpringSecurityMessageSource;
|
||||
import org.springframework.security.web.WebAttributes;
|
||||
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
|
||||
@@ -131,12 +127,6 @@ public class DefaultLoginPageGeneratingFilterTests {
|
||||
assertThat(response.getContentAsString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generatingPageWithOpenIdFilterOnlyIsSuccessFul() throws Exception {
|
||||
DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter(new MockProcessingFilter());
|
||||
filter.doFilter(new MockHttpServletRequest("GET", "/login"), new MockHttpServletResponse(), this.chain);
|
||||
}
|
||||
|
||||
/* SEC-1111 */
|
||||
@Test
|
||||
public void handlesNonIso8859CharsInErrorMessage() throws Exception {
|
||||
@@ -178,25 +168,6 @@ public class DefaultLoginPageGeneratingFilterTests {
|
||||
assertThat(response.getContentAsString()).contains("Login with SAML 2.0");
|
||||
assertThat(response.getContentAsString())
|
||||
.contains("<a href=\"/saml/sso/google\">Google < > " ' &</a>");
|
||||
} // Fake OpenID filter (since it's not in this module
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class MockProcessingFilter extends AbstractAuthenticationProcessingFilter {
|
||||
|
||||
MockProcessingFilter() {
|
||||
super("/someurl");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
|
||||
throws AuthenticationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
String getClaimedIdentityFieldName() {
|
||||
return "unused";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user