Bladeren bron

* init prj

chenlongfei 5 jaren geleden
bovenliggende
commit
6c7d673bac
3 gewijzigde bestanden met toevoegingen van 71 en 0 verwijderingen
  1. 6 0
      pom.xml
  2. 59 0
      src/main/java/com/mokamrp/privates/config/XxlSsoConfig.java
  3. 6 0
      src/main/resources/application.properties

+ 6 - 0
pom.xml

@@ -72,6 +72,12 @@
       <version>4.11</version>
       <scope>test</scope>
     </dependency>
+    <!-- xxl-sso-core -->
+    <dependency>
+      <groupId>com.xuxueli</groupId>
+      <artifactId>xxl-sso-core</artifactId>
+      <version>1.1.0</version>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

+ 59 - 0
src/main/java/com/mokamrp/privates/config/XxlSsoConfig.java

@@ -0,0 +1,59 @@
+package com.mokamrp.privates.config;
+
+import com.xxl.sso.core.conf.Conf;
+import com.xxl.sso.core.filter.XxlSsoWebFilter;
+import com.xxl.sso.core.util.JedisUtil;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author xuxueli 2018-11-15
+ */
+@Configuration
+public class XxlSsoConfig implements DisposableBean {
+
+
+    @Value("${xxl.sso.server}")
+    private String xxlSsoServer;
+
+    @Value("${xxl.sso.logout.path}")
+    private String xxlSsoLogoutPath;
+
+    @Value("${xxl-sso.excluded.paths}")
+    private String xxlSsoExcludedPaths;
+
+    @Value("${xxl.sso.redis.address}")
+    private String xxlSsoRedisAddress;
+
+
+    @Bean
+    public FilterRegistrationBean xxlSsoFilterRegistration() {
+
+        // xxl-sso, redis init
+        JedisUtil.init(xxlSsoRedisAddress);
+
+        // xxl-sso, filter init
+        FilterRegistrationBean registration = new FilterRegistrationBean();
+
+        registration.setName("XxlSsoWebFilter");
+        registration.setOrder(1);
+        registration.addUrlPatterns("/*");
+        registration.setFilter(new XxlSsoWebFilter());
+        registration.addInitParameter(Conf.SSO_SERVER, xxlSsoServer);
+        registration.addInitParameter(Conf.SSO_LOGOUT_PATH, xxlSsoLogoutPath);
+        registration.addInitParameter(Conf.SSO_EXCLUDED_PATHS, xxlSsoExcludedPaths);
+
+        return registration;
+    }
+
+    @Override
+    public void destroy() throws Exception {
+
+        // xxl-sso, redis close
+        JedisUtil.close();
+    }
+
+}

+ 6 - 0
src/main/resources/application.properties

@@ -12,3 +12,9 @@ spring.datasource.min-idle=5
 spring.datasource.initial-size=5
 
 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+
+
+xxl.sso.server=http://localhost:8888/sso
+xxl.sso.logout.path=/logout
+xxl-sso.excluded.paths=
+xxl.sso.redis.address=redis://xxl-sso:Jch9shshl@r-uf633f3f27aa2174pd.redis.rds.aliyuncs.com:6379/0