Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
long-tern-care-service
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hubin
long-tern-care-service
Commits
d7fa84c9
Commit
d7fa84c9
authored
Feb 08, 2023
by
maqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RSA密码加密
parent
9da726ae
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
7 deletions
+15
-7
AuthController.java
...main/java/com/hungraim/ltc/controller/AuthController.java
+12
-4
WebSecurityConfig.java
...va/com/hungraim/ltc/gateway/config/WebSecurityConfig.java
+1
-1
CsoftSecurityUtil.java
...rc/main/java/com/hungraim/ltc/util/CsoftSecurityUtil.java
+1
-1
ResourceServerConfig.java
...com/hungraim/ltc/gateway/config/ResourceServerConfig.java
+1
-1
No files found.
auth-service/src/main/java/com/hungraim/ltc/controller/AuthController.java
View file @
d7fa84c9
...
@@ -25,14 +25,22 @@ public class AuthController {
...
@@ -25,14 +25,22 @@ public class AuthController {
@PostMapping
(
"/token"
)
@PostMapping
(
"/token"
)
@SneakyThrows
@SneakyThrows
public
Result
<
OAuth2AccessToken
>
postAccessToken
(
Principal
principal
,
@RequestParam
Map
<
String
,
String
>
parameters
)
{
public
Result
<
OAuth2AccessToken
>
postAccessToken
(
Principal
principal
,
@RequestParam
Map
<
String
,
String
>
parameters
)
{
//
String password = parameters.get("password");
String
password
=
parameters
.
get
(
"password"
);
//
String decrypt = CsoftSecurityUtil.decrypt(password);
String
decrypt
=
CsoftSecurityUtil
.
decrypt
(
password
);
//
parameters.put("password", decrypt);
parameters
.
put
(
"password"
,
decrypt
);
OAuth2AccessToken
oAuth2AccessToken
=
tokenEndpoint
.
postAccessToken
(
principal
,
parameters
).
getBody
();
OAuth2AccessToken
oAuth2AccessToken
=
tokenEndpoint
.
postAccessToken
(
principal
,
parameters
).
getBody
();
return
Result
.
success
(
oAuth2AccessToken
);
return
Result
.
success
(
oAuth2AccessToken
);
}
}
/**
* 获取公钥
* @return
*/
@GetMapping
(
"/genKeyPair"
)
public
Result
<
String
>
genKeyPair
()
{
Map
keyMap
=
CsoftSecurityUtil
.
genKeyPair
();
return
Result
.
success
(
keyMap
.
get
(
0
).
toString
());
}
...
...
auth-service/src/main/java/com/hungraim/ltc/gateway/config/WebSecurityConfig.java
View file @
d7fa84c9
...
@@ -33,7 +33,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -33,7 +33,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.
authorizeRequests
().
requestMatchers
(
EndpointRequest
.
toAnyEndpoint
()).
permitAll
()
.
authorizeRequests
().
requestMatchers
(
EndpointRequest
.
toAnyEndpoint
()).
permitAll
()
.
and
()
.
and
()
.
authorizeRequests
()
.
authorizeRequests
()
.
antMatchers
(
"/getPublicKey"
,
"/oauth/
logout"
,
"
/genKeyPair"
).
permitAll
()
.
antMatchers
(
"/getPublicKey"
,
"/oauth/
token"
,
"/genKeyPair"
,
"/oauth
/genKeyPair"
).
permitAll
()
.
anyRequest
().
authenticated
();
.
anyRequest
().
authenticated
();
}
}
...
...
common/common-core/src/main/java/com/hungraim/ltc/util/CsoftSecurityUtil.java
View file @
d7fa84c9
...
@@ -32,7 +32,7 @@ public class CsoftSecurityUtil {
...
@@ -32,7 +32,7 @@ public class CsoftSecurityUtil {
//生成公钥和私钥
//生成公钥和私钥
genKeyPair
();
genKeyPair
();
//加密字符串
//加密字符串
String
message
=
"
df723820
"
;
String
message
=
"
Hg123admin
"
;
System
.
out
.
println
(
"随机生成的公钥为:"
+
keyMap
.
get
(
0
));
System
.
out
.
println
(
"随机生成的公钥为:"
+
keyMap
.
get
(
0
));
System
.
out
.
println
(
"随机生成的私钥为:"
+
keyMap
.
get
(
1
));
System
.
out
.
println
(
"随机生成的私钥为:"
+
keyMap
.
get
(
1
));
String
messageEn
=
encrypt
(
message
,
keyMap
.
get
(
0
));
String
messageEn
=
encrypt
(
message
,
keyMap
.
get
(
0
));
...
...
gateway-service/src/main/java/com/hungraim/ltc/gateway/config/ResourceServerConfig.java
View file @
d7fa84c9
...
@@ -51,7 +51,7 @@ public class ResourceServerConfig {
...
@@ -51,7 +51,7 @@ public class ResourceServerConfig {
http
.
oauth2ResourceServer
().
jwt
()
http
.
oauth2ResourceServer
().
jwt
()
.
jwtAuthenticationConverter
(
jwtAuthenticationConverter
());
.
jwtAuthenticationConverter
(
jwtAuthenticationConverter
());
http
.
authorizeExchange
()
http
.
authorizeExchange
()
.
pathMatchers
(
"/api/oauth/token"
,
"/oauth/token"
).
permitAll
()
.
pathMatchers
(
"/api/oauth/token"
,
"/oauth/token"
,
"/oauth/genKeyPair"
,
"/api/oauth/genKeyPair"
).
permitAll
()
.
anyExchange
().
access
(
authorizationManager
)
.
anyExchange
().
access
(
authorizationManager
)
.
and
()
.
and
()
.
exceptionHandling
()
.
exceptionHandling
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment