Compare commits
1 Commits
feature/sk
...
master
| Author | SHA1 | Date |
|---|---|---|
|
|
c516025070 |
|
|
@ -71,10 +71,6 @@ public abstract class AbstractTicketValidationFilter extends AbstractCasFilter {
|
||||||
*/
|
*/
|
||||||
private boolean useSession = true;
|
private boolean useSession = true;
|
||||||
|
|
||||||
private static final String X_REAL_IP = "x-real-ip";
|
|
||||||
|
|
||||||
private String internalIp = null;
|
|
||||||
|
|
||||||
protected AbstractTicketValidationFilter(final Protocol protocol) {
|
protected AbstractTicketValidationFilter(final Protocol protocol) {
|
||||||
super(protocol);
|
super(protocol);
|
||||||
}
|
}
|
||||||
|
|
@ -89,10 +85,6 @@ public abstract class AbstractTicketValidationFilter extends AbstractCasFilter {
|
||||||
return this.ticketValidator;
|
return this.ticketValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInternalIp(String internalIp) {
|
|
||||||
this.internalIp = internalIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ssl config to use for HTTPS connections
|
* Gets the ssl config to use for HTTPS connections
|
||||||
* if one is configured for this filter.
|
* if one is configured for this filter.
|
||||||
|
|
@ -140,7 +132,6 @@ public abstract class AbstractTicketValidationFilter extends AbstractCasFilter {
|
||||||
setExceptionOnValidationFailure(getBoolean(ConfigurationKeys.EXCEPTION_ON_VALIDATION_FAILURE));
|
setExceptionOnValidationFailure(getBoolean(ConfigurationKeys.EXCEPTION_ON_VALIDATION_FAILURE));
|
||||||
setRedirectAfterValidation(getBoolean(ConfigurationKeys.REDIRECT_AFTER_VALIDATION));
|
setRedirectAfterValidation(getBoolean(ConfigurationKeys.REDIRECT_AFTER_VALIDATION));
|
||||||
setUseSession(getBoolean(ConfigurationKeys.USE_SESSION));
|
setUseSession(getBoolean(ConfigurationKeys.USE_SESSION));
|
||||||
setInternalIp(getString(ConfigurationKeys.INTERNAL_IP));
|
|
||||||
|
|
||||||
if (!this.useSession && this.redirectAfterValidation) {
|
if (!this.useSession && this.redirectAfterValidation) {
|
||||||
logger.warn("redirectAfterValidation parameter may not be true when useSession parameter is false. Resetting it to false in order to prevent infinite redirects.");
|
logger.warn("redirectAfterValidation parameter may not be true when useSession parameter is false. Resetting it to false in order to prevent infinite redirects.");
|
||||||
|
|
@ -201,18 +192,12 @@ public abstract class AbstractTicketValidationFilter extends AbstractCasFilter {
|
||||||
public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
|
public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
|
||||||
final FilterChain filterChain) throws IOException, ServletException {
|
final FilterChain filterChain) throws IOException, ServletException {
|
||||||
|
|
||||||
final HttpServletRequest request = (HttpServletRequest) servletRequest;
|
|
||||||
final HttpServletResponse response = (HttpServletResponse) servletResponse;
|
|
||||||
|
|
||||||
if (!preFilter(servletRequest, servletResponse, filterChain)) {
|
if (!preFilter(servletRequest, servletResponse, filterChain)) {
|
||||||
if (isInternalRequest(request)) {
|
|
||||||
logger.debug("Request is ignored [internal].");
|
|
||||||
filterChain.doFilter(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||||
|
final HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||||
final String ticket = retrieveTicketFromRequest(request);
|
final String ticket = retrieveTicketFromRequest(request);
|
||||||
|
|
||||||
if (CommonUtils.isNotBlank(ticket)) {
|
if (CommonUtils.isNotBlank(ticket)) {
|
||||||
|
|
@ -270,14 +255,4 @@ public abstract class AbstractTicketValidationFilter extends AbstractCasFilter {
|
||||||
public final void setUseSession(final boolean useSession) {
|
public final void setUseSession(final boolean useSession) {
|
||||||
this.useSession = useSession;
|
this.useSession = useSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInternalRequest(final HttpServletRequest request) {
|
|
||||||
if (this.internalIp == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String realIp = request.getHeader(X_REAL_IP);
|
|
||||||
|
|
||||||
return this.internalIp.equals(realIp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue