Browse Source

kisso配置

mgr-gxzc 7 years ago
parent
commit
2a91270a50

+ 1 - 0
zen-umps/build.gradle

@@ -1,3 +1,4 @@
 dependencies {
     compile project(":zen-core")
+    compile project(":zen-api")
 }

+ 19 - 0
zen-umps/src/main/kotlin/com/gxzc/zen/ump/KissoAuthorization.kt

@@ -0,0 +1,19 @@
+package com.gxzc.zen.ump
+
+import com.baomidou.kisso.SSOAuthorization
+import com.baomidou.kisso.security.token.SSOToken
+import com.gxzc.zen.api.sys.service.ISysRolePermissionService
+import com.gxzc.zen.api.sys.service.ISysRoleService
+import com.gxzc.zen.api.sys.service.ISysUserService
+import com.gxzc.zen.common.util.SpringContextHolder
+
+class KissoAuthorization:SSOAuthorization {
+
+    private val userService=SpringContextHolder.getBean(ISysUserService::class.java)
+    private val roleService=SpringContextHolder.getBean(ISysRoleService::class.java)
+    private val rolePermissionService=SpringContextHolder.getBean(ISysRolePermissionService::class.java)
+
+    override fun isPermitted(token: SSOToken?, permission: String?): Boolean {
+        return false
+    }
+}

+ 27 - 0
zen-umps/src/main/kotlin/com/gxzc/zen/ump/KissoWebAppConfigurer.kt

@@ -0,0 +1,27 @@
+package com.gxzc.zen.ump
+
+import com.baomidou.kisso.web.interceptor.SSOPermissionInterceptor
+import com.baomidou.kisso.web.interceptor.SSOSpringInterceptor
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
+
+@Configuration
+class KissoWebAppConfigurer: WebMvcConfigurerAdapter() {
+
+    /*@Bean("KissoInit")
+    fun initKisso(){
+        return com.baomidou.kisso.web.WebKissoConfigurer()
+    }*/
+
+    override fun addInterceptors(registry: InterceptorRegistry) {
+        //登录拦截
+        registry.addInterceptor(SSOSpringInterceptor())
+                .addPathPatterns("/**")
+        //权限拦截
+        registry.addInterceptor(SSOPermissionInterceptor().also { it.authorization=KissoAuthorization() })
+                .addPathPatterns("/**")
+        super.addInterceptors(registry)
+    }
+}

+ 1 - 1
zen-web/src/main/resources/application.yml

@@ -6,7 +6,7 @@ server:
 spring:
   profiles:
     active: dev
-    include: orm-local,mq,cache
+    include: orm-local,mq,cache,umps
 #  redis:
 #    host: localhost
 #    port: 6379