mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 20:13:17 +00:00
use loginPageURL
This commit is contained in:
@@ -719,8 +719,7 @@ public class LDAPAuthentication
|
|||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response)
|
HttpServletResponse response)
|
||||||
{
|
{
|
||||||
return response.encodeRedirectURL(request.getContextPath() +
|
return null;
|
||||||
"/ldap-login");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -272,8 +272,7 @@ public class PasswordAuthentication
|
|||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response)
|
HttpServletResponse response)
|
||||||
{
|
{
|
||||||
return response.encodeRedirectURL(request.getContextPath() +
|
return null;
|
||||||
"/password-login");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,21 +16,18 @@ import javax.servlet.ServletException;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.http.auth.AUTH;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
import org.dspace.authenticate.AuthenticationMethod;
|
import org.dspace.authenticate.AuthenticationMethod;
|
||||||
import org.dspace.authenticate.ShibAuthentication;
|
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||||
import org.dspace.authenticate.service.AuthenticationService;
|
import org.dspace.authenticate.service.AuthenticationService;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.utils.DSpace;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class will filter login requests to try and authenticate them
|
* This class will filter login requests to try and authenticate them
|
||||||
@@ -70,16 +67,14 @@ public class StatelessLoginFilter extends AbstractAuthenticationProcessingFilter
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch(BadCredentialsException e) {
|
} catch(BadCredentialsException e) {
|
||||||
DSpace dspace = new DSpace();
|
AuthenticationService authenticationService = AuthenticateServiceFactory.getInstance().getAuthenticationService();
|
||||||
ConfigurationService configurationService = dspace.getConfigurationService();
|
Iterator<AuthenticationMethod> authenticationMethodIterator = authenticationService.authenticationMethodIterator();
|
||||||
String[] authMethods = configurationService.getArrayProperty("plugin.sequence.org.dspace.authenticate.AuthenticationMethod", new String[0]);
|
while (authenticationMethodIterator.hasNext()) {
|
||||||
for(String method: authMethods) {
|
AuthenticationMethod authenticationMethod = authenticationMethodIterator.next();
|
||||||
if (method.equals("org.dspace.authenticate.ShibAuthentication")) {
|
Context context = ContextUtil.obtainContext(req);
|
||||||
String shibLoginUrl = configurationService.getProperty("authentication-shibboleth.lazysession.loginurl", "");
|
String loginPageURL = authenticationMethod.loginPageURL(context, req, res);
|
||||||
if (!shibLoginUrl.isEmpty()) {
|
if (StringUtils.isNotBlank(loginPageURL)) {
|
||||||
res.addHeader("Location", String.format("https://%s%s?target=%s", req.getHeader("Host"), shibLoginUrl, req.getHeader("Referer")));
|
res.addHeader("Location", loginPageURL);
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
Reference in New Issue
Block a user