Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加忽略列表文件 #183

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
target/

/webapp/WEB-INF/classes

/.settings

/.classpath

/.project
/mossle.store
target/

/webapp/WEB-INF/classes

/.settings

/.idea


/.classpath

/.project
/mossle.store

2 changes: 1 addition & 1 deletion src/main/resources/spring/ctx-common-i18n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

<!-- 国际化 -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames" value="${application.i18n.packages}"/>
<property name="useCodeAsDefaultMessage" value="true" />
</bean>
Expand Down
306 changes: 154 additions & 152 deletions src/main/resources/spring/ctx-common-security-extend.xml
Original file line number Diff line number Diff line change
@@ -1,152 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!-- 校验权限是否匹配 -->
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<constructor-arg>
<list>
<bean class="com.mossle.security.client.AuthenticatedVoter"/>
<bean class="com.mossle.security.perm.PermissionVoter">
<property name="permissionChecker" ref="permissionChecker"/>
</bean>
</list>
</constructor-arg>
</bean>

<!-- 校验权限 -->
<bean id="permissionChecker" class="com.mossle.security.perm.PermissionChecker"/>

<!-- 认证 -->
<!--
<bean id="authenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/>
<property name="passwordEncoder" ref="passwordEncoder"/>
</bean>
-->
<!--
<bean id="authenticationProvider" class="com.mossle.security.client.SimpleAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/>
<property name="passwordEncoder" ref="passwordEncoder"/>
<property name="remoteUserConnector" ref="remoteUserConnector"/>
</bean>
-->
<bean id="authenticationProvider" class="com.mossle.security.client.DefaultAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/>
<property name="authnClient" ref="authnClient"/>
<property name="tenantHolder" ref="tenantHolder"/>
</bean>

<!-- 为认证获取用户信息 -->
<!--
<bean id="userDetailsService" class="com.mossle.security.client.DefaultUserDetailsService">
<property name="userAuthConnector" ref="userAuthConnector"/>
<property name="internalUserConnector" ref="internalUserConnector"/>
<property name="debug" value="${security.autologin.enabled}"/>
<property name="tenantHolder" ref="tenantHolder"/>
</bean>
-->
<bean id="userDetailsService" class="com.mossle.security.client.MockUserDetailsService">
<property name="userClient" ref="userClient" />
<property name="authzClient" ref="authzClient" />
<property name="tenantHolder" ref="tenantHolder" />
</bean>

<!-- 密码加密器 -->
<bean id="passwordEncoder" class="com.mossle.security.support.PasswordEncoderFactoryBean">
<property name="type" value="${security.passwordencoder.type}"/>
<property name="salt" value="${security.passwordencoder.salt}"/>
</bean>

<!-- 获取当前登录用户的工具 -->
<!--
<bean id="currentUserHolder" class="com.mossle.security.client.SpringSecurityCurrentUserHolder"/>
-->
<bean id="currentUserHolder" class="com.mossle.security.support.SpringSecurityCurrentUserHolder"/>

<!-- 又一个密码加密器? -->
<bean id="customPasswordEncoder" factory-bean="&amp;passwordEncoder" factory-method="getCustomPasswordEncoder"/>

<!-- 测试环境下使用的自动登录工具 -->
<bean id="autoLoginFilter" class="com.mossle.security.client.AutoLoginFilter">
<property name="enabled" value="${security.autologin.enabled}" />
<property name="defaultUserName" value="${security.autologin.username}" />
<property name="userDetailsService" ref="userDetailsService" />
</bean>

<!-- 验证码 -->
<bean id="captchaFilter" class="com.mossle.security.client.CaptchaFilter"/>

<!-- 切换用户身份 -->
<bean id="switchUserFilter" class="org.springframework.security.web.authentication.switchuser.SwitchUserFilter">
<property name="userDetailsService" ref="userDetailsService" />
<property name="targetUrl" value="/common/util/switchUser.jsp" />
</bean>

<!-- 初始化URL和METHOD权限 -->
<bean id="resourceDetailsMonitor" class="com.mossle.security.client.ResourceDetailsMonitor">
<property name="debug" value="${security.resource.debug}"/>
<property name="filterSecurityInterceptor"
ref="org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0"/>
<property name="urlSourceFetcher" ref="${security.url.fetcher.type}UrlSourceFetcher"/>
<property name="delegatingMethodSecurityMetadataSource"
ref="org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0"/>
<property name="methodSourceFetcher" ref="${security.method.fetcher}MethodSourceFetcher"/>
</bean>

