Browse Source

低代码管理

master
陈裕财 2 years ago
parent
commit
4db0533e04
  1. 4
      mdp-lcode-bootstrap/pom.xml
  2. 49
      mdp-lcode-bootstrap/src/main/java/com/mdp/WebSecurityConfig.java
  3. 6
      mdp-lcode-bootstrap/src/main/resources/application-prod.yml
  4. 5
      mdp-lcode/pom.xml
  5. 6
      mdp-lcode/src/main/resources/application-dev.yml
  6. 41
      mdp-lcode/src/test/java/com/mdp/WebSecurityConfig.java

4
mdp-lcode-bootstrap/pom.xml

@ -26,10 +26,6 @@
<groupId>com.mdp</groupId> <groupId>com.mdp</groupId>
<artifactId>mdp-lcode</artifactId> <artifactId>mdp-lcode</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.mdp</groupId>
<artifactId>mdp-sys</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

49
mdp-lcode-bootstrap/src/main/java/com/mdp/WebSecurityConfig.java

@ -1,29 +1,22 @@
package com.mdp; package com.mdp;
import com.mdp.safe.client.jwt.JwtAuthenticationConverter; import com.mdp.safe.client.jwt.JwtAuthenticationConverter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.security.oauth2.jwt.JwtDecoder;
/**
* com.qqkj.WebSecurityConfig
*
* @author chenyc
* @date 2019/10/10
*/
@EnableWebSecurity @EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
JwtDecoder jwtDecoder;
@Autowired @Autowired
JwtAuthenticationConverter jwtConverter; JwtAuthenticationConverter jwtConverter;
@Autowired
JwtDecoder jwtDecoder;
@Override @Override
public void configure(WebSecurity web) throws Exception { public void configure(WebSecurity web) throws Exception {
@ -37,13 +30,37 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
*/ */
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().oauth2Client().and().logout().disable();
http.formLogin().usernameParameter("userloginid");
http.authorizeRequests().antMatchers("/actuator/**","/**/safe/app/auth**",
"/**/sys/userTpaInvite/checkInviteId",
"/**/sys/user/addUserNoAuth",
"/**/sys/user/noauth/detail",
"/**/sys/userFans/fansCpd",
"/**/sys/userSvr/list",
"/**/sys/user/crowd/list",
"/**/sys/branch/add",
"/**/sys/branch/list",
"/**/sys/branch/listBranchNoAuth",
"/**/sys/branch/addBranchNoAuth",
"/**/sys/dept/listDeptAndChidlDeptByBranchIdNoAuth",
"/**/sys/dept/addDeptNoAuth",
"/**/sys/userDept/batchEditNoauth",
"/**/list/byItemCode",
"/**/list/byItemIds",
"/**/sys/userTpa/list",
"/app/appTpAuth/list",
"/**/menuModuleBranch/list",
"/**/item/dicts",
"/**/list/sysParam",
"/swagger-ui.html",
"/webjars/**",
"/swagger-ui/**",
"/swagger-resources/**",
"/v2/*",
"/csrf",
"/").permitAll().anyRequest().authenticated();
http.oauth2Client().and().logout().disable();
http.oauth2Login(); http.oauth2Login();
http.oauth2ResourceServer().jwt().jwtAuthenticationConverter(jwtConverter);
http.csrf().disable();
http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter); http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter);
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);//禁用session
http.csrf().disable();
} }
} }

6
mdp-lcode-bootstrap/src/main/resources/application-prod.yml

@ -205,7 +205,7 @@ spring:
#password: zchcgl123!@# #password: zchcgl123!@#
#driver-class-name: com.mysql.cj.jdbc.Driver #driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.207.117.5:3306/lcode?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
url: jdbc:mysql://123.207.117.5:3306/adm?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
username: root username: root
password: 1qaz@WSX password: 1qaz@WSX
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
@ -218,12 +218,12 @@ spring:
#password: root #password: root
#driver-class-name: com.mysql.cj.jdbc.Driver #driver-class-name: com.mysql.cj.jdbc.Driver
mem-ds: mem-ds:
url: jdbc:mysql://123.207.117.5:3306/lcode?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
url: jdbc:mysql://123.207.117.5:3306/adm?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
username: root username: root
password: 1qaz@WSX password: 1qaz@WSX
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
mall-ds: mall-ds:
url: jdbc:mysql://123.207.117.5:3306/lcode?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
url: jdbc:mysql://123.207.117.5:3306/adm?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
username: root username: root
password: 1qaz@WSX password: 1qaz@WSX
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver

