update to v4.5.0

This commit is contained in:
zlt2000
2021-05-24 06:43:03 +08:00
parent 26770b79d9
commit 93918ec4e9
61 changed files with 69 additions and 64 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>4.4</version>
<version>4.5.0</version>
</parent>
<artifactId>zlt-uaa</artifactId>
<description>认证中心</description>
@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
@@ -52,10 +53,14 @@ public class TokensController {
@GetMapping("/key")
@ApiOperation(value = "获取jwt密钥")
public Result<String> key(HttpServletRequest request) {
String[] clientArr = AuthUtils.extractClient(request);
ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientArr[0]);
if (!passwordEncoder.matches(clientArr[1], clientDetails.getClientSecret())) {
throw new BadCredentialsException("应用密码错误");
try {
String[] clientArr = AuthUtils.extractClient(request);
ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientArr[0]);
if (clientDetails == null || !passwordEncoder.matches(clientArr[1], clientDetails.getClientSecret())) {
throw new BadCredentialsException("应用ID或密码错误");
}
} catch (AuthenticationException ae) {
return Result.failed(ae.getMessage());
}
org.springframework.core.io.Resource res = new ClassPathResource(SecurityConstants.RSA_PUBLIC_KEY);
try (BufferedReader br = new BufferedReader(new InputStreamReader(res.getInputStream()))) {