<!-- resource修改后通知其他节点更新权限 -->
<bean id="resourcePublisher" class="com.mossle.security.client.ResourcePublisherImpl"/>

<!-- 日志 -->
<bean class="org.springframework.security.authentication.event.LoggerListener"/>
<bean class="org.springframework.security.access.event.LoggerListener"/>

<!-- url fetcher -->
<bean id="databaseUrlSourceFetcher" class="com.mossle.security.impl.DatabaseUrlSourceFetcher">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean>

<bean id="httpUrlSourceFetcher" class="com.mossle.security.impl.HttpUrlSourceFetcher">
<property name="url" value="${security.url.fetcher.url}"/>
<property name="appId" value="${security.defaultAppId}"/>
</bean>

<!-- method fetcher -->
<bean id="databaseMethodSourceFetcher" class="com.mossle.security.impl.DatabaseMethodSourceFetcher">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean>

<!-- 实现用户权限修改后,不用重新登录就刷新权限 -->
<bean id="securityContextRepository" class="com.mossle.security.client.CachedSecurityContextRepository">
<property name="authzClient" ref="authzClient"/>
<!--
<property name="debug" value="${security.autologin.enabled}"/>
-->
<property name="debug" value="true"/>
</bean>

<!-- 认证成功后,记住最后使用的账号 -->
<bean id="authenticationSuccessHandler" class="com.mossle.security.util.RememberLastUsernameAuthenticationSuccessHandler"/>

<!-- 认证失败后,记住最后使用的账号 -->
<bean id="authenticationFailureHandler" class="com.mossle.security.util.RememberLastUsernameAuthenticationFailureHandler">
<property name="defaultFailureUrl" value="/common/login.jsp?error=true"/>
</bean>

<!-- 注销成功以后发送LogoutEvent -->
<bean id="logoutSuccessHandler" class="com.mossle.security.util.LogoutSuccessHandlerImpl"/>

<!-- 把spring security的event转化成LoginEvent和LogoutEvent -->
<bean class="com.mossle.security.util.SpringSecurityListener"/>

<!-- 提供从session中直接获取UserAuthDTO -->
<bean id="internalUserAuthConnector" class="com.mossle.security.util.InternalUserAuthConnectorImpl"/>

<!-- 为测试环境提供权限控制 -->
<bean id="testUrlResourcePopulator" class="com.mossle.security.client.TestUrlResourcePopulator">
<property name="filterSecurityInterceptor" ref="org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0"/>
<property name="enable" value="${security.url.test.enable}"/>
</bean>

</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!-- 校验权限是否匹配 -->
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<constructor-arg>
<list>
<bean class="com.mossle.security.client.AuthenticatedVoter"/>
<bean class="com.mossle.security.perm.PermissionVoter">
<property name="permissionChecker" ref="permissionChecker"/>
</bean>
</list>
</constructor-arg>
</bean>

<!-- 校验权限 -->
<bean id="permissionChecker" class="com.mossle.security.perm.PermissionChecker"/>

<!-- 认证 -->
<!--
<bean id="authenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/>
<property name="passwordEncoder" ref="passwordEncoder"/>
</bean>
-->
<!--
<bean id="authenticationProvider" class="com.mossle.security.client.SimpleAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/>
<property name="passwordEncoder" ref="passwordEncoder"/>
<property name="remoteUserConnector" ref="remoteUserConnector"/>
</bean>
-->
<bean id="authenticationProvider" class="com.mossle.security.client.DefaultAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/>
<property name="authnClient" ref="authnClient"/>
<property name="tenantHolder" ref="tenantHolder"/>
</bean>

<!-- 为认证获取用户信息 -->
<!--
<bean id="userDetailsService" class="com.mossle.security.client.DefaultUserDetailsService">
<property name="userAuthConnector" ref="userAuthConnector"/>
<property name="internalUserConnector" ref="internalUserConnector"/>
<property name="debug" value="${security.autologin.enabled}"/>
<property name="tenantHolder" ref="tenantHolder"/>
</bean>
-->
<bean id="userDetailsService" class="com.mossle.security.client.MockUserDetailsService">
<property name="userClient" ref="userClient" />
<property name="authzClient" ref="authzClient" />
<property name="tenantHolder" ref="tenantHolder" />
</bean>

<!-- 密码加密器 -->
<bean id="passwordEncoder" class="com.mossle.security.support.PasswordEncoderFactoryBean">
<property name="type" value="${security.passwordencoder.type}"/>
<property name="salt" value="${security.passwordencoder.salt}"/>
</bean>

