Compare commits

...

44 Commits

Author SHA1 Message Date
Alexander Buntakov c516025070
Merge pull request #1 from TouchInstinct/feature/skip-internal-ip
support internal requests skip
2019-12-27 18:49:12 +03:00
Alexander Buntakov 71e71f15ff support internal requests skip 2019-12-27 17:53:03 +03:00
dependabot-preview[bot] 448b08c43c build(deps): bump jetty.version (#409)
Bumps `jetty.version` from 9.4.24.v20191120 to 9.4.25.v20191220.

Updates `jetty-security` from 9.4.24.v20191120 to 9.4.25.v20191220
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.24.v20191120...jetty-9.4.25.v20191220)

Updates `jetty-webapp` from 9.4.24.v20191120 to 9.4.25.v20191220
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.24.v20191120...jetty-9.4.25.v20191220)

Updates `jetty-plus` from 9.4.24.v20191120 to 9.4.25.v20191220
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.24.v20191120...jetty-9.4.25.v20191220)

Updates `jetty-annotations` from 9.4.24.v20191120 to 9.4.25.v20191220
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.24.v20191120...jetty-9.4.25.v20191220)

Updates `apache-jsp` from 9.4.24.v20191120 to 9.4.25.v20191220
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.24.v20191120...jetty-9.4.25.v20191220)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-24 05:46:06 +00:00
dependabot-preview[bot] 06f87f85fc build(deps): bump maven-source-plugin from 3.2.0 to 3.2.1 (#408)
Bumps [maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.2.0 to 3.2.1.
- [Release notes](https://github.com/apache/maven-source-plugin/releases)
- [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.2.0...maven-source-plugin-3.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-23 05:41:20 +00:00
renovate[bot] f2c44b7e74 renovatebot(deps): update dependency org.apache.tomcat:tomcat-catalina to v7.0.99 (#406) 2019-12-17 09:33:26 +00:00
renovate[bot] 94d81c32ba renovatebot(deps): update slf4j.version to v1.7.30 (#405) 2019-12-16 21:42:40 +00:00
renovate[bot] a96a13c630 renovatebot(deps): update dependency org.apache.tomcat:tomcat-catalina to v8.5.50 (#403) 2019-12-12 12:46:16 +00:00
renovate[bot] 06f3ebc7c2 renovatebot(deps): update dependency org.apache.tomcat.embed:tomcat-embed-core to v8.5.50 (#402) 2019-12-12 12:46:08 +00:00
renovate[bot] 0dce0aa69e renovatebot(deps): update tomcat.version to v9.0.30 (#401) 2019-12-12 10:02:06 +00:00
renovate[bot] 8a665e1cb1 renovatebot(deps): update spring boot to v2.2.2.release (#400) 2019-12-06 12:42:38 +00:00
renovate[bot] dce1a94d9a renovatebot(deps): update spring core to v5.2.2.release (#399) 2019-12-03 13:17:34 +00:00
Petr Bodnar 76fb6a4f9c README.md - Only list used properties for Single Log Out (#398)
* README.md - Only list used properties for Single Log Out

Properties `casServerUrlPrefix` and `frontLogoutParameterName` are not really read by the SLO filter. Mainly the 1st one has no usage in this filter by design.

* README.md - Only list used properties for Single Log Out

Also removing unused `casServerUrlPrefix` from the code examples.
2019-11-30 12:21:06 +04:00
dependabot-preview[bot] 8d38080354 build(deps): bump jetty.version (#397)
Bumps `jetty.version` from 9.4.22.v20191022 to 9.4.24.v20191120.

Updates `jetty-security` from 9.4.22.v20191022 to 9.4.24.v20191120
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.22.v20191022...jetty-9.4.24.v20191120)

Updates `jetty-webapp` from 9.4.22.v20191022 to 9.4.24.v20191120
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.22.v20191022...jetty-9.4.24.v20191120)

Updates `jetty-plus` from 9.4.22.v20191022 to 9.4.24.v20191120
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.22.v20191022...jetty-9.4.24.v20191120)

Updates `jetty-annotations` from 9.4.22.v20191022 to 9.4.24.v20191120
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.22.v20191022...jetty-9.4.24.v20191120)

Updates `apache-jsp` from 9.4.22.v20191022 to 9.4.24.v20191120
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.22.v20191022...jetty-9.4.24.v20191120)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-22 05:38:31 +00:00
renovate[bot] be803939d8 renovatebot(deps): update dependency org.apache.tomcat:tomcat-catalina to v8.5.49 (#393) 2019-11-21 13:42:30 +00:00
renovate[bot] af1bbb2f32 renovatebot(deps): update dependency org.apache.tomcat.embed:tomcat-embed-core to v8.5.49 (#392) 2019-11-21 13:42:21 +00:00
renovate[bot] c5a5a9961b renovatebot(deps): update dependency com.fasterxml.jackson.core:jackson-databind to v2.10.1 (#390) 2019-11-21 13:42:15 +00:00
renovate[bot] 6e2fbec2a4 renovatebot(deps): update tomcat.version to v9.0.29 (#394) 2019-11-21 13:39:17 +00:00
Misagh Moayyed 638c2d6fe4
fix maven jar plugin version 2019-11-21 17:31:58 +04:00
dependabot-preview[bot] efd6dbb491 Bump maven-source-plugin from 3.1.0 to 3.2.0 (#387)
Bumps [maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/apache/maven-source-plugin/releases)
- [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.1.0...maven-source-plugin-3.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-07 13:22:49 +04:00
renovate[bot] 905ce61e82 renovatebot(deps): update dependency org.apache.maven.plugins:ma… (#383) 2019-11-07 13:22:32 +04:00
dependabot-preview[bot] 3ba892e482 Bump maven-jar-plugin from 3.1.1 to 3.2.0 (#385)
Bumps [maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/apache/maven-jar-plugin/releases)
- [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.1.1...maven-jar-plugin-3.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-07 13:22:15 +04:00
Gahon 62cc93399f add central logout support for springboot (#388)
* add dependence to generated metadata for springboot

* add central logout support for springboot
2019-11-07 11:56:45 +04:00
renovate[bot] cd67d874a2 renovatebot(deps): update dependency org.springframework.boot:spring-boot-starter to v2.2.1.release (#389) 2019-11-07 00:58:45 +00:00
renovate[bot] 46381476e9 renovatebot(deps): update dependency org.jasig.cas.client:cas-client to v3.6.1 (#369) 2019-11-04 18:25:30 +00:00
renovate[bot] d2538f378d renovatebot(deps): update spring core to v5.2.1.release (#381) 2019-11-04 18:23:06 +00:00
dependabot-preview[bot] f14d836e03 Bump spring.version from 5.2.0.RELEASE to 5.2.1.RELEASE (#384)
Bumps `spring.version` from 5.2.0.RELEASE to 5.2.1.RELEASE.

Updates `spring-core` from 5.2.0.RELEASE to 5.2.1.RELEASE
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.0.RELEASE...v5.2.1.RELEASE)

Updates `spring-context` from 5.2.0.RELEASE to 5.2.1.RELEASE
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.0.RELEASE...v5.2.1.RELEASE)

Updates `spring-web` from 5.2.0.RELEASE to 5.2.1.RELEASE
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.0.RELEASE...v5.2.1.RELEASE)

Updates `spring-test` from 5.2.0.RELEASE to 5.2.1.RELEASE
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.0.RELEASE...v5.2.1.RELEASE)

Updates `spring-beans` from 5.2.0.RELEASE to 5.2.1.RELEASE
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.0.RELEASE...v5.2.1.RELEASE)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-04 18:23:02 +00:00
renovate[bot] e2e4ea9fa1 renovatebot(deps): update dependency org.apache.maven.plugins:ma… (#382) 2019-11-04 22:22:45 +04:00
dependabot-preview[bot] df89820368 Bump maven-assembly-plugin from 3.1.1 to 3.2.0 (#386)
Bumps [maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/apache/maven-assembly-plugin/releases)
- [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.1.1...maven-assembly-plugin-3.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-04 22:22:26 +04:00
Misagh Moayyed 3005cc8607
Update .mergify.yml 2019-11-04 22:21:59 +04:00
renovate[bot] e0374d61ac renovatebot(deps): update dependency joda-time:joda-time to v2.1… (#378) 2019-10-31 23:37:23 +04:00
renovate[bot] 360ff59ddd renovatebot(deps): update dependency org.apache.tomcat:tomcat-ca… (#372) 2019-10-31 23:37:03 +04:00
renovate[bot] 59f42b7edf renovatebot(deps): update tomcat.version to v9.0.27 (#370) 2019-10-31 23:36:44 +04:00
dependabot-preview[bot] 409bd553ba Bump jetty.version from 9.4.21.v20190926 to 9.4.22.v20191022 (#377)
Bumps `jetty.version` from 9.4.21.v20190926 to 9.4.22.v20191022.

Updates `jetty-security` from 9.4.21.v20190926 to 9.4.22.v20191022
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.21.v20190926...jetty-9.4.22.v20191022)

Updates `jetty-webapp` from 9.4.21.v20190926 to 9.4.22.v20191022
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.21.v20190926...jetty-9.4.22.v20191022)

Updates `jetty-plus` from 9.4.21.v20190926 to 9.4.22.v20191022
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.21.v20190926...jetty-9.4.22.v20191022)

Updates `jetty-annotations` from 9.4.21.v20190926 to 9.4.22.v20191022
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.21.v20190926...jetty-9.4.22.v20191022)

Updates `apache-jsp` from 9.4.21.v20190926 to 9.4.22.v20191022
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.21.v20190926...jetty-9.4.22.v20191022)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-31 23:36:23 +04:00
dependabot-preview[bot] 3ec16e8aaf Bump joda-time from 2.10.4 to 2.10.5 (#379)
Bumps [joda-time](https://github.com/JodaOrg/joda-time) from 2.10.4 to 2.10.5.
- [Release notes](https://github.com/JodaOrg/joda-time/releases)
- [Changelog](https://github.com/JodaOrg/joda-time/blob/master/RELEASE-NOTES.txt)
- [Commits](https://github.com/JodaOrg/joda-time/compare/v2.10.4...v2.10.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-31 23:35:14 +04:00
renovate[bot] 08bedcf889 renovatebot(deps): update slf4j.version to v1.7.29 (#380) 2019-10-31 23:34:59 +04:00
Misagh Moayyed da7ff03cff
Update .mergify.yml 2019-10-24 19:04:44 +04:00
renovate[bot] 5aaf09b3e4 renovatebot(deps): update dependency org.apache.tomcat.embed:tom… (#371) 2019-10-24 19:04:14 +04:00
dependabot-preview[bot] fd176bc1a7 Bump spring-boot-starter from 2.1.9.RELEASE to 2.2.0.RELEASE (#376)
Bumps [spring-boot-starter](https://github.com/spring-projects/spring-boot) from 2.1.9.RELEASE to 2.2.0.RELEASE.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](https://github.com/spring-projects/spring-boot/compare/v2.1.9.RELEASE...v2.2.0.RELEASE)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-17 17:51:43 +04:00
renovate[bot] 9f09c15673 renovatebot(deps): update dependency org.bouncycastle:bcpkix-jdk15on to v1.64 (#373) 2019-10-12 10:20:46 +04:00
Misagh Moayyed e4c1df0280
[maven-release-plugin] prepare for next development iteration 2019-10-08 17:22:31 +04:00
Misagh Moayyed a00064d1d8
[maven-release-plugin] prepare release cas-client-3.6.1 2019-10-08 17:22:16 +04:00
Misagh Moayyed 21d5f37322
Updated: code cleanup and styling; fixes test cases 2019-10-08 17:20:43 +04:00
Misagh Moayyed 872fc49fb7
ensure API compatibility 2019-10-08 17:19:45 +04:00
Jérôme LELEU 18c79fcf00 [maven-release-plugin] prepare for next development iteration 2019-10-07 11:02:29 +02:00
22 changed files with 203 additions and 101 deletions

View File

@ -27,8 +27,8 @@ pull_request_rules:
- label=dependencies
actions:
merge:
method: merge
strict: true
method: squash
strict: false
delete_head_branch:
- name: automatic merge by renovate
conditions:
@ -39,6 +39,6 @@ pull_request_rules:
- label=dependencies
actions:
merge:
method: merge
strict: true
method: squash
strict: false
delete_head_branch:

View File

@ -723,6 +723,7 @@ cas.validation-type=SAML
### Available optional properties
* `cas.single-logout.enabled`
* `cas.authentication-url-patterns`
* `cas.validation-url-patterns`
* `cas.request-wrapper-url-patterns`
@ -793,7 +794,7 @@ type="java.lang.String" value="https://www.apereo.org/cas"/>
### Configuring Single Sign Out
The Single Sign Out support in CAS consists of configuring one `SingleSignOutFilter` and one `ContextListener`. Please note that if you have configured the CAS Client for Java as Web filters, this filter must come before the other filters as described.
The `SingleSignOutFilter` can affect character encoding. This becomes most obvious when used in conjunction with applications such as Atlassian Confluence. Its recommended you explicitly configure either the [VT Character Encoding Filter](http://code.google.com/p/vt-middleware/wiki/vtservletfilters#CharacterEncodingFilter) or the [Spring Character Encoding Filter](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/filter/CharacterEncodingFilter.html) with explicit encodings.
The `SingleSignOutFilter` can affect character encoding. This becomes most obvious when used in conjunction with applications such as Atlassian Confluence. It's recommended you explicitly configure either the [VT Character Encoding Filter](http://code.google.com/p/vt-middleware/wiki/vtservletfilters#CharacterEncodingFilter) or the [Spring Character Encoding Filter](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/filter/CharacterEncodingFilter.html) with explicit encodings.
#### Configuration
@ -801,12 +802,10 @@ The `SingleSignOutFilter` can affect character encoding. This becomes most obvio
|----------|-------|-----------
| `artifactParameterName` | The ticket artifact parameter name. Defaults to `ticket`| No
| `logoutParameterName` | Defaults to `logoutRequest` | No
| `frontLogoutParameterName` | Defaults to `SAMLRequest` | No
| `relayStateParameterName` | Defaults to `RelayState` | No
| `eagerlyCreateSessions` | Defaults to `true` | No
| `artifactParameterOverPost` | Defaults to `false` | No
| `logoutCallbackPath` | The path which is expected to receive logout callback requests from the CAS server. This is necessary if your app needs access to the raw input stream when handling form posts. If not configured, the default behavior will check every form post for a logout parameter. | No
| `casServerUrlPrefix` | URL to root of CAS Web application context. | Yes
<a name="cas-protocol"></a>
#### CAS Protocol
@ -815,10 +814,6 @@ The `SingleSignOutFilter` can affect character encoding. This becomes most obvio
<filter>
<filter-name>CAS Single Sign Out Filter</filter-name>
<filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>https://cas.example.com/cas</param-value>
</init-param>
</filter>
...
<filter-mapping>
@ -842,10 +837,6 @@ The `SingleSignOutFilter` can affect character encoding. This becomes most obvio
<param-name>artifactParameterName</param-name>
<param-value>SAMLart</param-value>
</init-param>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>https://cas.example.com/cas</param-value>
</init-param>
</filter>
...
<filter-mapping>

View File

@ -21,7 +21,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
<artifactId>cas-client</artifactId>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -82,6 +82,10 @@ public class AuthenticationFilter extends AbstractCasFilter {
private UrlPatternMatcherStrategy ignoreUrlPatternMatcherStrategyClass = null;
private String internalIp = null;
private static final String X_REAL_IP = "x-real-ip";
private static final Map<String, Class<? extends UrlPatternMatcherStrategy>> PATTERN_MATCHER_TYPES =
new HashMap<String, Class<? extends UrlPatternMatcherStrategy>>();
@ -115,6 +119,7 @@ public class AuthenticationFilter extends AbstractCasFilter {
setRenew(getBoolean(ConfigurationKeys.RENEW));
setGateway(getBoolean(ConfigurationKeys.GATEWAY));
setMethod(getString(ConfigurationKeys.METHOD));
setInternalIp(getString(ConfigurationKeys.INTERNAL_IP));
final String ignorePattern = getString(ConfigurationKeys.IGNORE_PATTERN);
final String ignoreUrlPatternType = getString(ConfigurationKeys.IGNORE_URL_PATTERN_TYPE);
@ -169,6 +174,12 @@ public class AuthenticationFilter extends AbstractCasFilter {
final HttpServletRequest request = (HttpServletRequest) servletRequest;
final HttpServletResponse response = (HttpServletResponse) servletResponse;
if (isInternalRequest(request)) {
logger.debug("Request is ignored [internal].");
filterChain.doFilter(request, response);
return;
}
if (isRequestUrlExcluded(request)) {
logger.debug("Request is ignored.");
filterChain.doFilter(request, response);
@ -231,10 +242,24 @@ public class AuthenticationFilter extends AbstractCasFilter {
this.casServerLoginUrl = casServerLoginUrl;
}
public void setInternalIp(String internalIp) {
this.internalIp = internalIp;
}
public final void setGatewayStorage(final GatewayResolver gatewayStorage) {
this.gatewayStorage = gatewayStorage;
}
private boolean isInternalRequest(final HttpServletRequest request) {
if (this.internalIp == null) {
return false;
}
String realIp = request.getHeader(X_REAL_IP);
return this.internalIp.equals(realIp);
}
private boolean isRequestUrlExcluded(final HttpServletRequest request) {
if (this.ignoreUrlPatternMatcherStrategyClass == null) {
return false;

View File

@ -64,6 +64,7 @@ public interface ConfigurationKeys {
*/
@Deprecated
ConfigurationKey<Boolean> DISABLE_XML_SCHEMA_VALIDATION = new ConfigurationKey<Boolean>("disableXmlSchemaValidation", Boolean.FALSE);
ConfigurationKey<String> INTERNAL_IP = new ConfigurationKey<String>("internalIp", null);
ConfigurationKey<String> IGNORE_PATTERN = new ConfigurationKey<String>("ignorePattern", null);
ConfigurationKey<String> IGNORE_URL_PATTERN_TYPE = new ConfigurationKey<String>("ignoreUrlPatternType", "REGEX");
ConfigurationKey<Class<? extends HostnameVerifier>> HOSTNAME_VERIFIER = new ConfigurationKey<Class<? extends HostnameVerifier>>("hostnameVerifier", null);

View File

@ -18,16 +18,6 @@
*/
package org.jasig.cas.client.util;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*;
import javax.net.ssl.SSLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jasig.cas.client.Protocol;
import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage;
import org.jasig.cas.client.ssl.HttpURLConnectionFactory;
@ -37,6 +27,23 @@ import org.jasig.cas.client.validation.ProxyListEditor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Common utilities so that we don't need to include Commons Lang.
*
@ -61,19 +68,20 @@ public final class CommonUtils {
private static final String SERVICE_PARAMETER_NAMES;
private CommonUtils() {
// nothing to do
}
static {
final Set<String> serviceParameterSet = new HashSet<String>(4);
for (final Protocol protocol : Protocol.values()) {
serviceParameterSet.add(protocol.getServiceParameterName());
}
SERVICE_PARAMETER_NAMES = serviceParameterSet.toString()
.replaceAll("\\[|\\]", "")
.replaceAll("\\s", "");
.replaceAll("\\[|\\]", "")
.replaceAll("\\s", "");
}
private CommonUtils() {
// nothing to do
}
/**
* Check whether the object is null or not. If it is, throw an exception and
* display the message.
@ -183,15 +191,30 @@ public final class CommonUtils {
* @return the fully constructed redirect url.
*/
public static String constructRedirectUrl(final String casServerLoginUrl, final String serviceParameterName,
final String serviceUrl, final boolean renew, final boolean gateway, final String method) {
final String serviceUrl, final boolean renew, final boolean gateway, final String method) {
return casServerLoginUrl + (casServerLoginUrl.contains("?") ? "&" : "?") + serviceParameterName + "="
+ urlEncode(serviceUrl) + (renew ? "&renew=true" : "") + (gateway ? "&gateway=true" : "")
+ (method != null ? "&method=" + method : "");
+ urlEncode(serviceUrl) + (renew ? "&renew=true" : "") + (gateway ? "&gateway=true" : "")
+ (method != null ? "&method=" + method : "");
}
/**
* Construct redirect url to a CAS server.
*
* @param casServerLoginUrl the cas server login url
* @param serviceParameterName the service parameter name
* @param serviceUrl the service url
* @param renew the renew
* @param gateway the gateway
* @return the string
*/
public static String constructRedirectUrl(final String casServerLoginUrl, final String serviceParameterName,
final String serviceUrl, final boolean renew, final boolean gateway) {
return constructRedirectUrl(casServerLoginUrl, serviceParameterName, serviceUrl, renew, gateway, null);
}
/**
* Url encode a value using UTF-8 encoding.
*
*
* @param value the value to encode.
* @return the encoded value.
*/
@ -204,8 +227,8 @@ public final class CommonUtils {
}
public static void readAndRespondToProxyReceptorRequest(final HttpServletRequest request,
final HttpServletResponse response, final ProxyGrantingTicketStorage proxyGrantingTicketStorage)
throws IOException {
final HttpServletResponse response, final ProxyGrantingTicketStorage proxyGrantingTicketStorage)
throws IOException {
final String proxyGrantingTicketIou = request.getParameter(PARAM_PROXY_GRANTING_TICKET_IOU);
final String proxyGrantingTicket = request.getParameter(PARAM_PROXY_GRANTING_TICKET);
@ -216,12 +239,12 @@ public final class CommonUtils {
}
LOGGER.debug("Received proxyGrantingTicketId [{}] for proxyGrantingTicketIou [{}]", proxyGrantingTicket,
proxyGrantingTicketIou);
proxyGrantingTicketIou);
proxyGrantingTicketStorage.save(proxyGrantingTicketIou, proxyGrantingTicket);
LOGGER.debug("Successfully saved proxyGrantingTicketId [{}] for proxyGrantingTicketIou [{}]",
proxyGrantingTicket, proxyGrantingTicketIou);
proxyGrantingTicket, proxyGrantingTicketIou);
response.getWriter().write("<?xml version=\"1.0\"?>");
response.getWriter().write("<casClient:proxySuccess xmlns:casClient=\"http://www.yale.edu/tp/casClient\" />");
@ -254,7 +277,7 @@ public final class CommonUtils {
return serverNames[0];
}
private static boolean requestIsOnStandardPort(final HttpServletRequest request) {
final int serverPort = request.getServerPort();
return serverPort == 80 || serverPort == 443;
@ -281,7 +304,7 @@ public final class CommonUtils {
final String service, final String serverNames,
final String artifactParameterName, final boolean encode) {
return constructServiceUrl(request, response, service, serverNames, SERVICE_PARAMETER_NAMES
, artifactParameterName, encode);
, artifactParameterName, encode);
}
/**
@ -301,8 +324,8 @@ public final class CommonUtils {
* @return the service url to use.
*/
public static String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response,
final String service, final String serverNames, final String serviceParameterName,
final String artifactParameterName, final boolean encode) {
final String service, final String serverNames, final String serviceParameterName,
final String artifactParameterName, final boolean encode) {
if (CommonUtils.isNotBlank(service)) {
return encode ? response.encodeURL(service) : service;
}
@ -330,10 +353,10 @@ public final class CommonUtils {
for (final URIBuilder.BasicNameValuePair pair : originalRequestUrl.getQueryParams()) {
final String name = pair.getName();
if (!name.equals(artifactParameterName) && !serviceParameterNames.contains(name)) {
if (name.contains("&") || name.contains("=") ){
if (name.contains("&") || name.contains("=")) {
final URIBuilder encodedParamBuilder = new URIBuilder();
encodedParamBuilder.setParameters(name);
for (final URIBuilder.BasicNameValuePair pair2 :encodedParamBuilder.getQueryParams()){
for (final URIBuilder.BasicNameValuePair pair2 : encodedParamBuilder.getQueryParams()) {
final String name2 = pair2.getName();
if (!name2.equals(artifactParameterName) && !serviceParameterNames.contains(name2)) {
builder.addParameter(name2, pair2.getValue());
@ -369,13 +392,13 @@ public final class CommonUtils {
* @return the value of the parameter.
*/
public static String safeGetParameter(final HttpServletRequest request, final String parameter,
final List<String> parameters) {
final List<String> parameters) {
if ("POST".equals(request.getMethod()) && parameters.contains(parameter)) {
LOGGER.debug("safeGetParameter called on a POST HttpServletRequest for Restricted Parameters. Cannot complete check safely. Reverting to standard behavior for this Parameter");
return request.getParameter(parameter);
}
return request.getQueryString() == null || !request.getQueryString().contains(parameter) ? null : request
.getParameter(parameter);
.getParameter(parameter);
}
public static String safeGetParameter(final HttpServletRequest request, final String parameter) {
@ -392,11 +415,11 @@ public final class CommonUtils {
*/
@Deprecated
public static String getResponseFromServer(final String constructedUrl, final String encoding) {
try {
try {
return getResponseFromServer(new URL(constructedUrl), DEFAULT_URL_CONNECTION_FACTORY, encoding);
} catch (final IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}
@Deprecated
@ -413,8 +436,8 @@ public final class CommonUtils {
* @return the response.
*/
public static String getResponseFromServer(final URL constructedUrl, final HttpURLConnectionFactory factory,
final String encoding) {
final String encoding) {
HttpURLConnection conn = null;
InputStreamReader in = null;
try {
@ -434,13 +457,13 @@ public final class CommonUtils {
return builder.toString();
} catch (final RuntimeException e) {
throw e;
throw e;
} catch (final SSLException e) {
LOGGER.error("SSL error getting response from host: {} : Error Message: {}", constructedUrl.getHost(), e.getMessage(), e);
throw new RuntimeException(e);
} catch (final IOException e) {
LOGGER.error("Error getting response from host: [{}] with path: [{}] and protocol: [{}] Error Message: {}",
constructedUrl.getHost(), constructedUrl.getPath(), constructedUrl.getProtocol(), e.getMessage(), e);
constructedUrl.getHost(), constructedUrl.getPath(), constructedUrl.getProtocol(), e.getMessage(), e);
throw new RuntimeException(e);
} finally {
closeQuietly(in);
@ -574,11 +597,11 @@ public final class CommonUtils {
case 1: {
final char ch0 = str.charAt(0);
if (ch0 == 'y' || ch0 == 'Y' ||
ch0 == 't' || ch0 == 'T') {
ch0 == 't' || ch0 == 'T') {
return Boolean.TRUE;
}
if (ch0 == 'n' || ch0 == 'N' ||
ch0 == 'f' || ch0 == 'F') {
ch0 == 'f' || ch0 == 'F') {
return Boolean.FALSE;
}
break;
@ -587,11 +610,11 @@ public final class CommonUtils {
final char ch0 = str.charAt(0);
final char ch1 = str.charAt(1);
if ((ch0 == 'o' || ch0 == 'O') &&
(ch1 == 'n' || ch1 == 'N') ) {
(ch1 == 'n' || ch1 == 'N')) {
return Boolean.TRUE;
}
if ((ch0 == 'n' || ch0 == 'N') &&
(ch1 == 'o' || ch1 == 'O') ) {
(ch1 == 'o' || ch1 == 'O')) {
return Boolean.FALSE;
}
break;
@ -601,13 +624,13 @@ public final class CommonUtils {
final char ch1 = str.charAt(1);
final char ch2 = str.charAt(2);
if ((ch0 == 'y' || ch0 == 'Y') &&
(ch1 == 'e' || ch1 == 'E') &&
(ch2 == 's' || ch2 == 'S') ) {
(ch1 == 'e' || ch1 == 'E') &&
(ch2 == 's' || ch2 == 'S')) {
return Boolean.TRUE;
}
if ((ch0 == 'o' || ch0 == 'O') &&
(ch1 == 'f' || ch1 == 'F') &&
(ch2 == 'f' || ch2 == 'F') ) {
(ch1 == 'f' || ch1 == 'F') &&
(ch2 == 'f' || ch2 == 'F')) {
return Boolean.FALSE;
}
break;
@ -618,9 +641,9 @@ public final class CommonUtils {
final char ch2 = str.charAt(2);
final char ch3 = str.charAt(3);
if ((ch0 == 't' || ch0 == 'T') &&
(ch1 == 'r' || ch1 == 'R') &&
(ch2 == 'u' || ch2 == 'U') &&
(ch3 == 'e' || ch3 == 'E') ) {
(ch1 == 'r' || ch1 == 'R') &&
(ch2 == 'u' || ch2 == 'U') &&
(ch3 == 'e' || ch3 == 'E')) {
return Boolean.TRUE;
}
break;
@ -632,10 +655,10 @@ public final class CommonUtils {
final char ch3 = str.charAt(3);
final char ch4 = str.charAt(4);
if ((ch0 == 'f' || ch0 == 'F') &&
(ch1 == 'a' || ch1 == 'A') &&
(ch2 == 'l' || ch2 == 'L') &&
(ch3 == 's' || ch3 == 'S') &&
(ch4 == 'e' || ch4 == 'E') ) {
(ch1 == 'a' || ch1 == 'A') &&
(ch2 == 'l' || ch2 == 'L') &&
(ch3 == 's' || ch3 == 'S') &&
(ch4 == 'e' || ch4 == 'E')) {
return Boolean.FALSE;
}
break;
@ -691,7 +714,7 @@ public final class CommonUtils {
* @return the int represented by the string, or the default if conversion fails
*/
public static int toInt(final String str, final int defaultValue) {
if(str == null) {
if (str == null) {
return defaultValue;
}
try {

View File

@ -21,7 +21,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0-SNAPSHOT</version>
<version>3.6.1</version>
<artifactId>cas-client</artifactId>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,7 +21,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
<artifactId>cas-client</artifactId>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -33,7 +33,7 @@
<properties>
<!-- Note Jetty 9.2.x is the last version to support Java SE 7 -->
<jetty.version>9.4.21.v20190926</jetty.version>
<jetty.version>9.4.25.v20191220</jetty.version>
</properties>
<dependencies>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -50,7 +50,7 @@
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.96</version>
<version>7.0.99</version>
<type>jar</type>
<scope>provided</scope>
<exclusions>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -50,7 +50,7 @@
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>8.5.46</version>
<version>8.5.50</version>
<type>jar</type>
<scope>provided</scope>
<exclusions>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -50,14 +50,14 @@
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>8.5.46</version>
<version>8.5.50</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>8.5.46</version>
<version>8.5.50</version>
<type>jar</type>
<scope>provided</scope>
<exclusions>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -32,7 +32,7 @@
<name>Jasig CAS Client for Java - Tomcat 9.0.x Integration</name>
<properties>
<tomcat.version>9.0.26</tomcat.version>
<tomcat.version>9.0.30</tomcat.version>
</properties>
<dependencies>
<dependency>

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>Jasig CAS Client for Java - Distributed Proxy Storage Support: EhCache

View File

@ -23,7 +23,7 @@
<parent>
<artifactId>cas-client</artifactId>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,7 +21,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
<artifactId>cas-client</artifactId>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -38,7 +38,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.4</version>
<version>2.10.5</version>
</dependency>
<!-- Test dependencies -->

View File

@ -21,7 +21,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
<artifactId>cas-client</artifactId>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -58,6 +58,15 @@
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
<version>${springboot.version}</version>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.jasig.cas.client</groupId>
@ -74,6 +83,6 @@
</dependencies>
<properties>
<springboot.version>2.1.9.RELEASE</springboot.version>
<springboot.version>2.2.2.RELEASE</springboot.version>
</properties>
</project>

View File

@ -20,6 +20,8 @@ package org.jasig.cas.client.boot.configuration;
import org.jasig.cas.client.authentication.AuthenticationFilter;
import org.jasig.cas.client.authentication.Saml11AuthenticationFilter;
import org.jasig.cas.client.session.SingleSignOutFilter;
import org.jasig.cas.client.session.SingleSignOutHttpSessionListener;
import org.jasig.cas.client.util.AssertionThreadLocalFilter;
import org.jasig.cas.client.util.HttpServletRequestWrapperFilter;
import org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter;
@ -29,8 +31,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -40,6 +44,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.EventListener;
/**
* Configuration class providing default CAS client infrastructure filters.
@ -199,4 +204,25 @@ public class CasClientConfiguration {
}
this.casClientConfigurer = configurers.iterator().next();
}
@Bean
@ConditionalOnProperty(prefix = "cas", value = "single-logout.enabled", havingValue = "true")
public FilterRegistrationBean casSingleSignOutFilter() {
final FilterRegistrationBean singleSignOutFilter = new FilterRegistrationBean();
singleSignOutFilter.setFilter(new SingleSignOutFilter());
Map<String,String> initParameters = new HashMap<>(1);
initParameters.put("casServerUrlPrefix", configProps.getServerUrlPrefix());
singleSignOutFilter.setInitParameters(initParameters);
singleSignOutFilter.setOrder(Ordered.HIGHEST_PRECEDENCE);
return singleSignOutFilter;
}
@Bean
@ConditionalOnProperty(prefix = "cas", value = "single-logout.enabled", havingValue = "true")
public ServletListenerRegistrationBean<EventListener> casSingleSignOutListener(){
ServletListenerRegistrationBean<EventListener> singleSignOutListener = new ServletListenerRegistrationBean<>();
singleSignOutListener.setListener(new SingleSignOutHttpSessionListener());
singleSignOutListener.setOrder(Ordered.HIGHEST_PRECEDENCE);
return singleSignOutListener;
}
}

View File

@ -115,6 +115,24 @@ public class CasClientConfigurationProperties {
private Boolean skipTicketValidation = false;
private SingleLogout singleLogout;
public static class SingleLogout{
/**
* whether to receive the single logout request from cas server.
*/
private boolean enabled = false;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
public String getServerUrlPrefix() {
return serverUrlPrefix;
}
@ -242,4 +260,13 @@ public class CasClientConfigurationProperties {
public void setSkipTicketValidation(final Boolean skipTicketValidation) {
this.skipTicketValidation = skipTicketValidation;
}
public SingleLogout getSingleLogout() {
return singleLogout;
}
public void setSingleLogout(SingleLogout singleLogout) {
this.singleLogout = singleLogout;
}
}

20
pom.xml
View File

@ -26,7 +26,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jasig.cas.client</groupId>
<version>3.6.0</version>
<version>3.6.2-SNAPSHOT</version>
<artifactId>cas-client</artifactId>
<packaging>pom</packaging>
@ -41,7 +41,7 @@
<connection>scm:git:git@github.com:apereo/java-cas-client.git</connection>
<developerConnection>scm:git:git@github.com:apereo/java-cas-client.git</developerConnection>
<url>https://github.com/apereo/java-cas-client</url>
<tag>cas-client-3.6.0</tag>
<tag>HEAD</tag>
</scm>
<inceptionYear>2006</inceptionYear>
@ -79,7 +79,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
<configuration>
<descriptors>
<descriptor>${basedir}/assembly.xml</descriptor>
@ -109,7 +109,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
@ -144,8 +144,8 @@
</plugin>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<header>src/licensing/header.txt</header>
<skipExistingHeaders>true</skipExistingHeaders>
@ -268,7 +268,7 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.63</version>
<version>1.64</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -309,10 +309,10 @@
</modules>
<properties>
<spring.version>5.2.0.RELEASE</spring.version>
<spring.version>5.2.2.RELEASE</spring.version>
<ehcache.version>2.6.11</ehcache.version>
<clover.version>3.0.2</clover.version>
<slf4j.version>1.7.28</slf4j.version>
<jackson.version>2.10.0</jackson.version>
<slf4j.version>1.7.30</slf4j.version>
<jackson.version>2.10.1</jackson.version>
</properties>
</project>