update config
This commit is contained in:
parent
32c9a1c7ee
commit
6722607bf9
@ -19,13 +19,13 @@
|
||||
<bean class="org.pac4j.cas.client.CasClient">
|
||||
<constructor-arg>
|
||||
<bean class="org.pac4j.cas.config.CasConfiguration">
|
||||
<constructor-arg value="${cas.server.login-url:${cas.server.addr}/login}" />
|
||||
<property name="protocol" value="${cas.protocol:CAS20}" />
|
||||
<constructor-arg value="${tigon.shiro.cas.login-url:${tigon.shiro.cas.server.addr}/login}" />
|
||||
<property name="protocol" value="${tigon.shiro.cas.protocol:CAS20}" />
|
||||
<property name="acceptAnyProxy" value="true" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<property name="name" value="${spring.application.name}" />
|
||||
<property name="callbackUrl" value="${cas.client.login.url:${cas.client.addr}${cas.client.login.path:/cas/login}?client_name=${spring.application.name}}" />
|
||||
<property name="callbackUrl" value="${tigon.shiro.cas.login-callback-url:${tigon.shiro.cas.client.addr}${tigon.shiro.cas.login-callback-path:/cas/login}?client_name=${spring.application.name}}" />
|
||||
<property name="profileCreator">
|
||||
<bean class="me.chyxion.tigon.shiro.cas.DefaultProfileCreator" />
|
||||
</property>
|
||||
@ -35,34 +35,45 @@
|
||||
|
||||
<bean id="shiroFilter" parent="shiroFilterParent">
|
||||
<property name="securityManager" ref="securityManager" />
|
||||
<property name="loginUrl" value="${shiro.login-url:${cas.server.login-url:${cas.server.addr}/login}}?service=${cas.client.addr}${cas.client.login.path:/cas/login}?client_name=${spring.application.name}}" />
|
||||
<property name="successUrl" value="${cas.client.login.success-url:/login-success}" />
|
||||
<property name="unauthorizedUrl" value="${cas.client.unauthorized-url:/403}" />
|
||||
<property name="loginUrl" value="${tigon.shiro.login-url:${tigon.shiro.cas.server.login-url:${tigon.shiro.cas.server.addr}/login}}?service=${tigon.shiro.cas.client.addr}${tigon.shiro.cas.client.login.path:/cas/login}?client_name=${spring.application.name}}" />
|
||||
<property name="successUrl" value="${tigon.shiro.login-success-url:/login-success}" />
|
||||
|
||||
<property name="filters">
|
||||
<map>
|
||||
<entry key="cas">
|
||||
<entry key="${tigon.shiro.cas.login-callback-filter-name:cas}">
|
||||
<bean class="io.buji.pac4j.filter.CallbackFilter">
|
||||
<property name="config" ref="casConfig" />
|
||||
<property name="defaultUrl" value="${cas.client.login.success-url:/login-success}" />
|
||||
</bean>
|
||||
</entry>
|
||||
<entry key="user">
|
||||
<entry key="${tigon.shiro.cas.security-filter-name:user}">
|
||||
<bean class="io.buji.pac4j.filter.SecurityFilter">
|
||||
<property name="config" ref="casConfig" />
|
||||
<property name="clients" value="${spring.application.name}" />
|
||||
</bean>
|
||||
</entry>
|
||||
<entry key="logout">
|
||||
<entry key="${tigon.shiro.cas.logout-filter-name:logout}">
|
||||
<bean class="io.buji.pac4j.filter.LogoutFilter">
|
||||
<property name="config" ref="casConfig" />
|
||||
<property name="localLogout" value="${cas.client.logout.local:true}" />
|
||||
<property name="centralLogout" value="${cas.client.logout.central:true}" />
|
||||
<property name="logoutUrlPattern" value="${cas.client.logout.path:/logout}" />
|
||||
<property name="defaultUrl" value="${cas.client.logout.success-url:/logout-success}" />
|
||||
<property name="localLogout" value="${tigon.shiro.cas.local-logout:true}" />
|
||||
<property name="centralLogout" value="${tigon.shiro.cas.central-logout:true}" />
|
||||
<property name="logoutUrlPattern" value="${tigon.shiro.logout-path:/logout}" />
|
||||
<property name="defaultUrl" value="${tigon.shiro.logout-success-url:/logout-success}" />
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
|
||||
<property name="filterChainDefinitionMap">
|
||||
<bean class="me.chyxion.tigon.shiro.FilterChainDefinitionMap">
|
||||
<constructor-arg value="${tigon.shiro.filter-chain-definition.config-location:classpath:shiro/auth.properties}" />
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry key="${tigon.shiro.cas.login-callback-path:/cas/login}" value="${tigon.shiro.cas.login-callback-filter-name:cas}" />
|
||||
<entry key="${tigon.shiro.cas.logout-path:/logout}" value="${tigon.shiro.cas.logout-filter-name:logout}" />
|
||||
<entry key="${tigon.shiro.cas.logout-success-url:/logout-success}" value="anon" />
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@ -21,6 +21,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.chyxion.tigon</groupId>
|
||||
<artifactId>tigon-sequence</artifactId>
|
||||
|
@ -1,13 +1,9 @@
|
||||
package me.chyxion.tigon.shiro;
|
||||
|
||||
import java.util.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.util.Set;
|
||||
import java.util.Properties;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.springframework.core.io.Resource;
|
||||
@ -19,43 +15,57 @@ import org.springframework.core.io.Resource;
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
public class FilterChainDefinitionMap extends LinkedHashMap {
|
||||
private Resource configLocation;
|
||||
public class FilterChainDefinitionMap extends LinkedHashMap<String, String> {
|
||||
private final Resource configLocation;
|
||||
|
||||
@PostConstruct
|
||||
void init() throws IOException {
|
||||
public FilterChainDefinitionMap(final Resource configLocation) {
|
||||
this.configLocation = configLocation;
|
||||
}
|
||||
|
||||
public FilterChainDefinitionMap(final Resource configLocation, final Map<String, String> map) {
|
||||
super(map);
|
||||
this.configLocation = configLocation;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
void init() throws IOException {
|
||||
log.info("Load shiro filter chain definition from config location [{}].", configLocation);
|
||||
|
||||
final InputStream authIn = configLocation != null && configLocation.exists() ?
|
||||
configLocation.getInputStream() :
|
||||
FilterChainDefinitionMap.class
|
||||
.getResourceAsStream("/shiro/auth.properties");
|
||||
|
||||
if (authIn != null) {
|
||||
final Properties props = new OrderedProperties();
|
||||
try {
|
||||
props.load(authIn);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException(
|
||||
"Load shiro filter chain definition config error caused", e);
|
||||
}
|
||||
finally {
|
||||
if (authIn != null) {
|
||||
try {
|
||||
authIn.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
if (configLocation != null && configLocation.exists()) {
|
||||
final InputStream authIn = configLocation.getInputStream();
|
||||
if (authIn != null) {
|
||||
final Properties props = new OrderedProperties();
|
||||
try {
|
||||
props.load(authIn);
|
||||
}
|
||||
catch (final IOException e) {
|
||||
throw new IllegalStateException(
|
||||
"Load shiro filter chain definition config error caused", e);
|
||||
}
|
||||
finally {
|
||||
if (authIn != null) {
|
||||
try {
|
||||
authIn.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String name : props.stringPropertyNames()) {
|
||||
put(name, props.getProperty(name));
|
||||
for (final String path : props.stringPropertyNames()) {
|
||||
final String auth = props.getProperty(path);
|
||||
log.info("Shiro filter chain definition [{}] -> [{}] added.", path, auth);
|
||||
put(path, auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.info("No input stream load from shiro filter chain definition config location [{}], ignore.", configLocation);
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.info("Shiro filter chain definition config location [{}] does not exist, ignore.", configLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@Slf4j
|
||||
|
@ -17,26 +17,26 @@
|
||||
<property name="sessionManager">
|
||||
<bean class="me.chyxion.tigon.shiro.TigonWebSessionManager">
|
||||
<property name="globalSessionTimeout"
|
||||
value="${shiro.session.timeout:1800000}"/>
|
||||
value="${tigon.shiro.session.timeout:1800000}"/>
|
||||
<property name="sessionValidationSchedulerEnabled"
|
||||
value="${shiro.session.validation.scheduler.enabled:false}" />
|
||||
value="${tigon.shiro.session.validation.scheduler.enabled:false}" />
|
||||
<property name="sessionValidationInterval"
|
||||
value="${shiro.session.validation.interval:3600000}" />
|
||||
value="${tigon.shiro.session.validation.interval:3600000}" />
|
||||
<property name="sessionDAO">
|
||||
<bean class="me.chyxion.tigon.shiro.TigonSessionDAO" />
|
||||
</property>
|
||||
<property name="sessionIdCookieEnabled" value="${shiro.session.id.cookie.enabled:true}" />
|
||||
<property name="sessionIdUrlRewritingEnabled" value="${shiro.session.id.url.rewriting.enabled:true}" />
|
||||
<property name="sessionIdCookieEnabled" value="${tigon.shiro.session.id.cookie.enabled:true}" />
|
||||
<property name="sessionIdUrlRewritingEnabled" value="${tigon.shiro.session.id.url.rewriting.enabled:true}" />
|
||||
<property name="sessionIdCookie">
|
||||
<bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
|
||||
<constructor-arg value="${shiro.session.id.cookie.name:SID}" />
|
||||
<property name="domain" value="${shiro.cookie.domain:}" />
|
||||
<property name="path" value="${shiro.cookie.path:/}" />
|
||||
<property name="maxAge" value="${shiro.cookie.max.age:-1}" />
|
||||
<property name="version" value="${shiro.cookie.version:-1}" />
|
||||
<property name="secure" value="${shiro.cookie.secure:false}" />
|
||||
<property name="httpOnly" value="${shiro.cookie.http.only:true}" />
|
||||
<property name="comment" value="${shiro.cookie.comment:}" />
|
||||
<constructor-arg value="${tigon.shiro.session.id.cookie.name:SID}" />
|
||||
<property name="domain" value="${tigon.shiro.cookie.domain:}" />
|
||||
<property name="path" value="${tigon.shiro.cookie.path:/}" />
|
||||
<property name="maxAge" value="${tigon.shiro.cookie.max.age:-1}" />
|
||||
<property name="version" value="${tigon.shiro.cookie.version:-1}" />
|
||||
<property name="secure" value="${tigon.shiro.cookie.secure:false}" />
|
||||
<property name="httpOnly" value="${tigon.shiro.cookie.http.only:true}" />
|
||||
<property name="comment" value="${tigon.shiro.cookie.comment:}" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
@ -45,14 +45,13 @@
|
||||
|
||||
<bean id="shiroFilterParent" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean" abstract="true">
|
||||
<property name="securityManager" ref="securityManager" />
|
||||
<property name="loginUrl" value="${cas.login-url:${cas.server.login-url:${cas.server.addr}/login}}?service=${cas.client.addr}${cas.client.login.path:/cas/login}?client_name=${spring.application.name}}" />
|
||||
<property name="successUrl" value="${cas.client.login.success-url:/login-success}" />
|
||||
<property name="unauthorizedUrl" value="${cas.client.unauthorized-url:/403}" />
|
||||
<property name="loginUrl" value="${tigon.shiro.login-url:/login}" />
|
||||
<property name="successUrl" value="${tigon.shiro.login-success-url:/}" />
|
||||
<property name="unauthorizedUrl" value="${tigon.shiro.unauthorized-url:/403}" />
|
||||
|
||||
<property name="filterChainDefinitionMap">
|
||||
<bean class="me.chyxion.tigon.shiro.FilterChainDefinitionMap">
|
||||
<property name="configLocation"
|
||||
value="${shiro.filter-chain-definition.config-location:classpath*:shiro/auth.properties}" />
|
||||
<constructor-arg value="${tigon.shiro.filter-chain-definition.config-location:classpath:shiro/auth.properties}" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
@ -63,13 +62,13 @@
|
||||
<constructor-arg value="shiroFilter" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="enabled" value="${shiro.fitler.enabled:true}" />
|
||||
<property name="enabled" value="${tigon.shiro.fitler.enabled:true}" />
|
||||
<property name="initParameters">
|
||||
<map>
|
||||
<entry key="targetFilterLifecycle" value="true" />
|
||||
</map>
|
||||
</property>
|
||||
<property name="urlPatterns" value="${shiro.fitler.url-patterns:/*}" />
|
||||
<property name="urlPatterns" value="${tigon.shiro.fitler.url-patterns:/*}" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
Loading…
x
Reference in New Issue
Block a user