<!-- 获取当前登录用户的工具 -->
<!--
<bean id="currentUserHolder" class="com.mossle.security.client.SpringSecurityCurrentUserHolder"/>
-->
<bean id="currentUserHolder" class="com.mossle.security.support.SpringSecurityCurrentUserHolder"/>

<!-- 又一个密码加密器? -->
<bean id="customPasswordEncoder" factory-bean="&amp;passwordEncoder" factory-method="getCustomPasswordEncoder"/>

<!-- 测试环境下使用的自动登录工具 -->
<bean id="autoLoginFilter" class="com.mossle.security.client.AutoLoginFilter">
<property name="enabled" value="${security.autologin.enabled}" />
<property name="defaultUserName" value="${security.autologin.username}" />
<property name="userDetailsService" ref="userDetailsService" />
</bean>

<!-- 验证码 -->
<bean id="captchaFilter" class="com.mossle.security.client.CaptchaFilter"/>

<!-- 切换用户身份 -->
<bean id="switchUserFilter" class="org.springframework.security.web.authentication.switchuser.SwitchUserFilter">
<property name="userDetailsService" ref="userDetailsService" />
<property name="targetUrl" value="/common/util/switchUser.jsp" />
</bean>

<!-- 初始化URL和METHOD权限 -->
<bean id="resourceDetailsMonitor" class="com.mossle.security.client.ResourceDetailsMonitor">
<property name="debug" value="${security.resource.debug}"/>
<property name="filterSecurityInterceptor"
ref="org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0"/>
<property name="urlSourceFetcher" ref="${security.url.fetcher.type}UrlSourceFetcher"/>
<property name="delegatingMethodSecurityMetadataSource"
ref="org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0"/>
<property name="methodSourceFetcher" ref="${security.method.fetcher}MethodSourceFetcher"/>
</bean>

<!-- resource修改后通知其他节点更新权限 -->
<bean id="resourcePublisher" class="com.mossle.security.client.ResourcePublisherImpl"/>

<!-- 日志 -->
<bean class="org.springframework.security.authentication.event.LoggerListener"/>
<bean class="org.springframework.security.access.event.LoggerListener"/>

<!-- url fetcher -->
<bean id="databaseUrlSourceFetcher" class="com.mossle.security.impl.DatabaseUrlSourceFetcher">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean>

<bean id="httpUrlSourceFetcher" class="com.mossle.security.impl.HttpUrlSourceFetcher">
<property name="url" value="${security.url.fetcher.url}"/>
<property name="appId" value="${security.defaultAppId}"/>
</bean>

<!-- method fetcher -->
<bean id="databaseMethodSourceFetcher" class="com.mossle.security.impl.DatabaseMethodSourceFetcher">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean>

<!-- 实现用户权限修改后,不用重新登录就刷新权限 -->
<bean id="securityContextRepository" class="com.mossle.security.client.CachedSecurityContextRepository">
<property name="authzClient" ref="authzClient"/>
<!--
<property name="debug" value="${security.autologin.enabled}"/>
-->
<property name="debug" value="true"/>
</bean>

<!-- 认证成功后,记住最后使用的账号 -->
<bean id="authenticationSuccessHandler" class="com.mossle.security.util.RememberLastUsernameAuthenticationSuccessHandler">
<property name="alwaysUseDefaultTargetUrl" value="true"/>
</bean>

<!-- 认证失败后,记住最后使用的账号 -->
<bean id="authenticationFailureHandler" class="com.mossle.security.util.RememberLastUsernameAuthenticationFailureHandler">
<property name="defaultFailureUrl" value="/common/login.jsp?error=true"/>
</bean>

<!-- 注销成功以后发送LogoutEvent -->
<bean id="logoutSuccessHandler" class="com.mossle.security.util.LogoutSuccessHandlerImpl"/>

<!-- 把spring security的event转化成LoginEvent和LogoutEvent -->
<bean class="com.mossle.security.util.SpringSecurityListener"/>

<!-- 提供从session中直接获取UserAuthDTO -->
<bean id="internalUserAuthConnector" class="com.mossle.security.util.InternalUserAuthConnectorImpl"/>

<!-- 为测试环境提供权限控制 -->
<bean id="testUrlResourcePopulator" class="com.mossle.security.client.TestUrlResourcePopulator">
<property name="filterSecurityInterceptor" ref="org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0"/>
<property name="enable" value="${security.url.test.enable}"/>
</bean>

</beans>