Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
f4e36ad0
MaxKey
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
MaxKey
大约 1 年 前同步成功
通知
76
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f4e36ad0
编写于
1月 03, 2023
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
split maxkey-authentication-sms
上级
46a57a1a
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
229 addition
and
84 deletion
+229
-84
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/autoconfigure/OneTimePasswordAutoConfiguration.java
...axkey/autoconfigure/OneTimePasswordAutoConfiguration.java
+6
-8
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/MailOtpAuthnService.java
...a/org/maxkey/password/onetimepwd/MailOtpAuthnService.java
+85
-0
maxkey-authentications/maxkey-authentication-provider/build.gradle
...thentications/maxkey-authentication-provider/build.gradle
+1
-0
maxkey-authentications/maxkey-authentication-provider/src/main/java/org/maxkey/authn/provider/AbstractAuthenticationProvider.java
...maxkey/authn/provider/AbstractAuthenticationProvider.java
+2
-2
maxkey-authentications/maxkey-authentication-provider/src/main/java/org/maxkey/authn/provider/impl/MobileAuthenticationProvider.java
...key/authn/provider/impl/MobileAuthenticationProvider.java
+6
-4
maxkey-authentications/maxkey-authentication-provider/src/main/java/org/maxkey/autoconfigure/AuthnProviderAutoConfiguration.java
.../maxkey/autoconfigure/AuthnProviderAutoConfiguration.java
+3
-8
maxkey-authentications/maxkey-authentication-sms/build.gradle
...ey-authentications/maxkey-authentication-sms/build.gradle
+14
-0
maxkey-authentications/maxkey-authentication-sms/src/main/java/META-INF/MANIFEST.MF
...key-authentication-sms/src/main/java/META-INF/MANIFEST.MF
+3
-0
maxkey-authentications/maxkey-authentication-sms/src/main/java/org/maxkey/autoconfigure/SmsAutoConfiguration.java
...n/java/org/maxkey/autoconfigure/SmsAutoConfiguration.java
+63
-0
maxkey-authentications/maxkey-authentication-sms/src/main/java/org/maxkey/password/sms/SmsOtpAuthn.java
...ms/src/main/java/org/maxkey/password/sms/SmsOtpAuthn.java
+1
-1
maxkey-authentications/maxkey-authentication-sms/src/main/java/org/maxkey/password/sms/SmsOtpAuthnService.java
...main/java/org/maxkey/password/sms/SmsOtpAuthnService.java
+12
-36
maxkey-authentications/maxkey-authentication-sms/src/main/java/org/maxkey/password/sms/impl/SmsOtpAuthnAliyun.java
.../java/org/maxkey/password/sms/impl/SmsOtpAuthnAliyun.java
+2
-2
maxkey-authentications/maxkey-authentication-sms/src/main/java/org/maxkey/password/sms/impl/SmsOtpAuthnTencentCloud.java
...org/maxkey/password/sms/impl/SmsOtpAuthnTencentCloud.java
+2
-2
maxkey-authentications/maxkey-authentication-sms/src/main/java/org/maxkey/password/sms/impl/SmsOtpAuthnYunxin.java
.../java/org/maxkey/password/sms/impl/SmsOtpAuthnYunxin.java
+2
-2
maxkey-webs/maxkey-web-maxkey/build.gradle
maxkey-webs/maxkey-web-maxkey/build.gradle
+1
-0
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/autoconfigure/MaxKeyConfig.java
.../src/main/java/org/maxkey/autoconfigure/MaxKeyConfig.java
+2
-2
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java
...a/org/maxkey/web/contorller/ForgotPasswordContorller.java
+10
-8
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/LoginEntryPoint.java
.../main/java/org/maxkey/web/contorller/LoginEntryPoint.java
+6
-3
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/RegisterController.java
...in/java/org/maxkey/web/contorller/RegisterController.java
+4
-6
maxkey-webs/maxkey-web-maxkey/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
...ingframework.boot.autoconfigure.AutoConfiguration.imports
+1
-0
maxkey-webs/maxkey-web-mgt/build.gradle
maxkey-webs/maxkey-web-mgt/build.gradle
+1
-0
maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
...ingframework.boot.autoconfigure.AutoConfiguration.imports
+1
-0
settings.gradle
settings.gradle
+1
-0
未找到文件。
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/autoconfigure/OneTimePasswordAutoConfiguration.java
浏览文件 @
f4e36ad0
...
...
@@ -18,11 +18,10 @@
package
org.maxkey.autoconfigure
;
import
org.maxkey.constants.ConstsPersistence
;
import
org.maxkey.password.onetimepwd.OtpAuthnService
;
import
org.maxkey.password.onetimepwd.
Mail
OtpAuthnService
;
import
org.maxkey.password.onetimepwd.token.RedisOtpTokenStore
;
import
org.maxkey.persistence.redis.RedisConnectionFactory
;
import
org.maxkey.persistence.service.EmailSendersService
;
import
org.maxkey.persistence.service.SmsProviderService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.InitializingBean
;
...
...
@@ -37,21 +36,20 @@ public class OneTimePasswordAutoConfiguration implements InitializingBean {
LoggerFactory
.
getLogger
(
OneTimePasswordAutoConfiguration
.
class
);
@Bean
(
name
=
"
o
tpAuthnService"
)
public
OtpAuthnService
o
tpAuthnService
(
@Bean
(
name
=
"
mailO
tpAuthnService"
)
public
MailOtpAuthnService
mailO
tpAuthnService
(
@Value
(
"${maxkey.server.persistence}"
)
int
persistence
,
SmsProviderService
smsProviderService
,
EmailSendersService
emailSendersService
,
RedisConnectionFactory
redisConnFactory
)
{
OtpAuthnService
otpAuthnService
=
new
OtpAuthnService
(
smsProviderService
,
emailSendersService
);
Mail
OtpAuthnService
otpAuthnService
=
new
MailOtpAuthnService
(
emailSendersService
);
if
(
persistence
==
ConstsPersistence
.
REDIS
)
{
RedisOtpTokenStore
redisOptTokenStore
=
new
RedisOtpTokenStore
(
redisConnFactory
);
otpAuthnService
.
setRedisOptTokenStore
(
redisOptTokenStore
);
}
_logger
.
debug
(
"
OneTimePassword
Service {} inited."
,
_logger
.
debug
(
"
MailOtpAuthn
Service {} inited."
,
persistence
==
ConstsPersistence
.
REDIS
?
"Redis"
:
"InMemory"
);
return
otpAuthnService
;
}
...
...
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/MailOtpAuthnService.java
0 → 100644
浏览文件 @
f4e36ad0
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.maxkey.password.onetimepwd
;
import
java.sql.Types
;
import
java.util.concurrent.TimeUnit
;
import
org.maxkey.configuration.EmailConfig
;
import
org.maxkey.constants.ConstsBoolean
;
import
org.maxkey.crypto.password.PasswordReciprocal
;
import
org.maxkey.entity.EmailSenders
;
import
org.maxkey.password.onetimepwd.impl.MailOtpAuthn
;
import
org.maxkey.password.onetimepwd.token.RedisOtpTokenStore
;
import
org.maxkey.persistence.service.EmailSendersService
;
import
com.github.benmanes.caffeine.cache.Cache
;
import
com.github.benmanes.caffeine.cache.Caffeine
;
public
class
MailOtpAuthnService
{
protected
static
final
Cache
<
String
,
AbstractOtpAuthn
>
otpAuthnStore
=
Caffeine
.
newBuilder
()
.
expireAfterWrite
(
60
,
TimeUnit
.
MINUTES
)
.
build
();
EmailSendersService
emailSendersService
;
RedisOtpTokenStore
redisOptTokenStore
;
public
MailOtpAuthnService
(
EmailSendersService
emailSendersService
)
{
this
.
emailSendersService
=
emailSendersService
;
}
public
MailOtpAuthnService
(
RedisOtpTokenStore
redisOptTokenStore
)
{
this
.
redisOptTokenStore
=
redisOptTokenStore
;
}
public
AbstractOtpAuthn
getMailOtpAuthn
(
String
instId
)
{
AbstractOtpAuthn
otpAuthn
=
otpAuthnStore
.
getIfPresent
(
instId
);
if
(
otpAuthn
==
null
)
{
EmailSenders
emailSender
=
emailSendersService
.
findOne
(
"where instid = ? "
,
new
Object
[]{
instId
},
new
int
[]{
Types
.
VARCHAR
});
String
credentials
=
PasswordReciprocal
.
getInstance
().
decoder
(
emailSender
.
getCredentials
());
EmailConfig
emailConfig
=
new
EmailConfig
(
emailSender
.
getAccount
(),
credentials
,
emailSender
.
getSmtpHost
(),
emailSender
.
getPort
(),
ConstsBoolean
.
isTrue
(
emailSender
.
getSslSwitch
()),
emailSender
.
getSender
());
MailOtpAuthn
mailOtpAuthn
=
new
MailOtpAuthn
(
emailConfig
);
mailOtpAuthn
.
setInterval
(
60
*
5
);
//5 minute
if
(
redisOptTokenStore
!=
null
)
{
mailOtpAuthn
.
setOptTokenStore
(
redisOptTokenStore
);
}
otpAuthn
=
mailOtpAuthn
;
}
otpAuthnStore
.
put
(
instId
,
otpAuthn
);
return
otpAuthn
;
}
public
void
setRedisOptTokenStore
(
RedisOtpTokenStore
redisOptTokenStore
)
{
this
.
redisOptTokenStore
=
redisOptTokenStore
;
}
}
maxkey-authentications/maxkey-authentication-provider/build.gradle
浏览文件 @
f4e36ad0
...
...
@@ -11,5 +11,6 @@ dependencies {
implementation
project
(
":maxkey-persistence"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-core"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-otp"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-sms"
)
}
\ No newline at end of file
maxkey-authentications/maxkey-authentication-provider/src/main/java/org/maxkey/authn/provider/AbstractAuthenticationProvider.java
浏览文件 @
f4e36ad0
...
...
@@ -31,7 +31,7 @@ import org.maxkey.constants.ConstsLoginType;
import
org.maxkey.constants.ConstsStatus
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.onetimepwd.OtpAuthnService
;
import
org.maxkey.password.onetimepwd.
Mail
OtpAuthnService
;
import
org.maxkey.web.WebConstants
;
import
org.maxkey.web.WebContext
;
import
org.slf4j.Logger
;
...
...
@@ -67,7 +67,7 @@ public abstract class AbstractAuthenticationProvider {
protected
AbstractOtpAuthn
tfaOtpAuthn
;
protected
OtpAuthnService
otpAuthnService
;
protected
Mail
OtpAuthnService
otpAuthnService
;
protected
SessionManager
sessionManager
;
...
...
maxkey-authentications/maxkey-authentication-provider/src/main/java/org/maxkey/authn/provider/impl/MobileAuthenticationProvider.java
浏览文件 @
f4e36ad0
...
...
@@ -25,7 +25,7 @@ import org.maxkey.configuration.ApplicationConfig;
import
org.maxkey.constants.ConstsLoginType
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.
onetimepwd.
OtpAuthnService
;
import
org.maxkey.password.
sms.Sms
OtpAuthnService
;
import
org.maxkey.web.WebConstants
;
import
org.maxkey.web.WebContext
;
import
org.slf4j.Logger
;
...
...
@@ -46,6 +46,8 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
MobileAuthenticationProvider
.
class
);
SmsOtpAuthnService
smsOtpAuthnService
;
public
String
getProviderName
()
{
return
"mobile"
+
PROVIDER_SUFFIX
;
}
...
...
@@ -59,11 +61,11 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
public
MobileAuthenticationProvider
(
AbstractAuthenticationRealm
authenticationRealm
,
ApplicationConfig
applicationConfig
,
OtpAuthnService
o
tpAuthnService
,
SmsOtpAuthnService
smsO
tpAuthnService
,
SessionManager
sessionManager
)
{
this
.
authenticationRealm
=
authenticationRealm
;
this
.
applicationConfig
=
applicationConfig
;
this
.
otpAuthnService
=
o
tpAuthnService
;
this
.
smsOtpAuthnService
=
smsO
tpAuthnService
;
this
.
sessionManager
=
sessionManager
;
}
...
...
@@ -136,7 +138,7 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
UserInfo
validUserInfo
=
new
UserInfo
();
validUserInfo
.
setUsername
(
userInfo
.
getUsername
());
validUserInfo
.
setId
(
userInfo
.
getId
());
AbstractOtpAuthn
smsOtpAuthn
=
o
tpAuthnService
.
getByInstId
(
userInfo
.
getInstId
());
AbstractOtpAuthn
smsOtpAuthn
=
smsO
tpAuthnService
.
getByInstId
(
userInfo
.
getInstId
());
if
(
password
==
null
||
!
smsOtpAuthn
.
validate
(
validUserInfo
,
password
))
{
String
message
=
WebContext
.
getI18nValue
(
"login.error.captcha"
);
_logger
.
debug
(
"login captcha valid error."
);
...
...
maxkey-authentications/maxkey-authentication-provider/src/main/java/org/maxkey/autoconfigure/AuthnProviderAutoConfiguration.java
浏览文件 @
f4e36ad0
...
...
@@ -28,15 +28,10 @@ import org.maxkey.authn.session.SessionManager;
import
org.maxkey.authn.support.rememberme.AbstractRemeberMeManager
;
import
org.maxkey.authn.support.rememberme.JdbcRemeberMeManager
;
import
org.maxkey.configuration.ApplicationConfig
;
import
org.maxkey.constants.ConstsPersistence
;
import
org.maxkey.password.onetimepwd.OtpAuthnService
;
import
org.maxkey.password.onetimepwd.token.RedisOtpTokenStore
;
import
org.maxkey.persistence.redis.RedisConnectionFactory
;
import
org.maxkey.password.sms.SmsOtpAuthnService
;
import
org.maxkey.persistence.repository.LoginHistoryRepository
;
import
org.maxkey.persistence.repository.LoginRepository
;
import
org.maxkey.persistence.repository.PasswordPolicyValidator
;
import
org.maxkey.persistence.service.EmailSendersService
;
import
org.maxkey.persistence.service.SmsProviderService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.InitializingBean
;
...
...
@@ -86,14 +81,14 @@ public class AuthnProviderAutoConfiguration implements InitializingBean {
public
AbstractAuthenticationProvider
mobileAuthenticationProvider
(
AbstractAuthenticationRealm
authenticationRealm
,
ApplicationConfig
applicationConfig
,
OtpAuthnService
otp
AuthnService
,
SmsOtpAuthnService
sms
AuthnService
,
SessionManager
sessionManager
)
{
_logger
.
debug
(
"init Mobile authentication Provider ."
);
return
new
MobileAuthenticationProvider
(
authenticationRealm
,
applicationConfig
,
otp
AuthnService
,
sms
AuthnService
,
sessionManager
);
}
...
...
maxkey-authentications/maxkey-authentication-sms/build.gradle
0 → 100644
浏览文件 @
f4e36ad0
description
=
"maxkey-authentication-sms"
dependencies
{
//local jars
implementation
fileTree
(
dir:
'../maxkey-lib/'
,
include:
'*/*.jar'
)
implementation
project
(
":maxkey-common"
)
implementation
project
(
":maxkey-core"
)
implementation
project
(
":maxkey-persistence"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-otp"
)
}
\ No newline at end of file
maxkey-authentications/maxkey-authentication-sms/src/main/java/META-INF/MANIFEST.MF
0 → 100644
浏览文件 @
f4e36ad0
Manifest-Version: 1.0
Class-Path:
maxkey-authentications/maxkey-authentication-sms/src/main/java/org/maxkey/autoconfigure/SmsAutoConfiguration.java
0 → 100644
浏览文件 @
f4e36ad0
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.maxkey.autoconfigure
;
import
org.maxkey.constants.ConstsPersistence
;
import
org.maxkey.password.onetimepwd.token.RedisOtpTokenStore
;
import
org.maxkey.password.sms.SmsOtpAuthnService
;
import
org.maxkey.persistence.redis.RedisConnectionFactory
;
import
org.maxkey.persistence.service.EmailSendersService
;
import
org.maxkey.persistence.service.SmsProviderService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.AutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
@AutoConfiguration
public
class
SmsAutoConfiguration
implements
InitializingBean
{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
SmsAutoConfiguration
.
class
);
@Bean
(
name
=
"smsOtpAuthnService"
)
public
SmsOtpAuthnService
smsOtpAuthnService
(
@Value
(
"${maxkey.server.persistence}"
)
int
persistence
,
SmsProviderService
smsProviderService
,
EmailSendersService
emailSendersService
,
RedisConnectionFactory
redisConnFactory
)
{
SmsOtpAuthnService
smsOtpAuthnService
=
new
SmsOtpAuthnService
(
smsProviderService
,
emailSendersService
);
if
(
persistence
==
ConstsPersistence
.
REDIS
)
{
RedisOtpTokenStore
redisOptTokenStore
=
new
RedisOtpTokenStore
(
redisConnFactory
);
smsOtpAuthnService
.
setRedisOptTokenStore
(
redisOptTokenStore
);
}
_logger
.
debug
(
"SmsOtpAuthnService {} inited."
,
persistence
==
ConstsPersistence
.
REDIS
?
"Redis"
:
"InMemory"
);
return
smsOtpAuthnService
;
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
}
}
maxkey-authentications/maxkey-authentication-
otp/src/main/java/org/maxkey/password/onetimepwd/impl
/SmsOtpAuthn.java
→
maxkey-authentications/maxkey-authentication-
sms/src/main/java/org/maxkey/password/sms
/SmsOtpAuthn.java
浏览文件 @
f4e36ad0
...
...
@@ -15,7 +15,7 @@
*/
package
org.maxkey.password.
onetimepwd.impl
;
package
org.maxkey.password.
sms
;
import
java.io.IOException
;
...
...
maxkey-authentications/maxkey-authentication-
otp/src/main/java/org/maxkey/password/onetimepwd/
OtpAuthnService.java
→
maxkey-authentications/maxkey-authentication-
sms/src/main/java/org/maxkey/password/sms/Sms
OtpAuthnService.java
浏览文件 @
f4e36ad0
...
...
@@ -15,7 +15,7 @@
*/
package
org.maxkey.password.
onetimepwd
;
package
org.maxkey.password.
sms
;
import
java.sql.Types
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -25,20 +25,21 @@ import org.maxkey.constants.ConstsBoolean;
import
org.maxkey.crypto.password.PasswordReciprocal
;
import
org.maxkey.entity.EmailSenders
;
import
org.maxkey.entity.SmsProvider
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.onetimepwd.impl.MailOtpAuthn
;
import
org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnAliyun
;
import
org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnTencentCloud
;
import
org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnYunxin
;
import
org.maxkey.password.onetimepwd.token.RedisOtpTokenStore
;
import
org.maxkey.password.sms.impl.SmsOtpAuthnAliyun
;
import
org.maxkey.password.sms.impl.SmsOtpAuthnTencentCloud
;
import
org.maxkey.password.sms.impl.SmsOtpAuthnYunxin
;
import
org.maxkey.persistence.service.EmailSendersService
;
import
org.maxkey.persistence.service.SmsProviderService
;
import
com.github.benmanes.caffeine.cache.Cache
;
import
com.github.benmanes.caffeine.cache.Caffeine
;
public
class
OtpAuthnService
{
public
class
Sms
OtpAuthnService
{
protected
static
final
Cache
<
String
,
AbstractOtpAuthn
>
otp
AuthnStore
=
protected
static
final
Cache
<
String
,
AbstractOtpAuthn
>
sms
AuthnStore
=
Caffeine
.
newBuilder
()
.
expireAfterWrite
(
60
,
TimeUnit
.
MINUTES
)
.
build
();
...
...
@@ -49,18 +50,19 @@ public class OtpAuthnService {
RedisOtpTokenStore
redisOptTokenStore
;
public
OtpAuthnService
(
SmsProviderService
smsProviderService
,
EmailSendersService
emailSendersService
)
{
public
Sms
OtpAuthnService
(
SmsProviderService
smsProviderService
,
EmailSendersService
emailSendersService
)
{
this
.
smsProviderService
=
smsProviderService
;
this
.
emailSendersService
=
emailSendersService
;
}
public
OtpAuthnService
(
SmsProviderService
smsProvider
Service
,
RedisOtpTokenStore
redisOptTokenStore
)
{
public
SmsOtpAuthnService
(
SmsProviderService
smsProviderService
,
EmailSendersService
emailSenders
Service
,
RedisOtpTokenStore
redisOptTokenStore
)
{
this
.
smsProviderService
=
smsProviderService
;
this
.
emailSendersService
=
emailSendersService
;
this
.
redisOptTokenStore
=
redisOptTokenStore
;
}
public
AbstractOtpAuthn
getByInstId
(
String
instId
)
{
AbstractOtpAuthn
otpAuthn
=
otp
AuthnStore
.
getIfPresent
(
instId
);
AbstractOtpAuthn
otpAuthn
=
sms
AuthnStore
.
getIfPresent
(
instId
);
if
(
otpAuthn
==
null
)
{
SmsProvider
smsProvider
=
smsProviderService
.
findOne
(
"where instid = ? "
,
new
Object
[]{
instId
},
new
int
[]{
Types
.
VARCHAR
});
...
...
@@ -119,37 +121,11 @@ public class OtpAuthnService {
otpAuthn
=
mailOtpAuthn
;
}
otp
AuthnStore
.
put
(
instId
,
otpAuthn
);
sms
AuthnStore
.
put
(
instId
,
otpAuthn
);
}
}
return
otpAuthn
;
}
public
AbstractOtpAuthn
getMailOtpAuthn
(
String
instId
)
{
AbstractOtpAuthn
otpAuthn
=
otpAuthnStore
.
getIfPresent
(
instId
);
if
(
otpAuthn
==
null
)
{
EmailSenders
emailSender
=
emailSendersService
.
findOne
(
"where instid = ? "
,
new
Object
[]{
instId
},
new
int
[]{
Types
.
VARCHAR
});
String
credentials
=
PasswordReciprocal
.
getInstance
().
decoder
(
emailSender
.
getCredentials
());
EmailConfig
emailConfig
=
new
EmailConfig
(
emailSender
.
getAccount
(),
credentials
,
emailSender
.
getSmtpHost
(),
emailSender
.
getPort
(),
ConstsBoolean
.
isTrue
(
emailSender
.
getSslSwitch
()),
emailSender
.
getSender
());
MailOtpAuthn
mailOtpAuthn
=
new
MailOtpAuthn
(
emailConfig
);
mailOtpAuthn
.
setInterval
(
60
*
5
);
//5 minute
if
(
redisOptTokenStore
!=
null
)
{
mailOtpAuthn
.
setOptTokenStore
(
redisOptTokenStore
);
}
otpAuthn
=
mailOtpAuthn
;
}
otpAuthnStore
.
put
(
instId
,
otpAuthn
);
return
otpAuthn
;
}
public
void
setRedisOptTokenStore
(
RedisOtpTokenStore
redisOptTokenStore
)
{
this
.
redisOptTokenStore
=
redisOptTokenStore
;
...
...
maxkey-authentications/maxkey-authentication-
otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms
/SmsOtpAuthnAliyun.java
→
maxkey-authentications/maxkey-authentication-
sms/src/main/java/org/maxkey/password/sms/impl
/SmsOtpAuthnAliyun.java
浏览文件 @
f4e36ad0
...
...
@@ -15,7 +15,7 @@
*/
package
org.maxkey.password.
onetimepwd.impl.sms
;
package
org.maxkey.password.
sms.impl
;
import
com.aliyuncs.CommonRequest
;
import
com.aliyuncs.CommonResponse
;
...
...
@@ -25,7 +25,7 @@ import com.aliyuncs.http.MethodType;
import
com.aliyuncs.profile.DefaultProfile
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.
onetimepwd.impl
.SmsOtpAuthn
;
import
org.maxkey.password.
sms
.SmsOtpAuthn
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
maxkey-authentications/maxkey-authentication-
otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms
/SmsOtpAuthnTencentCloud.java
→
maxkey-authentications/maxkey-authentication-
sms/src/main/java/org/maxkey/password/sms/impl
/SmsOtpAuthnTencentCloud.java
浏览文件 @
f4e36ad0
...
...
@@ -15,7 +15,7 @@
*/
package
org.maxkey.password.
onetimepwd.impl.sms
;
package
org.maxkey.password.
sms.impl
;
import
com.tencentcloudapi.common.Credential
;
import
com.tencentcloudapi.common.profile.ClientProfile
;
...
...
@@ -25,7 +25,7 @@ import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
import
com.tencentcloudapi.sms.v20190711.models.SendSmsResponse
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.
onetimepwd.impl
.SmsOtpAuthn
;
import
org.maxkey.password.
sms
.SmsOtpAuthn
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
maxkey-authentications/maxkey-authentication-
otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms
/SmsOtpAuthnYunxin.java
→
maxkey-authentications/maxkey-authentication-
sms/src/main/java/org/maxkey/password/sms/impl
/SmsOtpAuthnYunxin.java
浏览文件 @
f4e36ad0
...
...
@@ -15,7 +15,7 @@
*/
package
org.maxkey.password.
onetimepwd.impl.sms
;
package
org.maxkey.password.
sms.impl
;
import
java.security.MessageDigest
;
import
java.util.ArrayList
;
...
...
@@ -30,7 +30,7 @@ import org.apache.http.impl.client.HttpClientBuilder;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.
onetimepwd.impl
.SmsOtpAuthn
;
import
org.maxkey.password.
sms
.SmsOtpAuthn
;
import
org.maxkey.util.JsonUtils
;
import
org.maxkey.util.StringGenerator
;
import
org.slf4j.Logger
;
...
...
maxkey-webs/maxkey-web-maxkey/build.gradle
浏览文件 @
f4e36ad0
...
...
@@ -13,6 +13,7 @@ dependencies {
implementation
project
(
":maxkey-authentications:maxkey-authentication-captcha"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-otp"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-provider"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-sms"
)
implementation
project
(
":maxkey-protocols:maxkey-protocol-authorize"
)
implementation
project
(
":maxkey-protocols:maxkey-protocol-cas"
)
...
...
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/autoconfigure/MaxKeyConfig.java
浏览文件 @
f4e36ad0
...
...
@@ -31,7 +31,7 @@ import org.maxkey.authn.support.kerberos.RemoteKerberosService;
import
org.maxkey.configuration.EmailConfig
;
import
org.maxkey.constants.ConstsPersistence
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.onetimepwd.OtpAuthnService
;
import
org.maxkey.password.onetimepwd.
Mail
OtpAuthnService
;
import
org.maxkey.password.onetimepwd.algorithm.OtpKeyUriFormat
;
import
org.maxkey.password.onetimepwd.impl.MailOtpAuthn
;
import
org.maxkey.password.onetimepwd.impl.TimeBasedOtpAuthn
;
...
...
@@ -104,7 +104,7 @@ public class MaxKeyConfig implements InitializingBean {
LoginHistoryRepository
loginHistoryService
,
UserInfoService
userInfoService
,
JdbcTemplate
jdbcTemplate
,
OtpAuthnService
otpAuthnService
,
Mail
OtpAuthnService
otpAuthnService
,
LdapContextService
ldapContextService
)
{
LdapAuthenticationRealmService
ldapRealmService
=
new
LdapAuthenticationRealmService
(
ldapContextService
);
JdbcAuthenticationRealm
authenticationRealm
=
new
JdbcAuthenticationRealm
(
...
...
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java
浏览文件 @
f4e36ad0
...
...
@@ -26,12 +26,12 @@ import org.maxkey.entity.ChangePassword;
import
org.maxkey.entity.Message
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.onetimepwd.OtpAuthnService
;
import
org.maxkey.password.onetimepwd.MailOtpAuthnService
;
import
org.maxkey.password.sms.SmsOtpAuthnService
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -74,8 +74,10 @@ public class ForgotPasswordContorller {
UserInfoService
userInfoService
;
@Autowired
@Qualifier
(
"otpAuthnService"
)
OtpAuthnService
otpAuthnService
;
MailOtpAuthnService
mailOtpAuthnService
;
@Autowired
SmsOtpAuthnService
smsOtpAuthnService
;
...
...
@@ -100,7 +102,7 @@ public class ForgotPasswordContorller {
if
(
userInfo
!=
null
)
{
change
=
new
ChangePassword
(
userInfo
);
change
.
clearPassword
();
AbstractOtpAuthn
smsOtpAuthn
=
o
tpAuthnService
.
getByInstId
(
userInfo
.
getInstId
());
AbstractOtpAuthn
smsOtpAuthn
=
smsO
tpAuthnService
.
getByInstId
(
userInfo
.
getInstId
());
smsOtpAuthn
.
produce
(
userInfo
);
return
new
Message
<
ChangePassword
>(
change
).
buildResponse
();
}
...
...
@@ -127,7 +129,7 @@ public class ForgotPasswordContorller {
if
(
userInfo
!=
null
)
{
change
=
new
ChangePassword
(
userInfo
);
change
.
clearPassword
();
AbstractOtpAuthn
mailOtpAuthn
=
o
tpAuthnService
.
getMailOtpAuthn
(
userInfo
.
getInstId
());
AbstractOtpAuthn
mailOtpAuthn
=
mailO
tpAuthnService
.
getMailOtpAuthn
(
userInfo
.
getInstId
());
mailOtpAuthn
.
produce
(
userInfo
);
return
new
Message
<
ChangePassword
>(
change
).
buildResponse
();
}
...
...
@@ -146,8 +148,8 @@ public class ForgotPasswordContorller {
&&
changePassword
.
getPassword
().
equals
(
changePassword
.
getConfirmPassword
()))
{
UserInfo
loadedUserInfo
=
userInfoService
.
get
(
changePassword
.
getUserId
());
if
(
loadedUserInfo
!=
null
)
{
AbstractOtpAuthn
smsOtpAuthn
=
o
tpAuthnService
.
getByInstId
(
loadedUserInfo
.
getInstId
());
AbstractOtpAuthn
mailOtpAuthn
=
o
tpAuthnService
.
getMailOtpAuthn
(
loadedUserInfo
.
getInstId
());
AbstractOtpAuthn
smsOtpAuthn
=
smsO
tpAuthnService
.
getByInstId
(
loadedUserInfo
.
getInstId
());
AbstractOtpAuthn
mailOtpAuthn
=
mailO
tpAuthnService
.
getMailOtpAuthn
(
loadedUserInfo
.
getInstId
());
if
(
(
forgotType
.
equalsIgnoreCase
(
"email"
)
&&
mailOtpAuthn
!=
null
...
...
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/LoginEntryPoint.java
浏览文件 @
f4e36ad0
...
...
@@ -38,7 +38,8 @@ import org.maxkey.entity.Institutions;
import
org.maxkey.entity.Message
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.onetimepwd.OtpAuthnService
;
import
org.maxkey.password.onetimepwd.MailOtpAuthnService
;
import
org.maxkey.password.sms.SmsOtpAuthnService
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.web.WebConstants
;
import
org.maxkey.web.WebContext
;
...
...
@@ -91,7 +92,9 @@ public class LoginEntryPoint {
AbstractOtpAuthn
tfaOtpAuthn
;
@Autowired
OtpAuthnService
otpAuthnService
;
SmsOtpAuthnService
smsAuthnService
;
@Autowired
AbstractRemeberMeManager
remeberMeManager
;
...
...
@@ -156,7 +159,7 @@ public class LoginEntryPoint {
public
ResponseEntity
<?>
produceOtp
(
@PathVariable
(
"mobile"
)
String
mobile
)
{
UserInfo
userInfo
=
userInfoService
.
findByEmailMobile
(
mobile
);
if
(
userInfo
!=
null
)
{
otp
AuthnService
.
getByInstId
(
WebContext
.
getInst
().
getId
()).
produce
(
userInfo
);
sms
AuthnService
.
getByInstId
(
WebContext
.
getInst
().
getId
()).
produce
(
userInfo
);
return
new
Message
<
AuthJwt
>(
Message
.
SUCCESS
).
buildResponse
();
}
...
...
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/RegisterController.java
浏览文件 @
f4e36ad0
...
...
@@ -29,14 +29,13 @@ import org.maxkey.crypto.password.PasswordReciprocal;
import
org.maxkey.entity.Message
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.
onetimepwd.
OtpAuthnService
;
import
org.maxkey.password.
sms.Sms
OtpAuthnService
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.util.StringUtils
;
import
org.maxkey.web.WebContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
...
...
@@ -64,8 +63,7 @@ public class RegisterController {
private
UserInfoService
userInfoService
;
@Autowired
@Qualifier
(
"otpAuthnService"
)
OtpAuthnService
otpAuthnService
;
SmsOtpAuthnService
smsOtpAuthnService
;
@Autowired
private
PasswordEncoder
passwordEncoder
;
...
...
@@ -81,7 +79,7 @@ public class RegisterController {
UserInfo
userInfo
=
new
UserInfo
();
userInfo
.
setUsername
(
mobile
);
userInfo
.
setMobile
(
mobile
);
AbstractOtpAuthn
smsOtpAuthn
=
o
tpAuthnService
.
getByInstId
(
WebContext
.
getInst
().
getId
());
AbstractOtpAuthn
smsOtpAuthn
=
smsO
tpAuthnService
.
getByInstId
(
WebContext
.
getInst
().
getId
());
smsOtpAuthn
.
produce
(
userInfo
);
return
new
Message
<
UserInfo
>(
userInfo
).
buildResponse
();
}
...
...
@@ -98,7 +96,7 @@ public class RegisterController {
UserInfo
validateUserInfo
=
new
UserInfo
();
validateUserInfo
.
setUsername
(
userInfo
.
getMobile
());
validateUserInfo
.
setMobile
(
userInfo
.
getMobile
());
AbstractOtpAuthn
smsOtpAuthn
=
o
tpAuthnService
.
getByInstId
(
WebContext
.
getInst
().
getId
());
AbstractOtpAuthn
smsOtpAuthn
=
smsO
tpAuthnService
.
getByInstId
(
WebContext
.
getInst
().
getId
());
if
(
smsOtpAuthn
!=
null
&&
smsOtpAuthn
.
validate
(
validateUserInfo
,
captcha
)){
UserInfo
temp
=
userInfoService
.
findByEmailMobile
(
userInfo
.
getEmail
());
...
...
maxkey-webs/maxkey-web-maxkey/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
浏览文件 @
f4e36ad0
...
...
@@ -5,6 +5,7 @@ org.maxkey.autoconfigure.RedisAutoConfiguration
org.maxkey.autoconfigure.AuthnProviderAutoConfiguration
org.maxkey.autoconfigure.JwtAuthnAutoConfiguration
org.maxkey.autoconfigure.OneTimePasswordAutoConfiguration
org.maxkey.autoconfigure.SmsAutoConfiguration
org.maxkey.autoconfigure.SessionAutoConfiguration
org.maxkey.autoconfigure.TokenAutoConfiguration
org.maxkey.autoconfigure.CasAutoConfiguration
...
...
maxkey-webs/maxkey-web-mgt/build.gradle
浏览文件 @
f4e36ad0
...
...
@@ -12,6 +12,7 @@ dependencies {
implementation
project
(
":maxkey-authentications:maxkey-authentication-captcha"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-otp"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-provider"
)
implementation
project
(
":maxkey-authentications:maxkey-authentication-sms"
)
implementation
project
(
":maxkey-protocols:maxkey-protocol-oauth-2.0"
)
implementation
project
(
":maxkey-protocols:maxkey-protocol-saml-2.0"
)
...
...
maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
浏览文件 @
f4e36ad0
...
...
@@ -5,6 +5,7 @@ org.maxkey.autoconfigure.JwtAuthnAutoConfiguration
org.maxkey.autoconfigure.RedisAutoConfiguration
org.maxkey.autoconfigure.AuthnProviderAutoConfiguration
org.maxkey.autoconfigure.OneTimePasswordAutoConfiguration
org.maxkey.autoconfigure.SmsAutoConfiguration
org.maxkey.autoconfigure.SessionAutoConfiguration
org.maxkey.autoconfigure.TokenAutoConfiguration
org.maxkey.autoconfigure.SynchronizerAutoConfiguration
...
...
settings.gradle
浏览文件 @
f4e36ad0
...
...
@@ -31,6 +31,7 @@ include (
'maxkey-authentications:maxkey-authentication-social'
,
'maxkey-authentications:maxkey-authentication-otp'
,
'maxkey-authentications:maxkey-authentication-provider'
,
'maxkey-authentications:maxkey-authentication-sms'
,
//identity
'maxkey-identitys:maxkey-identity-scim'
,
'maxkey-identitys:maxkey-identity-rest'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录