Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
8db33b0e
MaxKey
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
MaxKey
9 个月 前同步成功
通知
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 搜索 >>
提交
8db33b0e
编写于
4月 28, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ROLE_ALL_USER
上级
b1b021e6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
25 addition
and
25 deletion
+25
-25
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java
...java/org/maxkey/authn/AbstractAuthenticationProvider.java
+2
-1
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/session/InMemorySessionManager.java
...java/org/maxkey/authn/session/InMemorySessionManager.java
+1
-1
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/session/RedisSessionManager.java
...in/java/org/maxkey/authn/session/RedisSessionManager.java
+3
-3
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/AuthorizationUtils.java
...rc/main/java/org/maxkey/authn/web/AuthorizationUtils.java
+4
-19
maxkey-core/src/main/java/org/maxkey/entity/Groups.java
maxkey-core/src/main/java/org/maxkey/entity/Groups.java
+11
-0
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/access/contorller/GroupsController.java
...va/org/maxkey/web/access/contorller/GroupsController.java
+4
-1
未找到文件。
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java
浏览文件 @
8db33b0e
...
@@ -138,7 +138,8 @@ public abstract class AbstractAuthenticationProvider {
...
@@ -138,7 +138,8 @@ public abstract class AbstractAuthenticationProvider {
//create session
//create session
this
.
sessionManager
.
create
(
session
.
getId
(),
session
);
this
.
sessionManager
.
create
(
session
.
getId
(),
session
);
AuthorizationUtils
.
setSession
(
session
);
//set Authentication to http session
AuthorizationUtils
.
setAuthentication
(
authenticationToken
);
return
authenticationToken
;
return
authenticationToken
;
}
}
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/session/InMemorySessionManager.java
浏览文件 @
8db33b0e
...
@@ -85,7 +85,7 @@ public class InMemorySessionManager extends AbstractSessionManager{
...
@@ -85,7 +85,7 @@ public class InMemorySessionManager extends AbstractSessionManager{
LocalTime
currentTime
=
LocalTime
.
now
();
LocalTime
currentTime
=
LocalTime
.
now
();
Duration
duration
=
Duration
.
between
(
currentTime
,
session
.
getLastAccessTime
());
Duration
duration
=
Duration
.
between
(
currentTime
,
session
.
getLastAccessTime
());
_logger
.
trace
(
"
OnlineTicket
duration "
+
duration
.
getSeconds
());
_logger
.
trace
(
"
Session
duration "
+
duration
.
getSeconds
());
if
(
duration
.
getSeconds
()
>
Session
.
MAX_EXPIRY_DURATION
)
{
if
(
duration
.
getSeconds
()
>
Session
.
MAX_EXPIRY_DURATION
)
{
session
.
setLastAccessTime
(
currentTime
);
session
.
setLastAccessTime
(
currentTime
);
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/session/RedisSessionManager.java
浏览文件 @
8db33b0e
...
@@ -59,8 +59,8 @@ public class RedisSessionManager extends AbstractSessionManager {
...
@@ -59,8 +59,8 @@ public class RedisSessionManager extends AbstractSessionManager {
@Override
@Override
public
void
create
(
String
sessionId
,
Session
ticket
)
{
public
void
create
(
String
sessionId
,
Session
ticket
)
{
RedisConnection
conn
=
connectionFactory
.
getConnection
();
RedisConnection
conn
=
connectionFactory
.
getConnection
();
conn
.
setexObject
(
PREFIX
+
sessionId
,
serviceTicketValiditySeconds
,
ticket
);
conn
.
setexObject
(
PREFIX
+
sessionId
,
serviceTicketValiditySeconds
,
ticket
);
conn
.
close
();
conn
.
close
();
}
}
...
@@ -101,7 +101,7 @@ public class RedisSessionManager extends AbstractSessionManager {
...
@@ -101,7 +101,7 @@ public class RedisSessionManager extends AbstractSessionManager {
LocalTime
currentTime
=
LocalTime
.
now
();
LocalTime
currentTime
=
LocalTime
.
now
();
Duration
duration
=
Duration
.
between
(
currentTime
,
session
.
getLastAccessTime
());
Duration
duration
=
Duration
.
between
(
currentTime
,
session
.
getLastAccessTime
());
_logger
.
trace
(
"
OnlineTicket
duration "
+
duration
.
getSeconds
());
_logger
.
trace
(
"
Session
duration "
+
duration
.
getSeconds
());
if
(
duration
.
getSeconds
()
>
Session
.
MAX_EXPIRY_DURATION
)
{
if
(
duration
.
getSeconds
()
>
Session
.
MAX_EXPIRY_DURATION
)
{
session
.
setLastAccessTime
(
currentTime
);
session
.
setLastAccessTime
(
currentTime
);
...
...
maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/web/AuthorizationUtils.java
浏览文件 @
8db33b0e
...
@@ -44,7 +44,7 @@ public class AuthorizationUtils {
...
@@ -44,7 +44,7 @@ public class AuthorizationUtils {
AuthJwtService
authJwtService
,
AuthJwtService
authJwtService
,
SessionManager
sessionManager
SessionManager
sessionManager
)
throws
ParseException
{
)
throws
ParseException
{
if
(
get
Sess
ion
()
==
null
)
{
if
(
get
Authenticat
ion
()
==
null
)
{
Cookie
authCookie
=
WebContext
.
getCookie
(
request
,
Authorization_Cookie
);
Cookie
authCookie
=
WebContext
.
getCookie
(
request
,
Authorization_Cookie
);
if
(
authCookie
!=
null
)
{
if
(
authCookie
!=
null
)
{
String
authorization
=
authCookie
.
getValue
();
String
authorization
=
authCookie
.
getValue
();
...
@@ -59,7 +59,7 @@ public class AuthorizationUtils {
...
@@ -59,7 +59,7 @@ public class AuthorizationUtils {
AuthJwtService
authJwtService
,
AuthJwtService
authJwtService
,
SessionManager
sessionManager
SessionManager
sessionManager
)
throws
ParseException
{
)
throws
ParseException
{
if
(
get
Sess
ion
()
==
null
)
{
if
(
get
Authenticat
ion
()
==
null
)
{
String
authorization
=
AuthorizationHeaderUtils
.
resolveBearer
(
request
);
String
authorization
=
AuthorizationHeaderUtils
.
resolveBearer
(
request
);
if
(
authorization
!=
null
)
{
if
(
authorization
!=
null
)
{
doJwtAuthenticate
(
authorization
,
authJwtService
,
sessionManager
);
doJwtAuthenticate
(
authorization
,
authJwtService
,
sessionManager
);
...
@@ -76,28 +76,12 @@ public class AuthorizationUtils {
...
@@ -76,28 +76,12 @@ public class AuthorizationUtils {
String
sessionId
=
authJwtService
.
resolveJWTID
(
authorization
);
String
sessionId
=
authJwtService
.
resolveJWTID
(
authorization
);
Session
session
=
sessionManager
.
get
(
sessionId
);
Session
session
=
sessionManager
.
get
(
sessionId
);
if
(
session
!=
null
)
{
if
(
session
!=
null
)
{
setSession
(
session
);
setAuthentication
(
session
.
getAuthentication
());
setAuthentication
(
session
.
getAuthentication
());
}
}
}
}
}
}
//set session to http session
public
static
void
setSession
(
Session
session
)
{
WebContext
.
setAttribute
(
WebConstants
.
SESSION
,
session
);
}
public
static
Session
getSession
()
{
Session
session
=
getSession
(
WebContext
.
getRequest
());
return
session
;
}
//get session to http session
public
static
Session
getSession
(
HttpServletRequest
request
)
{
Session
session
=
(
Session
)
request
.
getSession
().
getAttribute
(
WebConstants
.
SESSION
);
return
session
;
}
public
static
Authentication
getAuthentication
()
{
public
static
Authentication
getAuthentication
()
{
Authentication
authentication
=
(
Authentication
)
getAuthentication
(
WebContext
.
getRequest
());
Authentication
authentication
=
(
Authentication
)
getAuthentication
(
WebContext
.
getRequest
());
return
authentication
;
return
authentication
;
...
@@ -108,12 +92,13 @@ public class AuthorizationUtils {
...
@@ -108,12 +92,13 @@ public class AuthorizationUtils {
return
authentication
;
return
authentication
;
}
}
//set Authentication to http session
public
static
void
setAuthentication
(
Authentication
authentication
)
{
public
static
void
setAuthentication
(
Authentication
authentication
)
{
WebContext
.
setAttribute
(
WebConstants
.
AUTHENTICATION
,
authentication
);
WebContext
.
setAttribute
(
WebConstants
.
AUTHENTICATION
,
authentication
);
}
}
public
static
boolean
isAuthenticated
()
{
public
static
boolean
isAuthenticated
()
{
return
get
Sess
ion
()
!=
null
;
return
get
Authenticat
ion
()
!=
null
;
}
}
public
static
boolean
isNotAuthenticated
()
{
public
static
boolean
isNotAuthenticated
()
{
...
...
maxkey-core/src/main/java/org/maxkey/entity/Groups.java
浏览文件 @
8db33b0e
...
@@ -166,6 +166,17 @@ public class Groups extends JpaBaseEntity implements Serializable {
...
@@ -166,6 +166,17 @@ public class Groups extends JpaBaseEntity implements Serializable {
this
.
status
=
status
;
this
.
status
=
status
;
}
}
/**
* ROLE_ALL_USER must be
* 1, dynamic
* 2, all orgIdsList
* 3, not filters
*/
public
void
setDefaultAllUser
()
{
this
.
dynamic
=
"1"
;
this
.
orgIdsList
=
""
;
this
.
filters
=
""
;
}
public
String
getDynamic
()
{
public
String
getDynamic
()
{
return
dynamic
;
return
dynamic
;
...
...
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/access/contorller/GroupsController.java
浏览文件 @
8db33b0e
/*
/*
* Copyright [202
0
] [MaxKey of copyright http://www.maxkey.top]
* Copyright [202
2
] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -92,6 +92,9 @@ public class GroupsController {
...
@@ -92,6 +92,9 @@ public class GroupsController {
@RequestMapping
(
value
={
"/update"
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@RequestMapping
(
value
={
"/update"
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<?>
update
(
@RequestBody
Groups
group
,
@CurrentUser
UserInfo
currentUser
)
{
public
ResponseEntity
<?>
update
(
@RequestBody
Groups
group
,
@CurrentUser
UserInfo
currentUser
)
{
_logger
.
debug
(
"-update group :"
+
group
);
_logger
.
debug
(
"-update group :"
+
group
);
if
(
group
.
getId
().
equalsIgnoreCase
(
"ROLE_ALL_USER"
))
{
group
.
setDefaultAllUser
();
}
group
.
setInstId
(
currentUser
.
getInstId
());
group
.
setInstId
(
currentUser
.
getInstId
());
if
(
groupsService
.
update
(
group
))
{
if
(
groupsService
.
update
(
group
))
{
groupsService
.
refreshDynamicGroups
(
group
);
groupsService
.
refreshDynamicGroups
(
group
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录