From fef5aa09d38afcd007bc8e4dcb665020f11c83de Mon Sep 17 00:00:00 2001 From: huangwb Date: Thu, 28 Sep 2017 13:41:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/SimpleUrlPatternMatcherStrategy.java | 29 +++++++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 11 +++++-- .../src/main/webapp/wangwu.jsp | 15 ++++++++++ .../src/main/webapp/zhangsan.jsp | 14 +++++++++ .../services/Localhost-10000002.json | 6 ++-- 5 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 sso-client-demo/sso-cas-client-demo/src/main/java/com/carl/auth/sso/client/demo/SimpleUrlPatternMatcherStrategy.java create mode 100644 sso-client-demo/sso-cas-client-demo/src/main/webapp/wangwu.jsp create mode 100644 sso-client-demo/sso-cas-client-demo/src/main/webapp/zhangsan.jsp diff --git a/sso-client-demo/sso-cas-client-demo/src/main/java/com/carl/auth/sso/client/demo/SimpleUrlPatternMatcherStrategy.java b/sso-client-demo/sso-cas-client-demo/src/main/java/com/carl/auth/sso/client/demo/SimpleUrlPatternMatcherStrategy.java new file mode 100644 index 0000000..a448bfc --- /dev/null +++ b/sso-client-demo/sso-cas-client-demo/src/main/java/com/carl/auth/sso/client/demo/SimpleUrlPatternMatcherStrategy.java @@ -0,0 +1,29 @@ +/* + * 版权所有.(c)2008-2017. 卡尔科技工作室 + */ + +package com.carl.auth.sso.client.demo; + +import org.jasig.cas.client.authentication.UrlPatternMatcherStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Carl + * @date 2017/9/28 + * @since 1.5.0 + */ +public class SimpleUrlPatternMatcherStrategy implements UrlPatternMatcherStrategy { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public boolean matches(String url) { + logger.debug("访问路径:" + url); + return url.contains("zhangsan.jsp"); + } + + @Override + public void setPattern(String pattern) { + + } +} diff --git a/sso-client-demo/sso-cas-client-demo/src/main/webapp/WEB-INF/web.xml b/sso-client-demo/sso-cas-client-demo/src/main/webapp/WEB-INF/web.xml index f53840d..a69af30 100644 --- a/sso-client-demo/sso-cas-client-demo/src/main/webapp/WEB-INF/web.xml +++ b/sso-client-demo/sso-cas-client-demo/src/main/webapp/WEB-INF/web.xml @@ -18,7 +18,7 @@ org.jasig.cas.client.session.SingleSignOutFilter casServerUrlPrefix - https://mmoayyed.unicon.net:8443/cas + https://passport.sso.com:8443/cas @@ -38,8 +38,15 @@ serverName http://localhost:8080 + + ignorePattern + .* + + + ignoreUrlPatternType + com.carl.auth.sso.client.demo.SimpleUrlPatternMatcherStrategy + - CAS Validation Filter diff --git a/sso-client-demo/sso-cas-client-demo/src/main/webapp/wangwu.jsp b/sso-client-demo/sso-cas-client-demo/src/main/webapp/wangwu.jsp new file mode 100644 index 0000000..d7a9cad --- /dev/null +++ b/sso-client-demo/sso-cas-client-demo/src/main/webapp/wangwu.jsp @@ -0,0 +1,15 @@ +<%-- + ~ 版权所有.(c)2008-2017. 卡尔科技工作室 + --%> + + + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 王五 + + +需要登录才访问 + + diff --git a/sso-client-demo/sso-cas-client-demo/src/main/webapp/zhangsan.jsp b/sso-client-demo/sso-cas-client-demo/src/main/webapp/zhangsan.jsp new file mode 100644 index 0000000..c0a96c6 --- /dev/null +++ b/sso-client-demo/sso-cas-client-demo/src/main/webapp/zhangsan.jsp @@ -0,0 +1,14 @@ +<%-- + ~ 版权所有.(c)2008-2017. 卡尔科技工作室 + --%> + + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 张三 + + +可以不登录就访问 + + diff --git a/sso-server/src/main/resources/services/Localhost-10000002.json b/sso-server/src/main/resources/services/Localhost-10000002.json index 1f54948..8c0331b 100644 --- a/sso-server/src/main/resources/services/Localhost-10000002.json +++ b/sso-server/src/main/resources/services/Localhost-10000002.json @@ -1,8 +1,8 @@ { "@class": "org.apereo.cas.services.RegexRegisteredService", - "serviceId": "^(http)://localhost.*", - "name": "本地服务", + "serviceId": "^(http|https)://localhost.*", + "name": "Local Services", "id": 10000002, - "description": "这是一个本地允许的服务,通过localhost访问都允许通过", + "description": "this is a localhost service,all of can login", "evaluationOrder": 10000000 }