Pārlūkot izejas kodu

统一会话和授权

shuzheng 9 gadi atpakaļ
vecāks
revīzija
6ed482f1ed

+ 4 - 1
zheng-cms/zheng-cms-admin/src/main/resources/applicationContext-dubbo-consumer.xml

@@ -9,7 +9,8 @@
 
     <dubbo:application name="zheng-cms-admin"/>
 
-    <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+    <dubbo:registry address="zookeeper://127.0.0.1:2181" default="false"/>
+    <dubbo:registry id="upmsRegistry" address="zookeeper://127.0.0.1:2181"/>
 
     <!-- 订阅服务 -->
     <dubbo:consumer check="false"/>
@@ -25,4 +26,6 @@
     <!-- 用户 -->
     <dubbo:reference id="userService" interface="com.zheng.cms.rpc.api.UserService" mock="true"/>
 
+    <!-- 接口服务 -->
+    <dubbo:reference id="upmsApiService" interface="com.zheng.upms.rpc.api.UpmsApiService" mock="true" registry="upmsRegistry"/>
 </beans>

+ 7 - 18
zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/web.xml

@@ -52,29 +52,18 @@
         <url-pattern>/</url-pattern>
     </servlet-mapping>
 
-    <!-- zhang-upms-client -->
+    <!-- shiroFilter -->
     <filter>
-        <filter-name>zheng-upms-client</filter-name>
-        <filter-class>com.zheng.upms.client.filter.SSOFilter</filter-class>
-        <!-- 系统名称 -->
+        <filter-name>shiroFilter</filter-name>
+        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
         <init-param>
-            <param-name>system_name</param-name>
-            <param-value>zheng-cms-admin</param-value>
-        </init-param>
-        <!-- SSO认证中心 -->
-        <init-param>
-            <param-name>sso_server_url</param-name>
-            <param-value>http://upms.zhangshuzheng.cn:1111</param-value>
-        </init-param>
-        <!-- 开发模式 -->
-        <init-param>
-            <param-name>sso_debug</param-name>
-            <param-value>false</param-value>
+            <param-name>targetFilterLifecycle</param-name>
+            <param-value>true</param-value>
         </init-param>
     </filter>
     <filter-mapping>
-        <filter-name>zheng-upms-client</filter-name>
-        <url-pattern>/manage/*</url-pattern>
+        <filter-name>shiroFilter</filter-name>
+        <url-pattern>/*</url-pattern>
     </filter-mapping>
 
     <!-- Druid连接池监控页面 -->

+ 3 - 17
zheng-upms/zheng-upms-client/src/main/resources/applicationContext-shiro.xml

@@ -1,22 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       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-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+	    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
 
     <description>zheng-upms</description>
 
     <!-- Shiro的Web过滤器 -->
     <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
         <property name="securityManager" ref="securityManager"/>
-        <property name="loginUrl" value="/sso/login"/>
+        <property name="loginUrl" value="http://upms.zhangshuzheng.cn:1111/sso/login"/>
         <property name="successUrl" value="/manage"/>
         <property name="unauthorizedUrl" value="/403"/>
-        <property name="filters">
-            <util:map>
-                <entry key="authc" value-ref="formAuthenticationFilter"/>
-            </util:map>
-        </property>
         <property name="filterChainDefinitions">
             <value>
                 /manage/** = upmsSessionForceLogout,authc
@@ -109,15 +104,6 @@
 
     <!-- cacheManager -->
 
-    <!-- 登录表单过滤器 -->
-    <bean id="formAuthenticationFilter"
-          class="org.apache.shiro.web.filter.authc.FormAuthenticationFilter">
-        <property name="usernameParam" value="username"/>
-        <property name="passwordParam" value="password"/>
-        <property name="rememberMeParam" value="rememberMe"/>
-        <property name="loginUrl" value="/sso/login"/>
-    </bean>
-
     <!-- 设置SecurityUtils,相当于调用SecurityUtils.setSecurityManager(securityManager) -->
     <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
         <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>