Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
1b70eec8
MaxKey
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
MaxKey
8 个月 前同步成功
通知
75
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,体验更适合开发者的 AI 搜索 >>
提交
1b70eec8
编写于
10月 06, 2021
作者:
MaxKey单点登录官方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
配置文件优化,参数整合及日志优化
上级
fe8c89a4
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
139 addition
and
102 deletion
+139
-102
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/algorithm/OtpKeyUriFormat.java
...maxkey/password/onetimepwd/algorithm/OtpKeyUriFormat.java
+27
-4
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/SmsOtpAuthn.java
...java/org/maxkey/password/onetimepwd/impl/SmsOtpAuthn.java
+3
-3
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/TimeBasedOtpAuthn.java
...rg/maxkey/password/onetimepwd/impl/TimeBasedOtpAuthn.java
+6
-0
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms/SmsOtpAuthnAliyun.java
...axkey/password/onetimepwd/impl/sms/SmsOtpAuthnAliyun.java
+4
-4
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms/SmsOtpAuthnTencentCloud.java
...password/onetimepwd/impl/sms/SmsOtpAuthnTencentCloud.java
+5
-6
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms/SmsOtpAuthnYunxin.java
...axkey/password/onetimepwd/impl/sms/SmsOtpAuthnYunxin.java
+3
-3
maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java
.../test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java
+2
-2
maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/autoconfigure/SocialSignOnAutoConfiguration.java
...g/maxkey/autoconfigure/SocialSignOnAutoConfiguration.java
+9
-15
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
...key-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
+38
-34
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java
.../org/maxkey/web/contorller/OneTimePasswordController.java
+17
-17
maxkey-webs/maxkey-web-maxkey/src/main/resources/application-http.properties
...web-maxkey/src/main/resources/application-http.properties
+7
-7
maxkey-webs/maxkey-web-maxkey/src/main/resources/application-https.properties
...eb-maxkey/src/main/resources/application-https.properties
+7
-7
maxkey-webs/maxkey-web-maxkey/src/main/resources/log4j2.xml
maxkey-webs/maxkey-web-maxkey/src/main/resources/log4j2.xml
+2
-0
maxkey-webs/maxkey-web-mgt/src/main/resources/application-http.properties
...ey-web-mgt/src/main/resources/application-http.properties
+8
-0
maxkey-webs/maxkey-web-mgt/src/main/resources/log4j2.xml
maxkey-webs/maxkey-web-mgt/src/main/resources/log4j2.xml
+1
-0
未找到文件。
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/algorithm/KeyUriFormat.java
→
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/algorithm/
Otp
KeyUriFormat.java
浏览文件 @
1b70eec8
...
...
@@ -17,7 +17,7 @@
package
org.maxkey.password.onetimepwd.algorithm
;
public
class
KeyUriFormat
{
public
class
Otp
KeyUriFormat
{
public
class
Types
{
public
static
final
String
HOTP
=
"hotp"
;
...
...
@@ -38,7 +38,7 @@ public class KeyUriFormat {
String
account
;
public
KeyUriFormat
()
{
public
Otp
KeyUriFormat
()
{
}
...
...
@@ -46,7 +46,7 @@ public class KeyUriFormat {
* @param type
* @param secret
*/
public
KeyUriFormat
(
String
type
,
String
secret
)
{
public
Otp
KeyUriFormat
(
String
type
,
String
secret
)
{
this
.
type
=
type
;
this
.
secret
=
secret
;
}
...
...
@@ -56,12 +56,35 @@ public class KeyUriFormat {
* @param secret
* @param issuer
*/
public
KeyUriFormat
(
String
type
,
String
secret
,
String
issuer
)
{
public
Otp
KeyUriFormat
(
String
type
,
String
secret
,
String
issuer
)
{
this
.
type
=
type
;
this
.
secret
=
secret
;
this
.
issuer
=
issuer
;
}
public
OtpKeyUriFormat
(
String
crypto
,
String
type
,
String
secret
,
String
issuer
,
String
domain
,
int
digits
,
Long
counter
,
int
period
,
String
account
)
{
super
();
this
.
crypto
=
crypto
;
this
.
type
=
type
;
this
.
secret
=
secret
;
this
.
issuer
=
issuer
;
this
.
domain
=
domain
;
this
.
digits
=
digits
;
this
.
counter
=
counter
;
this
.
period
=
period
;
this
.
account
=
account
;
}
public
OtpKeyUriFormat
(
String
type
,
String
issuer
,
String
domain
,
int
digits
,
int
period
)
{
super
();
this
.
type
=
type
;
this
.
issuer
=
issuer
;
this
.
domain
=
domain
;
this
.
digits
=
digits
;
this
.
period
=
period
;
}
/**
* @return the type
*/
...
...
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/SmsOtpAuthn.java
浏览文件 @
1b70eec8
...
...
@@ -18,17 +18,17 @@
package
org.maxkey.password.onetimepwd.impl
;
import
java.io.IOException
;
import
java.util.Properties
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.env.StandardEnvironment
;
public
class
SmsOtpAuthn
extends
AbstractOtpAuthn
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SmsOtpAuthn
.
class
);
protected
Properties
properties
;
protected
StandardEnvironment
properties
;
@Override
...
...
@@ -44,7 +44,7 @@ public class SmsOtpAuthn extends AbstractOtpAuthn {
return
true
;
}
public
void
setProperties
(
Properties
properties
)
{
public
void
setProperties
(
StandardEnvironment
properties
)
{
this
.
properties
=
properties
;
}
...
...
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/TimeBasedOtpAuthn.java
浏览文件 @
1b70eec8
...
...
@@ -38,6 +38,12 @@ public class TimeBasedOtpAuthn extends AbstractOtpAuthn {
dateFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
}
public
TimeBasedOtpAuthn
(
int
digits
,
int
interval
)
{
dateFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
super
.
digits
=
digits
;
super
.
interval
=
interval
;
}
@Override
public
boolean
produce
(
UserInfo
userInfo
)
{
return
true
;
...
...
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms/SmsOtpAuthnAliyun.java
浏览文件 @
1b70eec8
...
...
@@ -138,10 +138,10 @@ public class SmsOtpAuthnAliyun extends SmsOtpAuthn {
e
.
printStackTrace
();
}
this
.
accessKeyId
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.accesskeyid"
);
this
.
accessSecret
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.accesssecret"
);
this
.
templateCode
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.templatecode"
);
this
.
signName
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.signname"
);
this
.
accessKeyId
=
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.accesskeyid"
);
this
.
accessSecret
=
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.accesssecret"
);
this
.
templateCode
=
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.templatecode"
);
this
.
signName
=
properties
.
getProperty
(
"maxkey.otp.sms.aliyun.signname"
);
}
}
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms/SmsOtpAuthnTencentCloud.java
浏览文件 @
1b70eec8
...
...
@@ -55,7 +55,6 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
otpType
=
OtpTypes
.
SMS
;
}
@Override
...
...
@@ -181,11 +180,11 @@ public class SmsOtpAuthnTencentCloud extends SmsOtpAuthn {
e
.
printStackTrace
();
}
this
.
secretId
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.secretid"
);
this
.
secretKey
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.secretkey"
);
this
.
smsSdkAppid
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.smssdkappid"
);
this
.
templateId
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.templateid"
);
this
.
sign
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.sign"
);
this
.
secretId
=
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.secretid"
);
this
.
secretKey
=
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.secretkey"
);
this
.
smsSdkAppid
=
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.smssdkappid"
);
this
.
templateId
=
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.templateid"
);
this
.
sign
=
properties
.
getProperty
(
"maxkey.otp.sms.tencentcloud.sign"
);
}
}
maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/password/onetimepwd/impl/sms/SmsOtpAuthnYunxin.java
浏览文件 @
1b70eec8
...
...
@@ -212,9 +212,9 @@ public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
e
.
printStackTrace
();
}
this
.
appKey
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.yunxin.appkey"
);
this
.
appSecret
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.yunxin.appsecret"
);
this
.
templateId
=
this
.
properties
.
getProperty
(
"maxkey.otp.sms.yunxin.templateid"
);
this
.
appKey
=
properties
.
getProperty
(
"maxkey.otp.sms.yunxin.appkey"
);
this
.
appSecret
=
properties
.
getProperty
(
"maxkey.otp.sms.yunxin.appsecret"
);
this
.
templateId
=
properties
.
getProperty
(
"maxkey.otp.sms.yunxin.templateid"
);
}
/**
...
...
maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java
浏览文件 @
1b70eec8
...
...
@@ -19,7 +19,7 @@ package org.maxkey.otp.algorithm;
import
java.io.File
;
import
org.maxkey.password.onetimepwd.algorithm.KeyUriFormat
;
import
org.maxkey.password.onetimepwd.algorithm.
Otp
KeyUriFormat
;
import
org.maxkey.util.QRCode
;
import
com.google.zxing.BarcodeFormat
;
...
...
@@ -29,7 +29,7 @@ import com.google.zxing.common.BitMatrix;
public
class
KeyUriFormatTest
{
public
static
void
main
(
String
[]
args
)
{
try
{
KeyUriFormat
kuf
=
new
KeyUriFormat
(
KeyUriFormat
.
Types
.
TOTP
,
OtpKeyUriFormat
kuf
=
new
OtpKeyUriFormat
(
Otp
KeyUriFormat
.
Types
.
TOTP
,
"GIWVWOL7EI5WLVZPDMROEPSTFBEVO77Q"
,
"connsec.com"
);
kuf
.
setPeriod
(
60
);
...
...
maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/autoconfigure/SocialSignOnAutoConfiguration.java
浏览文件 @
1b70eec8
...
...
@@ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.support.PropertySourcesPlaceholderConfigurer
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.jdbc.core.JdbcTemplate
;
...
...
@@ -44,26 +43,21 @@ public class SocialSignOnAutoConfiguration implements InitializingBean {
@Bean
(
name
=
"socialSignOnProviderService"
)
@ConditionalOnClass
(
SocialSignOnProvider
.
class
)
public
SocialSignOnProviderService
socialSignOnProviderService
(
PropertySourcesPlaceholderConfigurer
propertySourcesPlaceholderConfigurer
)
throws
IOException
{
StandardEnvironment
environment
)
throws
IOException
{
SocialSignOnProviderService
socialSignOnProviderService
=
new
SocialSignOnProviderService
();
StandardEnvironment
properties
=
(
StandardEnvironment
)
propertySourcesPlaceholderConfigurer
.
getAppliedPropertySources
()
.
get
(
PropertySourcesPlaceholderConfigurer
.
ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME
)
.
getSource
();
List
<
SocialSignOnProvider
>
socialSignOnProviderList
=
new
ArrayList
<
SocialSignOnProvider
>();
String
[]
providerList
=
properties
.
getProperty
(
"maxkey.login.socialsignon.providers"
).
toString
().
split
(
","
);
String
[]
providerList
=
environment
.
getProperty
(
"maxkey.login.socialsignon.providers"
).
toString
().
split
(
","
);
for
(
String
provider
:
providerList
)
{
String
providerName
=
properties
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".provider.name"
);
String
icon
=
properties
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".icon"
);
String
clientId
=
properties
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".client.id"
);
String
clientSecret
=
properties
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".client.secret"
);
String
sortOrder
=
properties
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".sortorder"
);
String
agentId
=
properties
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".agent.id"
);
String
hidden
=
properties
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".hidden"
);
String
providerName
=
environment
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".provider.name"
);
String
icon
=
environment
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".icon"
);
String
clientId
=
environment
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".client.id"
);
String
clientSecret
=
environment
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".client.secret"
);
String
sortOrder
=
environment
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".sortorder"
);
String
agentId
=
environment
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".agent.id"
);
String
hidden
=
environment
.
getProperty
(
"maxkey.socialsignon."
+
provider
+
".hidden"
);
SocialSignOnProvider
socialSignOnProvider
=
new
SocialSignOnProvider
();
socialSignOnProvider
.
setProvider
(
provider
);
...
...
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
浏览文件 @
1b70eec8
...
...
@@ -22,7 +22,6 @@ import java.io.IOException;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.stream.Collectors
;
import
org.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm
;
...
...
@@ -38,7 +37,7 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
import
org.maxkey.configuration.EmailConfig
;
import
org.maxkey.constants.ConstantsPersistence
;
import
org.maxkey.password.onetimepwd.AbstractOtpAuthn
;
import
org.maxkey.password.onetimepwd.algorithm.KeyUriFormat
;
import
org.maxkey.password.onetimepwd.algorithm.
Otp
KeyUriFormat
;
import
org.maxkey.password.onetimepwd.impl.MailOtpAuthn
;
import
org.maxkey.password.onetimepwd.impl.SmsOtpAuthn
;
import
org.maxkey.password.onetimepwd.impl.TimeBasedOtpAuthn
;
...
...
@@ -60,6 +59,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.jdbc.core.JdbcTemplate
;
...
...
@@ -87,27 +87,22 @@ public class MaxKeyConfig implements InitializingBean {
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
MaxKeyConfig
.
class
);
@Bean
(
name
=
"
k
eyUriFormat"
)
public
KeyUriFormat
k
eyUriFormat
(
@Value
(
"${maxkey.otp.keyuri.format
.type:totp}"
)
String
keyuriFormatT
ype
,
@Value
(
"${maxkey.otp.keyuri.format
.domain:MaxKey.top}"
)
String
keyuriFormatD
omain
,
@Value
(
"${maxkey.otp.keyuri.format
.issuer:MaxKey}"
)
String
keyuriFormatI
ssuer
,
@Value
(
"${maxkey.otp.keyuri.format
.digits:6}"
)
int
keyuriFormatD
igits
,
@Value
(
"${maxkey.otp.keyuri.format
.period:30}"
)
int
keyuriFormatP
eriod
)
{
@Bean
(
name
=
"
otpK
eyUriFormat"
)
public
OtpKeyUriFormat
otpK
eyUriFormat
(
@Value
(
"${maxkey.otp.policy
.type:totp}"
)
String
t
ype
,
@Value
(
"${maxkey.otp.policy
.domain:MaxKey.top}"
)
String
d
omain
,
@Value
(
"${maxkey.otp.policy
.issuer:MaxKey}"
)
String
i
ssuer
,
@Value
(
"${maxkey.otp.policy
.digits:6}"
)
int
d
igits
,
@Value
(
"${maxkey.otp.policy
.period:30}"
)
int
p
eriod
)
{
KeyUriFormat
keyUriFormat
=
new
KeyUriFormat
();
keyUriFormat
.
setType
(
keyuriFormatType
);
keyUriFormat
.
setDomain
(
keyuriFormatDomain
);
keyUriFormat
.
setIssuer
(
keyuriFormatIssuer
);
keyUriFormat
.
setDigits
(
keyuriFormatDigits
);
keyUriFormat
.
setPeriod
(
keyuriFormatPeriod
);
_logger
.
debug
(
"KeyUri Format "
+
keyUriFormat
);
return
keyUriFormat
;
OtpKeyUriFormat
otpKeyUriFormat
=
new
OtpKeyUriFormat
(
type
,
issuer
,
domain
,
digits
,
period
);
_logger
.
debug
(
"OTP KeyUri Format "
+
otpKeyUriFormat
);
return
otpKeyUriFormat
;
}
public
AbstractAuthenticationRealm
ldapAuthenticationRealm
(
...
...
@@ -194,18 +189,26 @@ public class MaxKeyConfig implements InitializingBean {
}
@Bean
(
name
=
"timeBasedOtpAuthn"
)
public
TimeBasedOtpAuthn
timeBasedOtpAuthn
()
{
TimeBasedOtpAuthn
tfaOtpAuthn
=
new
TimeBasedOtpAuthn
();
public
TimeBasedOtpAuthn
timeBasedOtpAuthn
(
@Value
(
"${maxkey.otp.policy.digits:6}"
)
int
digits
,
@Value
(
"${maxkey.otp.policy.period:30}"
)
int
period
)
{
TimeBasedOtpAuthn
tfaOtpAuthn
=
new
TimeBasedOtpAuthn
(
digits
,
period
);
_logger
.
debug
(
"TimeBasedOtpAuthn inited."
);
return
tfaOtpAuthn
;
}
@Bean
(
name
=
"tfaOtpAuthn"
)
public
AbstractOtpAuthn
tfaOptAuthn
(
@Value
(
"${maxkey.login.mfa.type}"
)
String
mfaType
,
@Value
(
"${maxkey.server.persistence}"
)
int
persistence
,
RedisConnectionFactory
redisConnFactory
)
{
AbstractOtpAuthn
tfaOtpAuthn
=
new
TimeBasedOtpAuthn
();
@Value
(
"${maxkey.login.mfa.type}"
)
String
mfaType
,
@Value
(
"${maxkey.otp.policy.digits:6}"
)
int
digits
,
@Value
(
"${maxkey.otp.policy.period:30}"
)
int
period
,
@Value
(
"${maxkey.server.persistence}"
)
int
persistence
,
RedisConnectionFactory
redisConnFactory
)
{
AbstractOtpAuthn
tfaOtpAuthn
=
new
TimeBasedOtpAuthn
(
digits
,
period
);
_logger
.
debug
(
"TimeBasedOtpAuthn inited."
);
if
(
persistence
==
ConstantsPersistence
.
REDIS
)
{
...
...
@@ -251,14 +254,14 @@ public class MaxKeyConfig implements InitializingBean {
@Bean
(
name
=
"smsOtpAuthn"
)
public
SmsOtpAuthn
smsOtpAuthn
(
@Value
(
"${maxkey.otp.sms
}"
)
String
optSmsP
rovider
,
@Value
(
"${maxkey.otp.sms
.provider}"
)
String
p
rovider
,
@Value
(
"${maxkey.server.persistence}"
)
int
persistence
,
Properties
applicationProperty
,
StandardEnvironment
environment
,
RedisConnectionFactory
redisConnFactory
)
{
SmsOtpAuthn
smsOtpAuthn
=
null
;
if
(
optSmsProvider
.
equalsIgnoreCase
(
"SmsOtpAuthnA
liyun"
))
{
if
(
provider
.
equalsIgnoreCase
(
"a
liyun"
))
{
smsOtpAuthn
=
new
SmsOtpAuthnAliyun
();
}
else
if
(
optSmsProvider
.
equalsIgnoreCase
(
"SmsOtpAuthnTencentC
loud"
))
{
}
else
if
(
provider
.
equalsIgnoreCase
(
"tencentc
loud"
))
{
smsOtpAuthn
=
new
SmsOtpAuthnTencentCloud
();
}
else
{
smsOtpAuthn
=
new
SmsOtpAuthnYunxin
();
...
...
@@ -267,10 +270,11 @@ public class MaxKeyConfig implements InitializingBean {
RedisOtpTokenStore
redisOptTokenStore
=
new
RedisOtpTokenStore
(
redisConnFactory
);
smsOtpAuthn
.
setOptTokenStore
(
redisOptTokenStore
);
}
smsOtpAuthn
.
setProperties
(
applicationProperty
);
smsOtpAuthn
.
setProperties
(
environment
);
smsOtpAuthn
.
initPropertys
();
_logger
.
debug
(
"SmsOtpAuthn
inited."
);
_logger
.
debug
(
"SmsOtpAuthn
{} inited."
,
smsOtpAuthn
.
getClass
().
getCanonicalName
()
);
return
smsOtpAuthn
;
}
...
...
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java
浏览文件 @
1b70eec8
...
...
@@ -23,7 +23,7 @@ import org.apache.commons.codec.binary.Hex;
import
org.maxkey.crypto.Base32Utils
;
import
org.maxkey.crypto.password.PasswordReciprocal
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.password.onetimepwd.algorithm.KeyUriFormat
;
import
org.maxkey.password.onetimepwd.algorithm.
Otp
KeyUriFormat
;
import
org.maxkey.password.onetimepwd.algorithm.OtpSecret
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.util.RQCodeUtils
;
...
...
@@ -53,8 +53,8 @@ public class OneTimePasswordController {
private
UserInfoService
userInfoService
;
@Autowired
@Qualifier
(
"
k
eyUriFormat"
)
KeyUriFormat
k
eyUriFormat
;
@Qualifier
(
"
otpK
eyUriFormat"
)
OtpKeyUriFormat
otpK
eyUriFormat
;
@Autowired
@Qualifier
(
"passwordReciprocal"
)
...
...
@@ -65,13 +65,13 @@ public class OneTimePasswordController {
ModelAndView
modelAndView
=
new
ModelAndView
(
"safe/timeBased"
);
UserInfo
userInfo
=
WebContext
.
getUserInfo
();
String
sharedSecret
=
passwordReciprocal
.
decoder
(
userInfo
.
getSharedSecret
());
k
eyUriFormat
.
setSecret
(
sharedSecret
);
String
otpauth
=
k
eyUriFormat
.
format
(
userInfo
.
getUsername
());
otpK
eyUriFormat
.
setSecret
(
sharedSecret
);
String
otpauth
=
otpK
eyUriFormat
.
format
(
userInfo
.
getUsername
());
byte
[]
byteSharedSecret
=
Base32Utils
.
decode
(
sharedSecret
);
String
hexSharedSecret
=
Hex
.
encodeHexString
(
byteSharedSecret
);
modelAndView
.
addObject
(
"id"
,
genRqCode
(
otpauth
));
modelAndView
.
addObject
(
"userInfo"
,
userInfo
);
modelAndView
.
addObject
(
"format"
,
k
eyUriFormat
);
modelAndView
.
addObject
(
"format"
,
otpK
eyUriFormat
);
modelAndView
.
addObject
(
"sharedSecret"
,
sharedSecret
);
modelAndView
.
addObject
(
"hexSharedSecret"
,
hexSharedSecret
);
return
modelAndView
;
...
...
@@ -80,7 +80,7 @@ public class OneTimePasswordController {
@RequestMapping
(
value
=
{
"gen/timebased"
})
public
ModelAndView
gentimebased
()
{
UserInfo
userInfo
=
WebContext
.
getUserInfo
();
byte
[]
byteSharedSecret
=
OtpSecret
.
generate
(
k
eyUriFormat
.
getCrypto
());
byte
[]
byteSharedSecret
=
OtpSecret
.
generate
(
otpK
eyUriFormat
.
getCrypto
());
String
sharedSecret
=
Base32Utils
.
encode
(
byteSharedSecret
);
sharedSecret
=
passwordReciprocal
.
encode
(
sharedSecret
);
userInfo
.
setSharedSecret
(
sharedSecret
);
...
...
@@ -95,15 +95,15 @@ public class OneTimePasswordController {
ModelAndView
modelAndView
=
new
ModelAndView
(
"safe/counterBased"
);
UserInfo
userInfo
=
WebContext
.
getUserInfo
();
String
sharedSecret
=
passwordReciprocal
.
decoder
(
userInfo
.
getSharedSecret
());
k
eyUriFormat
.
setSecret
(
sharedSecret
);
k
eyUriFormat
.
setCounter
(
Long
.
parseLong
(
userInfo
.
getSharedCounter
()));
String
otpauth
=
k
eyUriFormat
.
format
(
userInfo
.
getUsername
());
otpK
eyUriFormat
.
setSecret
(
sharedSecret
);
otpK
eyUriFormat
.
setCounter
(
Long
.
parseLong
(
userInfo
.
getSharedCounter
()));
String
otpauth
=
otpK
eyUriFormat
.
format
(
userInfo
.
getUsername
());
byte
[]
byteSharedSecret
=
Base32Utils
.
decode
(
sharedSecret
);
String
hexSharedSecret
=
Hex
.
encodeHexString
(
byteSharedSecret
);
modelAndView
.
addObject
(
"id"
,
genRqCode
(
otpauth
));
modelAndView
.
addObject
(
"userInfo"
,
userInfo
);
modelAndView
.
addObject
(
"format"
,
k
eyUriFormat
);
modelAndView
.
addObject
(
"format"
,
otpK
eyUriFormat
);
modelAndView
.
addObject
(
"sharedSecret"
,
sharedSecret
);
modelAndView
.
addObject
(
"hexSharedSecret"
,
hexSharedSecret
);
return
modelAndView
;
...
...
@@ -113,7 +113,7 @@ public class OneTimePasswordController {
@RequestMapping
(
value
=
{
"gen/counterbased"
})
public
ModelAndView
gencounterbased
()
{
UserInfo
userInfo
=
WebContext
.
getUserInfo
();
byte
[]
byteSharedSecret
=
OtpSecret
.
generate
(
k
eyUriFormat
.
getCrypto
());
byte
[]
byteSharedSecret
=
OtpSecret
.
generate
(
otpK
eyUriFormat
.
getCrypto
());
String
sharedSecret
=
Base32Utils
.
encode
(
byteSharedSecret
);
sharedSecret
=
passwordReciprocal
.
encode
(
sharedSecret
);
userInfo
.
setSharedSecret
(
sharedSecret
);
...
...
@@ -128,14 +128,14 @@ public class OneTimePasswordController {
ModelAndView
modelAndView
=
new
ModelAndView
(
"safe/hotp"
);
UserInfo
userInfo
=
WebContext
.
getUserInfo
();
String
sharedSecret
=
passwordReciprocal
.
decoder
(
userInfo
.
getSharedSecret
());
k
eyUriFormat
.
setSecret
(
sharedSecret
);
k
eyUriFormat
.
setCounter
(
Long
.
parseLong
(
userInfo
.
getSharedCounter
()));
String
otpauth
=
k
eyUriFormat
.
format
(
userInfo
.
getUsername
());
otpK
eyUriFormat
.
setSecret
(
sharedSecret
);
otpK
eyUriFormat
.
setCounter
(
Long
.
parseLong
(
userInfo
.
getSharedCounter
()));
String
otpauth
=
otpK
eyUriFormat
.
format
(
userInfo
.
getUsername
());
byte
[]
byteSharedSecret
=
Base32Utils
.
decode
(
sharedSecret
);
String
hexSharedSecret
=
Hex
.
encodeHexString
(
byteSharedSecret
);
modelAndView
.
addObject
(
"id"
,
genRqCode
(
otpauth
));
modelAndView
.
addObject
(
"userInfo"
,
userInfo
);
modelAndView
.
addObject
(
"format"
,
k
eyUriFormat
);
modelAndView
.
addObject
(
"format"
,
otpK
eyUriFormat
);
modelAndView
.
addObject
(
"sharedSecret"
,
sharedSecret
);
modelAndView
.
addObject
(
"hexSharedSecret"
,
hexSharedSecret
);
return
modelAndView
;
...
...
@@ -145,7 +145,7 @@ public class OneTimePasswordController {
@RequestMapping
(
value
=
{
"gen/hotp"
})
public
ModelAndView
genhotp
()
{
UserInfo
userInfo
=
WebContext
.
getUserInfo
();
byte
[]
byteSharedSecret
=
OtpSecret
.
generate
(
k
eyUriFormat
.
getCrypto
());
byte
[]
byteSharedSecret
=
OtpSecret
.
generate
(
otpK
eyUriFormat
.
getCrypto
());
String
sharedSecret
=
Base32Utils
.
encode
(
byteSharedSecret
);
sharedSecret
=
passwordReciprocal
.
encode
(
sharedSecret
);
userInfo
.
setSharedSecret
(
sharedSecret
);
...
...
maxkey-webs/maxkey-web-maxkey/src/main/resources/application-http.properties
浏览文件 @
1b70eec8
...
...
@@ -176,10 +176,10 @@ spring.kafka.producer.value-serializer =org.apache.kafka.common.seriali
############################################################################
#SMS Message Login configuration #
#
SmsOtpAuthnYunxin SmsOtpAuthnAliyun SmsOtpAuthnTencentCloud
#
#
aliyun yunxin tencentcloud
#
############################################################################
#default
maxkey.otp.sms
=
${SMS_IMPL:SmsOtpAuthnY
unxin}
maxkey.otp.sms
.provider
=
${SMS_PROVIDER:y
unxin}
#aliyun
maxkey.otp.sms.aliyun.accesskeyid
=
${SMS_ALIYUN_ACCESSKEYID:94395d754eb55693043f5d6a2b772ef4}
maxkey.otp.sms.aliyun.accesssecret
=
${SMS_ALIYUN_ACCESSSECRET:05d5485357bc}
...
...
@@ -199,11 +199,11 @@ maxkey.otp.sms.tencentcloud.sign =${SMS_TENCENTCLOUD_SIGN:1486009
############################################################################
#Time-based One-Time Password configuration #
############################################################################
maxkey.otp.
keyuri.format.type
=
totp
maxkey.otp.
keyuri.format.digits
=
6
maxkey.otp.
keyuri.format.issuer
=
${OTP_KEYURI
_ISSUER:MaxKey}
maxkey.otp.
keyuri.format.domain
=
${maxkey.server.domain}
maxkey.otp.
keyuri.format.period
=
30
maxkey.otp.
policy.type
=
totp
maxkey.otp.
policy.digits
=
6
maxkey.otp.
policy.issuer
=
${OTP_POLICY
_ISSUER:MaxKey}
maxkey.otp.
policy.domain
=
${maxkey.server.domain}
maxkey.otp.
policy.period
=
30
############################################################################
#LDAP Login support configuration #
...
...
maxkey-webs/maxkey-web-maxkey/src/main/resources/application-https.properties
浏览文件 @
1b70eec8
...
...
@@ -178,10 +178,10 @@ spring.kafka.producer.value-serializer =org.apache.kafka.common.seriali
############################################################################
#SMS Message Login configuration #
#
SmsOtpAuthnYunxin SmsOtpAuthnAliyun SmsOtpAuthnTencentCloud
#
#
aliyun yunxin tencentcloud
#
############################################################################
#default
maxkey.otp.sms
=
${SMS_IMPL:SmsOtpAuthnY
unxin}
maxkey.otp.sms
.provider
=
${SMS_PROVIDER:y
unxin}
#aliyun
maxkey.otp.sms.aliyun.accesskeyid
=
${SMS_ALIYUN_ACCESSKEYID:94395d754eb55693043f5d6a2b772ef4}
maxkey.otp.sms.aliyun.accesssecret
=
${SMS_ALIYUN_ACCESSSECRET:05d5485357bc}
...
...
@@ -201,11 +201,11 @@ maxkey.otp.sms.tencentcloud.sign =${SMS_TENCENTCLOUD_SIGN:1486009
############################################################################
#Time-based One-Time Password configuration #
############################################################################
maxkey.otp.
keyuri.format.type
=
totp
maxkey.otp.
keyuri.format.digits
=
6
maxkey.otp.
keyuri.format.issuer
=
${OTP_KEYURI
_ISSUER:MaxKey}
maxkey.otp.
keyuri.format.domain
=
${maxkey.server.domain}
maxkey.otp.
keyuri.format.period
=
30
maxkey.otp.
policy.type
=
totp
maxkey.otp.
policy.digits
=
6
maxkey.otp.
policy.issuer
=
${OTP_POLICY
_ISSUER:MaxKey}
maxkey.otp.
policy.domain
=
${maxkey.server.domain}
maxkey.otp.
policy.period
=
30
############################################################################
#LDAP Login support configuration #
...
...
maxkey-webs/maxkey-web-maxkey/src/main/resources/log4j2.xml
浏览文件 @
1b70eec8
...
...
@@ -24,6 +24,8 @@
<Logger
level=
"INFO"
name=
"org.apache.logging"
></Logger>
<Logger
level=
"DEBUG"
name=
"org.maxkey"
></Logger>
<Logger
level=
"ERROR"
name=
"org.reflections.Reflections"
></Logger>
<Logger
level=
"OFF"
name=
"org.hibernate.validator.internal.util.Version"
></Logger>
<Root
level=
"INFO"
>
<AppenderRef
ref=
"consolePrint"
/>
...
...
maxkey-webs/maxkey-web-mgt/src/main/resources/application-http.properties
浏览文件 @
1b70eec8
...
...
@@ -157,6 +157,14 @@ spring.kafka.producer.key-serializer =org.apache.kafka.common.seriali
spring.kafka.producer.value-serializer
=
org.apache.kafka.common.serialization.StringSerializer
# partitioner
#spring.kafka.producer.properties.partitioner.class=com.felix.kafka.producer.CustomizePartitioner
############################################################################
#Time-based One-Time Password configuration #
############################################################################
maxkey.otp.policy.type
=
totp
maxkey.otp.policy.digits
=
6
maxkey.otp.policy.issuer
=
${OTP_POLICY_ISSUER:MaxKey}
maxkey.otp.policy.domain
=
${maxkey.server.domain}
maxkey.otp.policy.period
=
30
#############################################################################
#SAML V2.0 configuration #
...
...
maxkey-webs/maxkey-web-mgt/src/main/resources/log4j2.xml
浏览文件 @
1b70eec8
...
...
@@ -25,6 +25,7 @@
<Logger
level=
"DEBUG"
name=
"org.maxkey"
></Logger>
<Logger
level=
"DEBUG"
name=
"org.apache.mybatis.jpa"
></Logger>
<Logger
level=
"ERROR"
name=
"org.reflections.Reflections"
></Logger>
<Logger
level=
"OFF"
name=
"org.hibernate.validator.internal.util.Version"
></Logger>
<Root
level=
"INFO"
>
<AppenderRef
ref=
"consolePrint"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录