♻️ 重构代码。@EnablePigxResoureServer 一个注解接入OAuth
This commit is contained in:
1 parent
44ac88de6e
commit
584569ce3c
25 files changed
+151
-169
No files matched your search
@@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-visual</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
<version>1.7.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pigx-activiti</artifactId>
|
||||
@@ -32,16 +32,21 @@
|
||||
<description>工作流管理模块</description>
|
||||
|
||||
<dependencies>
|
||||
<!--配置中心客户端-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
<!--common code -->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-upms-api</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
@@ -106,7 +111,12 @@
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-swagger</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-security</artifactId>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
<!--undertow容器-->
|
||||
<dependency>
|
||||
|
||||
+4
-7
@@ -17,22 +17,19 @@
|
||||
|
||||
package com.pig4cloud.pigx.act;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer;
|
||||
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
|
||||
import org.activiti.spring.boot.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/9/25
|
||||
* 工作流管理模块
|
||||
*/
|
||||
@EnableCircuitBreaker
|
||||
@EnableDiscoveryClient
|
||||
@EnablePigxFeignClients
|
||||
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
|
||||
@EnablePigxResourceServer
|
||||
@SpringCloudApplication
|
||||
public class PigxActivitiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+2
-25
@@ -18,11 +18,7 @@
|
||||
package com.pig4cloud.pigx.act.config;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.component.BaseResourceServerConfigurerAdapter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
|
||||
|
||||
/**
|
||||
@@ -30,29 +26,10 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Res
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@AllArgsConstructor
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ResourceServerConfigurer extends BaseResourceServerConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.headers().frameOptions().disable()
|
||||
.and().authorizeRequests()
|
||||
.antMatchers("/actuator/**"
|
||||
, "/v2/api-docs"
|
||||
, "/service/**"
|
||||
, "/editor-app/**"
|
||||
,"/task/view/*"
|
||||
,"/process/resource/*/*/image"
|
||||
, "/modeler.html").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and().csrf().disable();
|
||||
}
|
||||
public class ResourceServerConfigurer extends BaseResourceServerConfigurerAdapter {
|
||||
|
||||
/**
|
||||
* 重写抽象类实现,不需要调用feign 获取 userdetils
|
||||
* 重写不需要调用feign 获取 userdetils
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
|
||||
@@ -4,22 +4,17 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: pigx-activiti
|
||||
#配置中心
|
||||
# 配置中心
|
||||
cloud:
|
||||
config:
|
||||
fail-fast: true
|
||||
name: ${spring.application.name}
|
||||
profile: dev
|
||||
profile: ${spring.profiles.active}
|
||||
discovery:
|
||||
enabled: true
|
||||
service-id: pigx-config
|
||||
datasource:
|
||||
url: jdbc:mysql://lengleng:3306/ac?characterEncoding=UTF-8&useSSL=false
|
||||
username: root
|
||||
password: 123456
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
activiti:
|
||||
check-process-definitions: false
|
||||
profiles:
|
||||
active: dev
|
||||
|
||||
# 注册中心配置
|
||||
eureka:
|
||||
@@ -29,20 +24,3 @@ eureka:
|
||||
service-url:
|
||||
defaultZone: http://pig:pig@lengleng:1025/eureka/
|
||||
|
||||
## spring security 配置
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)
|
||||
client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)
|
||||
scope: server
|
||||
resource:
|
||||
token-info-uri: ${security.auth.server}/check_token
|
||||
auth:
|
||||
server: http://lengleng:9999/auth/oauth
|
||||
|
||||
# 加解密根密码
|
||||
jasypt:
|
||||
encryptor:
|
||||
password: pigx #根密码
|
||||
# redis 相关
|
||||
+2
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.codegen;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer;
|
||||
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
|
||||
import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
|
||||
@EnablePigxSwagger2
|
||||
@SpringCloudApplication
|
||||
@EnablePigxFeignClients
|
||||
@EnablePigxResourceServer
|
||||
public class PigxCodeGenApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+1
-17
@@ -18,11 +18,7 @@
|
||||
package com.pig4cloud.pigx.codegen.config;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.component.BaseResourceServerConfigurerAdapter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
|
||||
|
||||
/**
|
||||
@@ -30,21 +26,9 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Res
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@AllArgsConstructor
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ResourceServerConfigurer extends BaseResourceServerConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/actuator/**", "/v2/api-docs").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and().csrf().disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写抽象类实现,不需要调用feign 获取 userDetailsService
|
||||
* 重写实现,不需要调用feign 获取 userDetailsService
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
|
||||
+4
@@ -18,6 +18,8 @@
|
||||
package com.pig4cloud.pigx.daemon;
|
||||
|
||||
import com.pig4cloud.pigx.common.job.annotation.EnablePigxJob;
|
||||
import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer;
|
||||
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
|
||||
@@ -27,7 +29,9 @@ import org.springframework.cloud.client.SpringCloudApplication;
|
||||
* 分布式任务调度模块
|
||||
*/
|
||||
@EnablePigxJob
|
||||
@EnablePigxFeignClients
|
||||
@SpringCloudApplication
|
||||
@EnablePigxResourceServer
|
||||
public class PigxDaemonApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+1
-17
@@ -18,11 +18,7 @@
|
||||
package com.pig4cloud.pigx.daemon.config;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.component.BaseResourceServerConfigurerAdapter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
|
||||
|
||||
/**
|
||||
@@ -30,21 +26,9 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Res
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@AllArgsConstructor
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ResourceServerConfigurer extends BaseResourceServerConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/actuator/**", "/v2/api-docs").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and().csrf().disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写抽象类实现,不需要调用feign 获取 userdetils
|
||||
* 重写实现,不需要调用feign 获取 userdetils
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 5002
|
||||
port: 5001
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
||||
Reference in new issue
Block a user