Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yujianwangzivayy
MaxKey
提交
e24b5982
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,体验更适合开发者的 AI 搜索 >>
提交
e24b5982
编写于
4月 25, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AuthenticationProvider
上级
d3b2f4da
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
88 addition
and
41 deletion
+88
-41
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java
...java/org/maxkey/authn/AbstractAuthenticationProvider.java
+5
-20
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/provider/AuthenticationProviderFactory.java
.../maxkey/authn/provider/AuthenticationProviderFactory.java
+60
-0
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java
...maxkey/autoconfigure/AuthenticationAutoConfiguration.java
+23
-21
未找到文件。
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java
浏览文件 @
e24b5982
...
...
@@ -18,7 +18,6 @@
package
org.maxkey.authn
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
org.maxkey.authn.jwt.AuthJwtService
;
import
org.maxkey.authn.online.OnlineTicket
;
...
...
@@ -52,6 +51,8 @@ public abstract class AbstractAuthenticationProvider {
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
AbstractAuthenticationProvider
.
class
);
public
static
String
PROVIDER_SUFFIX
=
"AuthenticationProvider"
;
public
class
AuthType
{
public
final
static
String
NORMAL
=
"normal"
;
public
final
static
String
TFA
=
"tfa"
;
...
...
@@ -59,11 +60,6 @@ public abstract class AbstractAuthenticationProvider {
public
final
static
String
TRUSTED
=
"trusted"
;
}
protected
static
String
PROVIDER_SUFFIX
=
"AuthenticationProvider"
;
private
static
HashMap
<
String
,
AbstractAuthenticationProvider
>
providers
=
new
HashMap
<
String
,
AbstractAuthenticationProvider
>();
protected
ApplicationConfig
applicationConfig
;
protected
AbstractAuthenticationRealm
authenticationRealm
;
...
...
@@ -94,24 +90,13 @@ public abstract class AbstractAuthenticationProvider {
}
public
Authentication
authenticate
(
LoginCredential
authentication
){
if
(
authentication
.
getAuthType
().
equalsIgnoreCase
(
"trusted"
))
{
//risk remove
return
null
;
}
AbstractAuthenticationProvider
provider
=
providers
.
get
(
authentication
.
getAuthType
()
+
PROVIDER_SUFFIX
);
return
provider
==
null
?
null
:
provider
.
doAuthenticate
(
authentication
);
return
null
;
}
public
Authentication
authenticate
(
LoginCredential
authentication
,
boolean
trusted
){
AbstractAuthenticationProvider
provider
=
providers
.
get
(
AuthType
.
TRUSTED
+
PROVIDER_SUFFIX
);
return
provider
.
doAuthenticate
(
authentication
);
public
Authentication
authenticate
(
LoginCredential
authentication
,
boolean
trusted
)
{
return
null
;
}
public
void
addAuthenticationProvider
(
AbstractAuthenticationProvider
provider
)
{
providers
.
put
(
provider
.
getProviderName
(),
provider
);
}
/**
* createOnlineSession
* @param credential
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/provider/AuthenticationProviderFactory.java
0 → 100644
浏览文件 @
e24b5982
/*
* 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.authn.provider
;
import
java.util.HashMap
;
import
org.maxkey.authn.AbstractAuthenticationProvider
;
import
org.maxkey.authn.LoginCredential
;
import
org.springframework.security.core.Authentication
;
public
class
AuthenticationProviderFactory
extends
AbstractAuthenticationProvider
{
private
static
HashMap
<
String
,
AbstractAuthenticationProvider
>
providers
=
new
HashMap
<
String
,
AbstractAuthenticationProvider
>();
@Override
public
Authentication
authenticate
(
LoginCredential
authentication
){
if
(
authentication
.
getAuthType
().
equalsIgnoreCase
(
"trusted"
))
{
//risk remove
return
null
;
}
AbstractAuthenticationProvider
provider
=
providers
.
get
(
authentication
.
getAuthType
()
+
PROVIDER_SUFFIX
);
return
provider
==
null
?
null
:
provider
.
doAuthenticate
(
authentication
);
}
@Override
public
Authentication
authenticate
(
LoginCredential
authentication
,
boolean
trusted
){
AbstractAuthenticationProvider
provider
=
providers
.
get
(
AuthType
.
TRUSTED
+
PROVIDER_SUFFIX
);
return
provider
.
doAuthenticate
(
authentication
);
}
public
void
addAuthenticationProvider
(
AbstractAuthenticationProvider
provider
)
{
providers
.
put
(
provider
.
getProviderName
(),
provider
);
}
@Override
public
String
getProviderName
()
{
return
"AuthenticationProviderFactory"
;
}
@Override
public
Authentication
doAuthenticate
(
LoginCredential
authentication
)
{
//AuthenticationProvider Factory do nothing
return
null
;
}
}
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/autoconfigure/AuthenticationAutoConfiguration.java
浏览文件 @
e24b5982
...
...
@@ -25,6 +25,7 @@ import org.maxkey.authn.jwt.InMemoryCongressService;
import
org.maxkey.authn.jwt.RedisCongressService
;
import
org.maxkey.authn.online.OnlineTicketService
;
import
org.maxkey.authn.online.OnlineTicketServiceFactory
;
import
org.maxkey.authn.provider.AuthenticationProviderFactory
;
import
org.maxkey.authn.provider.MobileAuthenticationProvider
;
import
org.maxkey.authn.provider.NormalAuthenticationProvider
;
import
org.maxkey.authn.provider.TrustedAuthenticationProvider
;
...
...
@@ -69,24 +70,34 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
@Bean
(
name
=
"authenticationProvider"
)
public
AbstractAuthenticationProvider
authenticationProvider
(
AbstractAuthenticationProvider
normalAuthenticationProvider
,
AbstractAuthenticationProvider
mobileAuthenticationProvider
,
AbstractAuthenticationProvider
trustedAuthenticationProvider
)
{
AuthenticationProviderFactory
authenticationProvider
=
new
AuthenticationProviderFactory
();
authenticationProvider
.
addAuthenticationProvider
(
normalAuthenticationProvider
);
authenticationProvider
.
addAuthenticationProvider
(
mobileAuthenticationProvider
);
authenticationProvider
.
addAuthenticationProvider
(
trustedAuthenticationProvider
);
return
authenticationProvider
;
}
@Bean
public
AbstractAuthenticationProvider
normalAuthenticationProvider
(
AbstractAuthenticationRealm
authenticationRealm
,
ApplicationConfig
applicationConfig
,
OnlineTicketService
onlineTicketServices
,
AuthJwtService
authJwtService
,
MomentaryService
momentaryService
)
{
_logger
.
debug
(
"init authentication Provider ."
);
NormalAuthenticationProvider
normal
=
new
NormalAuthenticationProvider
(
return
new
NormalAuthenticationProvider
(
authenticationRealm
,
applicationConfig
,
onlineTicketServices
,
authJwtService
,
momentaryService
);
normal
.
addAuthenticationProvider
(
normal
);
return
normal
;
}
@Bean
(
name
=
"mobileAuthenticationProvider"
)
...
...
@@ -94,38 +105,29 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
AbstractAuthenticationRealm
authenticationRealm
,
ApplicationConfig
applicationConfig
,
OtpAuthnService
otpAuthnService
,
OnlineTicketService
onlineTicketServices
,
AbstractAuthenticationProvider
authenticationProvider
OnlineTicketService
onlineTicketServices
)
{
MobileAuthenticationProvider
mobile
=
new
MobileAuthenticationProvider
(
_logger
.
debug
(
"init Mobile authentication Provider ."
);
return
new
MobileAuthenticationProvider
(
authenticationRealm
,
applicationConfig
,
otpAuthnService
,
onlineTicketServices
);
authenticationProvider
.
addAuthenticationProvider
(
mobile
);
_logger
.
debug
(
"init Mobile authentication Provider ."
);
return
mobile
;
}
@Bean
(
name
=
"trustedAuthenticationProvider"
)
public
AbstractAuthenticationProvider
trustedAuthenticationProvider
(
AbstractAuthenticationRealm
authenticationRealm
,
ApplicationConfig
applicationConfig
,
OnlineTicketService
onlineTicketServices
,
AbstractAuthenticationProvider
authenticationProvider
OnlineTicketService
onlineTicketServices
)
{
TrustedAuthenticationProvider
trusted
=
new
TrustedAuthenticationProvider
(
_logger
.
debug
(
"init Mobile authentication Provider ."
);
return
new
TrustedAuthenticationProvider
(
authenticationRealm
,
applicationConfig
,
onlineTicketServices
);
authenticationProvider
.
addAuthenticationProvider
(
trusted
);
_logger
.
debug
(
"init Mobile authentication Provider ."
);
return
trusted
;
}
@Bean
(
name
=
"authJwtService"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录