Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
JAVA小学生-王铁柱
eladmin
提交
98f2db21
E
eladmin
项目概览
JAVA小学生-王铁柱
/
eladmin
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
eladmin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
98f2db21
编写于
12月 01, 2019
作者:
D
dqjdda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前端rsa公钥加密传输登录密码,后端rsa私钥解密密码
上级
284c25a1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
2 deletion
+13
-2
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthController.java
...ava/me/zhengjie/modules/security/rest/AuthController.java
+8
-1
eladmin-system/src/main/resources/config/application.yml
eladmin-system/src/main/resources/config/application.yml
+5
-1
未找到文件。
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthController.java
浏览文件 @
98f2db21
package
me.zhengjie.modules.security.rest
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.crypto.asymmetric.KeyType
;
import
cn.hutool.crypto.asymmetric.RSA
;
import
com.wf.captcha.ArithmeticCaptcha
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -44,6 +46,8 @@ public class AuthController {
@Value
(
"${loginCode.expiration}"
)
private
Long
expiration
;
@Value
(
"${rsa.private_key}"
)
private
String
privateKey
;
private
final
SecurityProperties
properties
;
private
final
RedisUtils
redisUtils
;
private
final
UserDetailsService
userDetailsService
;
...
...
@@ -65,6 +69,9 @@ public class AuthController {
@AnonymousAccess
@PostMapping
(
value
=
"/login"
)
public
ResponseEntity
login
(
@Validated
@RequestBody
AuthUser
authUser
,
HttpServletRequest
request
){
// 密码解密
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
String
password
=
new
String
(
rsa
.
decrypt
(
authUser
.
getPassword
(),
KeyType
.
PrivateKey
));
// 查询验证码
String
code
=
(
String
)
redisUtils
.
get
(
authUser
.
getUuid
());
// 清除验证码
...
...
@@ -76,7 +83,7 @@ public class AuthController {
throw
new
BadRequestException
(
"验证码错误"
);
}
UsernamePasswordAuthenticationToken
authenticationToken
=
new
UsernamePasswordAuthenticationToken
(
authUser
.
getUsername
(),
authUser
.
getPassword
()
);
new
UsernamePasswordAuthenticationToken
(
authUser
.
getUsername
(),
password
);
Authentication
authentication
=
authenticationManagerBuilder
.
getObject
().
authenticate
(
authenticationToken
);
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
...
...
eladmin-system/src/main/resources/config/application.yml
浏览文件 @
98f2db21
...
...
@@ -51,4 +51,8 @@ code:
#登录图形验证码有效时间/分钟
loginCode
:
expiration
:
2
\ No newline at end of file
expiration
:
2
#密码加密传输,前端公钥加密,后端私钥解密
rsa
:
private_key
:
MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录