|
@@ -0,0 +1,150 @@
|
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
+<beans:beans xmlns="http://www.springframework.org/schema/security"
|
|
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
+ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
|
|
|
|
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
|
|
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
|
|
|
|
+<!-- 增加登录过滤器 -->
|
|
|
|
+
|
|
|
|
+<!--该路径下的资源不用过滤-->
|
|
|
|
+ <http pattern="/images/**" security="none"/>
|
|
|
|
+ <http pattern="/styles/**" security="none"/>
|
|
|
|
+ <http pattern="/scripts/**" security="none"/>
|
|
|
|
+ <http pattern="/plugin/**" security="none"/>
|
|
|
|
+ <http pattern="/upload/**" security="none"/>
|
|
|
|
+ <http pattern="/app/uploadTemplate/**" security="none"/>
|
|
|
|
+ <http pattern="/wechat/**" security="none"/>
|
|
|
|
+ <http pattern="/app/wechat/**" security="none"/>
|
|
|
|
+ <http pattern="/loginByToken" security="none"/>
|
|
|
|
+
|
|
|
|
+ <!--<http use-expressions="true">-->
|
|
|
|
+ <!--access="isAuthenticated()"-->
|
|
|
|
+
|
|
|
|
+ <!--auto-config = true 则使用from-login. 如果不使用该属性 则默认为http-basic(没有session).-->
|
|
|
|
+ <!-- lowercase-comparisons:表示URL比较前先转为小写。-->
|
|
|
|
+ <!-- path-type:表示使用Apache Ant的匹配模式。-->
|
|
|
|
+ <!--access-denied-page:访问拒绝时转向的页面。-->
|
|
|
|
+ <!-- access-decision-manager-ref:指定了自定义的访问策略管理器。-->
|
|
|
|
+ <http auto-config="true">
|
|
|
|
+
|
|
|
|
+ <http-basic/>
|
|
|
|
+
|
|
|
|
+ <!--intercept-url 指定拦截的url
|
|
|
|
+ 通过pattern指定当前intercept-url定义应当作用于哪些url
|
|
|
|
+ 可以通过access属性来指定intercept-url对应URL访问所应当具有的权限
|
|
|
|
+ -->
|
|
|
|
+ <intercept-url pattern="/repairBill/**" access="ROLE_ADMIN,ROLE_USER"/>
|
|
|
|
+
|
|
|
|
+ <!-- 用于测试权限问题 -->
|
|
|
|
+ <intercept-url pattern="/api/superdesk-app-auth/**" access="ROLE_ADMIN,ROLE_USER"/>
|
|
|
|
+
|
|
|
|
+ <intercept-url pattern="/app/api/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/kafka/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/lingling/PcPost/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/lingling/VisitorPcPost/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/appuser/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/appweb/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/third/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <!-- <intercept-url pattern="/app/wechat/**" access="ROLE_ANONYMOUS"/> -->
|
|
|
|
+ <intercept-url pattern="/app/mobile/**" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/estate/**" access="ROLE_ADMIN"/>
|
|
|
|
+ <intercept-url pattern="/app/admin/**" access="ROLE_ADMIN,ROLE_USER"/>
|
|
|
|
+ <intercept-url pattern="/app/dto/*" access="ROLE_ANONYMOUS"/>
|
|
|
|
+ <intercept-url pattern="/app/passwordHint*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
|
|
|
|
+ <intercept-url pattern="/app/signup*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
|
|
|
|
+ <intercept-url pattern="/app/**" access="ROLE_ADMIN,ROLE_USER"/>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <!--login-page:指定登录页面。 -->
|
|
|
|
+ <!-- login-processing-url:指定了客户在登录页面中按下 Sign In 按钮时要访问的 URL。-->
|
|
|
|
+ <!-- authentication-failure-url:指定了身份验证失败时跳转到的页面。-->
|
|
|
|
+ <!-- default-target-url:指定了成功进行身份验证和授权后默认呈现给用户的页面。-->
|
|
|
|
+ <!-- always-use-default-target:指定了是否在身份验证通过后总是跳转到default-target-url属性指定的URL。
|
|
|
|
+ authentication-success-handler-ref :根据权限跳转不同画面(使用authentication-success-handler-ref流向不同action)
|
|
|
|
+ -->
|
|
|
|
+ <form-login login-page="/login"
|
|
|
|
+ authentication-failure-url="/login?error=true"
|
|
|
|
+ login-processing-url="/j_security_check"
|
|
|
|
+ authentication-success-handler-ref="authenticationSuccessHandler"/>
|
|
|
|
+ <custom-filter before="FORM_LOGIN_FILTER" ref="verificationLogin"></custom-filter>
|
|
|
|
+
|
|
|
|
+ <remember-me user-service-ref="userDao" key="e37f4b31-0c45-11dd-bd0b-0800200c9a66"/>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <!-- 重点 会话管理-->
|
|
|
|
+ <session-management>
|
|
|
|
+ <!-- spring security之并发控制 <concurrency-control max-sessions:允许用户帐号登录的次数。范例限制用户只能登录一次。-->
|
|
|
|
+ <!-- 此值表示:用户第二次登录时,前一次的登录信息都被清空。-->
|
|
|
|
+ <!-- exception-if-maximum-exceeded:默认为false,-->
|
|
|
|
+ <!-- 当exception-if-maximum-exceeded="true"时系统会拒绝第二次登录。-->
|
|
|
|
+ <!-- session-registry-alias spring security自定义sessionRegistry-->
|
|
|
|
+ <concurrency-control
|
|
|
|
+ max-sessions="200000"
|
|
|
|
+ error-if-maximum-exceeded="false"
|
|
|
|
+ expired-url="/outline.html"
|
|
|
|
+ session-registry-alias="sessionRegistry"
|
|
|
|
+ session-registry-ref="sessionRegistry"/>
|
|
|
|
+ </session-management>
|
|
|
|
+
|
|
|
|
+ </http>
|
|
|
|
+
|
|
|
|
+ <!-- 实现了UserDetailsService的Bean -->
|
|
|
|
+ <authentication-manager alias="authenticationManager">
|
|
|
|
+
|
|
|
|
+ <!-- 正常用户验证 provider -->
|
|
|
|
+ <authentication-provider user-service-ref="userDao">
|
|
|
|
+ <!-- 登入 密码 -->
|
|
|
|
+ <password-encoder ref="passwordEncoder">
|
|
|
|
+ <salt-source ref="saltSource"/>
|
|
|
|
+ </password-encoder>
|
|
|
|
+ </authentication-provider>
|
|
|
|
+
|
|
|
|
+ <!-- 企业账号验证 provider -->
|
|
|
|
+ <authentication-provider ref="virAccountAuthenticationProvider">
|
|
|
|
+ </authentication-provider>
|
|
|
|
+
|
|
|
|
+ <!-- 新服务之窗backend provider -->
|
|
|
|
+ <authentication-provider ref="spuerdeskAppAuthenticationProvider">
|
|
|
|
+ </authentication-provider>
|
|
|
|
+
|
|
|
|
+ </authentication-manager>
|
|
|
|
+ <beans:bean id="verificationLogin" class="com.palmnest.webapp.filter.LoginFilterAuthentication">
|
|
|
|
+ <beans:property name="authenticationManager" ref="authenticationManager"/> <!-- 身份验证 必须的 -->
|
|
|
|
+ <beans:property name="authenticationSuccessHandler" ref="authenticationSuccessHandler" /> <!-- 验证通过 必须的 -->
|
|
|
|
+ <beans:property name="authenticationFailureHandler" ref="authenticationFailureHandler" />
|
|
|
|
+
|
|
|
|
+ </beans:bean>
|
|
|
|
+
|
|
|
|
+ <!-- -->
|
|
|
|
+ <beans:bean id="authenticationSuccessHandler" class="com.palmnest.webapp.controller.SimpleLoginSuccessHandler"/>
|
|
|
|
+ <beans:bean id="authenticationFailureHandler" class="com.palmnest.webapp.controller.LoginFailureHandler" />
|
|
|
|
+ <beans:bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource"
|
|
|
|
+ p:userPropertyToUse="username"/>
|
|
|
|
+
|
|
|
|
+ <!-- 配置MultipartResolver 用于文件上传 使用spring的CommosMultipartResolver -->
|
|
|
|
+ <beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
|
|
|
|
+ p:defaultEncoding="UTF-8"
|
|
|
|
+ p:maxUploadSize="54000000"
|
|
|
|
+ p:uploadTempDir="fileUpload/temp"
|
|
|
|
+ >
|
|
|
|
+ </beans:bean>
|
|
|
|
+
|
|
|
|
+ <!-- 所以我的配置里面只需要加上session-registry-ref就好了 -->
|
|
|
|
+ <beans:bean id="sessionRegistry"
|
|
|
|
+ class="com.palmnest.core.security.support.SessionRegistryImpl" scope="singleton">
|
|
|
|
+ <!-- 发现有 RedisTemplate 后屏蔽 -->
|
|
|
|
+ <!--<beans:property name="cacheManager" ref="cacheManager"/>-->
|
|
|
|
+ </beans:bean>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <!-- Override the default password-encoder (SHA) by uncommenting the following and changing the class -->
|
|
|
|
+ <!-- 已转移至 super_service/src/main/resources/applicationContext-service.xml -->
|
|
|
|
+ <!-- <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder"/> -->
|
|
|
|
+
|
|
|
|
+ <global-method-security>
|
|
|
|
+ <protect-pointcut expression="execution(* *..service.UserManager.getUsers(..))" access="ROLE_ADMIN"/>
|
|
|
|
+ <protect-pointcut expression="execution(* *..service.UserManager.removeUser(..))" access="ROLE_ADMIN"/>
|
|
|
|
+ </global-method-security>
|
|
|
|
+
|
|
|
|
+</beans:beans>
|