5
mdp-lcode/pom.xml

@ -13,5 +13,10 @@
<version>2.0.0-RELEASE</version> <version>2.0.0-RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency>
<groupId>com.mdp</groupId>
<artifactId>mdp-sys</artifactId>
<version>2.0.0-RELEASE</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

6
mdp-lcode/src/main/resources/application-dev.yml

@ -202,7 +202,7 @@ spring:
#password: zchcgl123!@# #password: zchcgl123!@#
#driver-class-name: com.mysql.cj.jdbc.Driver #driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.207.117.5:3306/lcode?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
url: jdbc:mysql://123.207.117.5:3306/adm?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
username: root username: root
password: 1qaz@WSX password: 1qaz@WSX
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
@ -215,12 +215,12 @@ spring:
#password: root #password: root
#driver-class-name: com.mysql.cj.jdbc.Driver #driver-class-name: com.mysql.cj.jdbc.Driver
mem-ds: mem-ds:
url: jdbc:mysql://123.207.117.5:3306/lcode?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
url: jdbc:mysql://123.207.117.5:3306/adm?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
username: root username: root
password: 1qaz@WSX password: 1qaz@WSX
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
mall-ds: mall-ds:
url: jdbc:mysql://123.207.117.5:3306/lcode?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
url: jdbc:mysql://123.207.117.5:3306/adm?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=CTT
username: root username: root
password: 1qaz@WSX password: 1qaz@WSX
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver

41
mdp-lcode/src/test/java/com/mdp/WebSecurityConfig.java

@ -1,5 +1,6 @@
package com.mdp; package com.mdp;
import com.mdp.safe.client.jwt.JwtAuthenticationConverter; import com.mdp.safe.client.jwt.JwtAuthenticationConverter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@ -9,18 +10,11 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.security.oauth2.jwt.JwtDecoder;
/**
* com.qqkj.WebSecurityConfig
*
* @author chenyc
* @date 2019/10/10
*/
@EnableWebSecurity @EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
JwtAuthenticationConverter jwtConverter; JwtAuthenticationConverter jwtConverter;
@Autowired @Autowired
JwtDecoder jwtDecoder; JwtDecoder jwtDecoder;
@ -36,12 +30,37 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
*/ */
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().oauth2Client().and().logout().disable();
http.formLogin().usernameParameter("userloginid");
//http.oauth2Login();
http.authorizeRequests().antMatchers("/actuator/**","/**/safe/app/auth**",
"/**/sys/userTpaInvite/checkInviteId",
"/**/sys/user/noauth/detail",
"/**/sys/userFans/fansCpd",
"/**/sys/userSvr/list",
"/**/sys/user/crowd/list",
"/**/sys/branch/listBranchNoAuth",
"/**/sys/branch/add",
"/**/sys/branch/list",
"/**/sys/branch/listBranchNoAuth",
"/**/sys/branch/addBranchNoAuth",
"/**/sys/dept/listDeptAndChidlDeptByBranchIdNoAuth",
"/**/sys/dept/addDeptNoAuth",
"/**/sys/userDept/batchEditNoauth",
"/**/list/byItemCode",
"/**/list/byItemIds",
"/**/item/dicts",
"/**/list/sysParam","/druid/**",
"/swagger-ui.html",
"/webjars/**",
"/swagger-ui/**",
"/swagger-resources/**",
"/v2/*",
"/csrf",
"/"
).permitAll();
//http.oauth2Client().and().logout().disable();
// http.oauth2Login();
http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter); http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter);
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);//禁用session http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);//禁用session
http.csrf().disable(); http.csrf().disable();
} }
} }
Loading…
Cancel
Save