Add filter to convert getRequestURL in AuthenticationFilter.
This commit is contained in:
parent
4fee4ddd8d
commit
0b93b16059
|
@ -6,7 +6,12 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import org.mitre.openid.connect.client.OIDCAuthenticationFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,6 +25,22 @@ public class OpenAIREAuthenticationFilter extends OIDCAuthenticationFilter {
|
|||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
final HttpServletRequestWrapper wrapped = new HttpServletRequestWrapper((HttpServletRequest) req) {
|
||||
@Override
|
||||
public StringBuffer getRequestURL() {
|
||||
final StringBuffer originalUrl = ((HttpServletRequest) getRequest()).getRequestURL();
|
||||
if(originalUrl.toString().contains(OIDCAuthenticationFilter.FILTER_PROCESSES_URL)) {
|
||||
return new StringBuffer(properties.getOidc().getHome());
|
||||
} else {
|
||||
return new StringBuffer(properties.getOidc().getRedirect());
|
||||
}
|
||||
}
|
||||
};
|
||||
super.doFilter(wrapped, res, chain);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleAuthorizationRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Redirect.setRedirect(request, properties);
|
||||
|
|
Loading…
Reference in New Issue