Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yujianwangzivayy
MaxKey
提交
a02822d0
MaxKey
项目概览
yujianwangzivayy
/
MaxKey
与 Fork 源项目一致
Fork自
MaxKey单点登录官方(MaxKeyTop) / MaxKey
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a02822d0
编写于
4月 22, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve
上级
0f7189c5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
8 addition
and
12 deletion
+8
-12
maxkey-authentications/maxkey-authentication-captcha/src/main/java/org/maxkey/web/contorller/ImageCaptchaEndpoint.java
.../java/org/maxkey/web/contorller/ImageCaptchaEndpoint.java
+4
-7
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/provider/NormalAuthenticationProvider.java
...g/maxkey/authn/provider/NormalAuthenticationProvider.java
+4
-5
未找到文件。
maxkey-authentications/maxkey-authentication-captcha/src/main/java/org/maxkey/web/contorller/ImageCaptchaEndpoint.java
浏览文件 @
a02822d0
...
...
@@ -18,8 +18,6 @@
package
org.maxkey.web.contorller
;
import
com.google.code.kaptcha.Producer
;
import
com.nimbusds.jwt.JWTClaimsSet
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.util.Base64
;
...
...
@@ -30,7 +28,6 @@ import org.apache.commons.lang3.StringUtils;
import
org.maxkey.authn.jwt.AuthJwtService
;
import
org.maxkey.entity.Message
;
import
org.maxkey.persistence.MomentaryService
;
import
org.maxkey.web.WebContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -87,11 +84,11 @@ public class ImageCaptchaEndpoint {
if
(
StringUtils
.
isNotBlank
(
state
)
&&
!
state
.
equalsIgnoreCase
(
"state"
)
&&
authJwtService
.
validateJwtToken
(
state
))
{
JWTClaimsSet
claim
=
authJwtService
.
resolve
(
state
);
kaptchaKey
=
claim
.
getJWTID
();
//do nothing
}
else
{
kaptchaKey
=
WebContext
.
genId
();
state
=
authJwtService
.
genJwt
();
}
kaptchaKey
=
authJwtService
.
resolveTicket
(
state
);
_logger
.
trace
(
"kaptchaKey {} , Captcha Text is {}"
,
kaptchaKey
,
kaptchaValue
);
momentaryService
.
put
(
""
,
kaptchaKey
,
kaptchaValue
);
...
...
@@ -108,7 +105,7 @@ public class ImageCaptchaEndpoint {
stream
.
close
();
return
new
Message
<
ImageCaptcha
>(
new
ImageCaptcha
(
kaptchaKey
,
b64Image
)
new
ImageCaptcha
(
state
,
b64Image
)
).
buildResponse
();
}
catch
(
Exception
e
)
{
_logger
.
error
(
"captcha Producer Error "
+
e
.
getMessage
());
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/provider/NormalAuthenticationProvider.java
浏览文件 @
a02822d0
...
...
@@ -37,8 +37,6 @@ import org.springframework.security.authentication.BadCredentialsException;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.AuthenticationException
;
import
com.nimbusds.jwt.JWTClaimsSet
;
/**
* database Authentication provider.
...
...
@@ -136,16 +134,17 @@ public class NormalAuthenticationProvider extends AbstractAuthenticationProvider
*/
protected
void
captchaValid
(
String
state
,
String
captcha
)
throws
ParseException
{
// for basic
JWTClaimsSet
claim
=
authJwtService
.
resolve
(
state
);
if
(
claim
==
null
)
{
String
ticket
=
authJwtService
.
resolveTicket
(
state
);
if
(
ticket
==
null
)
{
throw
new
BadCredentialsException
(
WebContext
.
getI18nValue
(
"login.error.captcha"
));
}
Object
momentaryCaptcha
=
momentaryService
.
get
(
""
,
claim
.
getJWTID
()
);
Object
momentaryCaptcha
=
momentaryService
.
get
(
""
,
ticket
);
_logger
.
info
(
"captcha : {} , momentary Captcha : {} "
,
captcha
,
momentaryCaptcha
);
if
(
StringUtils
.
isBlank
(
captcha
)
||
!
captcha
.
equals
(
momentaryCaptcha
.
toString
()))
{
_logger
.
debug
(
"login captcha valid error."
);
throw
new
BadCredentialsException
(
WebContext
.
getI18nValue
(
"login.error.captcha"
));
}
momentaryService
.
remove
(
""
,
ticket
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录