mirror of https://gitee.com/topiam/eiam
Merge remote-tracking branch 'origin/master'
# Conflicts: # eiam-protocol/eiam-protocol-jwt/src/main/java/cn/topiam/employee/protocol/jwt/token/JwtUtils.javapull/65/head
commit
bcb48a7520
|
@ -59,7 +59,7 @@
|
|||
"dayjs": "^1.11.10",
|
||||
"echarts": "^5.4.3",
|
||||
"fetch-jsonp": "^1.3.0",
|
||||
"form-render": "^2.2.16",
|
||||
"form-render": "^2.2.19",
|
||||
"google-libphonenumber": "^3.2.33",
|
||||
"js-base64": "^3.7.5",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
@ -71,7 +71,7 @@
|
|||
"qs": "^6.11.2",
|
||||
"query-string": "^8.1.0",
|
||||
"rc-field-form": "^1.38.2",
|
||||
"rc-menu": "^9.12.0",
|
||||
"rc-menu": "^9.12.2",
|
||||
"rc-select": "^14.9.0",
|
||||
"rc-tree": "^5.7.12",
|
||||
"react": "^18.2.0",
|
||||
|
@ -93,13 +93,13 @@
|
|||
"@types/numeral": "^2.0.3",
|
||||
"@types/qs": "^6.9.8",
|
||||
"@types/react": "^18.2.25",
|
||||
"@types/react-dom": "^18.2.10",
|
||||
"@types/react-dom": "^18.2.11",
|
||||
"@types/react-helmet": "^6.1.7",
|
||||
"@umijs/lint": "^4.0.83",
|
||||
"@umijs/max": "^4.0.83",
|
||||
"cross-env": "^7.0.3",
|
||||
"cross-port-killer": "^1.4.0",
|
||||
"eslint": "^8.50.0",
|
||||
"eslint": "^8.51.0",
|
||||
"husky": "^8.0.3",
|
||||
"lint-staged": "^14.0.1",
|
||||
"prettier": "^3.0.3",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* eiam-portal - Employee Identity and Access Management
|
||||
* eiam-console - Employee Identity and Access Management
|
||||
* Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
@ -68,8 +68,6 @@ import cn.topiam.employee.support.security.authentication.WebAuthenticationDetai
|
|||
import cn.topiam.employee.support.security.csrf.SpaCsrfTokenRequestHandler;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import static cn.topiam.employee.common.constant.SynchronizerConstants.EVENT_RECEIVE_PATH;
|
||||
import static org.springframework.security.config.Customizer.withDefaults;
|
||||
import static org.springframework.security.web.header.writers.XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK;
|
||||
import static org.springframework.web.cors.CorsConfiguration.ALL;
|
||||
|
@ -78,6 +76,7 @@ import static cn.topiam.employee.common.constant.AuthorizeConstants.FE_LOGIN;
|
|||
import static cn.topiam.employee.common.constant.AuthorizeConstants.FORM_LOGIN;
|
||||
import static cn.topiam.employee.common.constant.ConfigBeanNameConstants.DEFAULT_SECURITY_FILTER_CHAIN;
|
||||
import static cn.topiam.employee.common.constant.SessionConstants.CURRENT_STATUS;
|
||||
import static cn.topiam.employee.common.constant.SynchronizerConstants.EVENT_RECEIVE_PATH;
|
||||
import static cn.topiam.employee.core.endpoint.security.PublicSecretEndpoint.PUBLIC_SECRET_PATH;
|
||||
import static cn.topiam.employee.core.setting.constant.SecuritySettingConstants.*;
|
||||
import static cn.topiam.employee.protocol.code.util.ProtocolConfigUtils.getAuthenticationDetailsSource;
|
||||
|
|
|
@ -20,14 +20,11 @@ package cn.topiam.employee.console.pojo.update.user;
|
|||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.topiam.employee.common.enums.MessageNoticeChannel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 更改密码入参
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.topiam.employee.support.security.password.exception.PasswordInvalidException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -58,8 +57,6 @@ import cn.topiam.employee.support.security.util.SecurityUtils;
|
|||
import cn.topiam.employee.support.util.BeanUtils;
|
||||
import cn.topiam.employee.support.util.PhoneNumberUtils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import static cn.topiam.employee.core.message.sms.SmsMsgEventPublish.USERNAME;
|
||||
import static cn.topiam.employee.support.constant.EiamConstants.FORGET_PASSWORD_TOKEN_ID;
|
||||
|
|
|
@ -88,13 +88,13 @@
|
|||
"@types/numeral": "^2.0.3",
|
||||
"@types/qs": "^6.9.8",
|
||||
"@types/react": "^18.2.25",
|
||||
"@types/react-dom": "^18.2.10",
|
||||
"@types/react-dom": "^18.2.11",
|
||||
"@types/react-helmet": "^6.1.7",
|
||||
"@umijs/lint": "^4.0.83",
|
||||
"@umijs/max": "^4.0.83",
|
||||
"cross-env": "^7.0.3",
|
||||
"cross-port-killer": "^1.4.0",
|
||||
"eslint": "^8.50.0",
|
||||
"eslint": "^8.51.0",
|
||||
"husky": "^8.0.3",
|
||||
"lint-staged": "^14.0.1",
|
||||
"prettier": "^3.0.3",
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* eiam-protocol-jwt - Employee Identity and Access Management
|
||||
* Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cn.topiam.employee.protocol.jwt.token;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import cn.topiam.employee.common.util.X509Utils;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import io.jsonwebtoken.*;
|
||||
|
||||
/**
|
||||
* JWT 工具类
|
||||
*
|
||||
* @author TopIAM
|
||||
* Created by support@topiam.cn on 2023/02/12 21:58
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class JwtUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class);
|
||||
|
||||
/**
|
||||
* parserToken
|
||||
*
|
||||
* @param token {@link String}
|
||||
* @param publicKey {@link String}
|
||||
* @return {@link Claims}
|
||||
*/
|
||||
public static Claims parserToken(String token, String publicKey) {
|
||||
try {
|
||||
PublicKey readPublicKey = X509Utils.readPublicKey(publicKey, "");
|
||||
JwtParser jwtParser = Jwts.parser().verifyWith(readPublicKey).build();
|
||||
// 解析 JWT
|
||||
return jwtParser.parseSignedClaims(token).getPayload();
|
||||
} catch (io.jsonwebtoken.security.SecurityException | MalformedJwtException e) {
|
||||
logger.info("Invalid JWT signature.");
|
||||
logger.trace("Invalid JWT signature trace: {}", e.getMessage());
|
||||
throw e;
|
||||
} catch (ExpiredJwtException e) {
|
||||
logger.info("Expired JWT token.");
|
||||
logger.trace("Expired JWT token trace: {}", e.getMessage());
|
||||
throw e;
|
||||
} catch (UnsupportedJwtException e) {
|
||||
logger.info("Unsupported JWT token.");
|
||||
logger.trace("Unsupported JWT token trace: {}", e.getMessage());
|
||||
throw e;
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.info("JWT token compact of handler are invalid.");
|
||||
logger.trace("JWT token compact of handler are invalid trace: {}", e.getMessage());
|
||||
throw e;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue