提交 e1510165 编写于 作者: pig_冷冷's avatar pig_冷冷

🔖 Releasing / Version tags. 2.7.1

上级 5a35db49
[pigx 相关问题请去此提,码云忽略](https://git.pig4cloud.com/pig/pigx/issues)
### 版本信息
- pig版本:
- 是否修改包名:
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-auth</artifactId>
......@@ -46,13 +46,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-upms-api</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--security-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-security</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--JDBC相关-->
<dependency>
......
......@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-codegen</artifactId>
......@@ -37,7 +37,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-swagger</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--注册中心客户端-->
<dependency>
......@@ -53,30 +53,30 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-datasource</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-mybatis</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--common-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-core</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--日志处理-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-log</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-security</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--代码生成模板引擎-->
<dependency>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-common-core</artifactId>
......
......@@ -23,7 +23,7 @@
<parent>
<artifactId>pig-common</artifactId>
<groupId>com.pig4cloud</groupId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-common-log</artifactId>
......@@ -37,13 +37,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-core</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--UPMS接口模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-upms-api</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--安全依赖获取上下文信息-->
<dependency>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-common-mybatis</artifactId>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-common-security</artifactId>
......@@ -37,7 +37,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-core</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--安全模块-->
<dependency>
......@@ -52,7 +52,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-upms-api</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
</dependencies>
</project>
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-common-swagger</artifactId>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-common</artifactId>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-gateway</artifactId>
......@@ -61,7 +61,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-core</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--接口文档-->
<dependency>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-monitor</artifactId>
......
......@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-register</artifactId>
......
......@@ -75,9 +75,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) {
String ignoreURLs = env.getProperty("nacos.security.ignore.urls", "/**");
for (String ignoreURL : ignoreURLs.trim().split(SECURITY_IGNORE_URLS_SPILT_CHAR)) {
web.ignoring().antMatchers(ignoreURL.trim());
String ignoreUrls = env.getProperty("nacos.security.ignore.urls", "/**");
for (String url : ignoreUrls.trim().split(SECURITY_IGNORE_URLS_SPILT_CHAR)) {
web.ignoring().antMatchers(url.trim());
}
}
......
......@@ -38,102 +38,90 @@ import java.util.List;
@Component
public class JwtTokenUtils {
private final Logger log = LoggerFactory.getLogger(JwtTokenUtils.class);
private static final String AUTHORITIES_KEY = "auth";
/**
* secret key
*/
private String secretKey;
/**
* Token validity time(ms)
*/
private long tokenValidityInMilliseconds;
@PostConstruct
public void init() {
this.secretKey = "SecretKey012345678901234567890123456789012345678901234567890123456789";
this.tokenValidityInMilliseconds = 1000 * 60 * 30L;
}
/**
* Create token
*
* @param authentication auth info
* @return token
*/
public String createToken(Authentication authentication) {
/**
* Current time
*/
long now = (new Date()).getTime();
/**
* Validity date
*/
Date validity;
validity = new Date(now + this.tokenValidityInMilliseconds);
/**
* create token
*/
return Jwts.builder()
.setSubject(authentication.getName())
.claim(AUTHORITIES_KEY, "")
.setExpiration(validity)
.signWith(SignatureAlgorithm.HS256, secretKey)
.compact();
}
/**
* Get auth Info
*
* @param token token
* @return auth info
*/
public Authentication getAuthentication(String token) {
/**
* parse the payload of token
*/
Claims claims = Jwts.parser()
.setSigningKey(secretKey)
.parseClaimsJws(token)
.getBody();
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
User principal = new User(claims.getSubject(), "", authorities);
return new UsernamePasswordAuthenticationToken(principal, "", authorities);
}
/**
* validate token
*
* @param token token
* @return whether valid
*/
public boolean validateToken(String token) {
try {
Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
return true;
} catch (SignatureException e) {
log.info("Invalid JWT signature.");
log.trace("Invalid JWT signature trace: {}", e);
} catch (MalformedJwtException e) {
log.info("Invalid JWT token.");
log.trace("Invalid JWT token trace: {}", e);
} catch (ExpiredJwtException e) {
log.info("Expired JWT token.");
log.trace("Expired JWT token trace: {}", e);
} catch (UnsupportedJwtException e) {
log.info("Unsupported JWT token.");
log.trace("Unsupported JWT token trace: {}", e);
} catch (IllegalArgumentException e) {
log.info("JWT token compact of handler are invalid.");
log.trace("JWT token compact of handler are invalid trace: {}", e);
}
return false;
}
private final Logger log = LoggerFactory.getLogger(JwtTokenUtils.class);
private static final String AUTHORITIES_KEY = "auth";
/**
* secret key
*/
private String secretKey;
/**
* Token validity time(ms)
*/
private long tokenValidityInMilliseconds;
@PostConstruct
public void init() {
this.secretKey = "SecretKey012345678901234567890123456789012345678901234567890123456789";
this.tokenValidityInMilliseconds = 1000 * 60 * 30L;
}
/**
* Create token
*
* @param authentication auth info
* @return token
*/
public String createToken(Authentication authentication) {
/**
* Current time
*/
long now = (new Date()).getTime();
/**
* Validity date
*/
Date validity;
validity = new Date(now + this.tokenValidityInMilliseconds);
/**
* create token
*/
return Jwts.builder()
.setSubject(authentication.getName())
.claim(AUTHORITIES_KEY, "")
.setExpiration(validity)
.signWith(SignatureAlgorithm.HS256, secretKey)
.compact();
}
/**
* Get auth Info
*
* @param token token
* @return auth info
*/
public Authentication getAuthentication(String token) {
/**
* parse the payload of token
*/
Claims claims = Jwts.parser()
.setSigningKey(secretKey)
.parseClaimsJws(token)
.getBody();
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
User principal = new User(claims.getSubject(), "", authorities);
return new UsernamePasswordAuthenticationToken(principal, "", authorities);
}
/**
* validate token
*
* @param token token
* @return whether valid
*/
public boolean validateToken(String token) {
try {
Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
return true;
} catch (Exception e) {
log.info("Invalid JWT signature.");
log.trace("Invalid JWT signature trace: {}", e);
}
return false;
}
}
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-upms</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-upms-api</artifactId>
......@@ -37,7 +37,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-core</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
</dependencies>
</project>
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-upms</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-upms-biz</artifactId>
......@@ -36,31 +36,31 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-upms-api</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-security</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--日志处理-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-log</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--接口文档-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-swagger</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--mybatis 模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-mybatis</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</dependency>
<!--注册中心客户端-->
<dependency>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
</parent>
<artifactId>pig-upms</artifactId>
......
......@@ -29,7 +29,7 @@
<groupId>com.pig4cloud</groupId>
<artifactId>pig</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
<name>${project.artifactId}</name>
<packaging>pom</packaging>
<url>https://www.pig4cloud.com</url>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册