Skip to content

Commit

Permalink
完成shiro的单点退出功能,目前能够在shiro退出,cas能够也退出
Browse files Browse the repository at this point in the history
尚未解决问题:cas退出,shiro未退出,因为shiro收不到退出通知
  • Loading branch information
kawhii committed Oct 14, 2017
1 parent 2aa55eb commit 51ec494
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;


/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -155,6 +159,12 @@ protected Map<String, Filter> 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;
}
}
10 changes: 10 additions & 0 deletions sso-server/src/main/resources/services/CasClient-10000001.json
Original file line number Diff line number Diff line change
@@ -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/"
}
10 changes: 10 additions & 0 deletions sso-server/src/main/resources/services/ShiroClient-10000000.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 51ec494

Please sign in to comment.