diff --git a/sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/confg/ShiroConfiguration.java b/sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/confg/ShiroConfiguration.java index 1b06958..6b5286d 100644 --- a/sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/confg/ShiroConfiguration.java +++ b/sso-client-demo/sso-client-shiro-demo/src/main/java/com/carl/auth/shiro/client/demo/confg/ShiroConfiguration.java @@ -6,6 +6,7 @@ import io.buji.pac4j.filter.CallbackFilter; +import io.buji.pac4j.filter.LogoutFilter; import io.buji.pac4j.filter.SecurityFilter; import io.buji.pac4j.subject.Pac4jSubjectFactory; import org.apache.shiro.mgt.DefaultSecurityManager; @@ -43,6 +44,8 @@ public class ShiroConfiguration extends AbstractShiroWebFilterConfiguration { private String casLoginUrl; @Value("#{ @environment['cas.callbackUrl'] ?: null }") private String callbackUrl; + @Value("#{ @environment['cas.serviceUrl'] ?: null }") + private String serviceUrl; /** @@ -121,6 +124,7 @@ public CasClient casClient() { public ShiroFilterChainDefinition shiroFilterChainDefinition() { DefaultShiroFilterChainDefinition definition = new DefaultShiroFilterChainDefinition(); definition.addPathDefinition("/callback", "callbackFilter"); + definition.addPathDefinition("/logout", "logoutFilter"); definition.addPathDefinition("/**", "casSecurityFilter"); return definition; } @@ -155,6 +159,12 @@ protected Map shiroFilters() { CallbackFilter callbackFilter = new CallbackFilter(); callbackFilter.setConfig(casConfig()); filters.put("callbackFilter", callbackFilter); + + LogoutFilter logoutFilter = new LogoutFilter(); + logoutFilter.setConfig(casConfig()); + logoutFilter.setCentralLogout(true); + logoutFilter.setDefaultUrl(serviceUrl); + filters.put("logoutFilter", logoutFilter); return filters; } } diff --git a/sso-server/src/main/resources/services/CasClient-10000001.json b/sso-server/src/main/resources/services/CasClient-10000001.json new file mode 100644 index 0000000..c011b62 --- /dev/null +++ b/sso-server/src/main/resources/services/CasClient-10000001.json @@ -0,0 +1,10 @@ +{ + "@class": "org.apereo.cas.services.RegexRegisteredService", + "serviceId" : "^(https|imaps|http)://localhost:8080/sample.*", + "name": "CasClient-demo", + "id": 10000001, + "description": "CasClient-demo service", + "evaluationOrder": 100, + "theme":"apereo", + "logoutUrl": "http://localhost:8080/sample/" +} diff --git a/sso-server/src/main/resources/services/ShiroClient-10000000.json b/sso-server/src/main/resources/services/ShiroClient-10000000.json new file mode 100644 index 0000000..67ca38f --- /dev/null +++ b/sso-server/src/main/resources/services/ShiroClient-10000000.json @@ -0,0 +1,10 @@ +{ + "@class": "org.apereo.cas.services.RegexRegisteredService", + "serviceId" : "^(https|imaps|http)://localhost:8083.*", + "name": "ShiroClient-demo", + "id": 10000000, + "description": "ShiroClient-demo service", + "evaluationOrder": 100, + "theme":"apereo", + "logoutUrl": "http://localhost:8083/logout" +}