Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
0636df5d
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 搜索 >>
提交
0636df5d
编写于
9月 02, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CAS service ${errorMessage!} not registered .
上级
c2d7230e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
47 deletion
+59
-47
maxkey-persistence/src/main/java/org/maxkey/persistence/service/AppsCasDetailsService.java
...org/maxkey/persistence/service/AppsCasDetailsService.java
+3
-1
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasAuthorizeEndpoint.java
...a/org/maxkey/authz/cas/endpoint/CasAuthorizeEndpoint.java
+36
-37
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/interceptor/SingleSignOnInterceptor.java
...a/org/maxkey/web/interceptor/SingleSignOnInterceptor.java
+6
-0
maxkey-webs/maxkey-web-maxkey/src/main/resources/templates/views/authorize/cas_sso_submint.ftl
...n/resources/templates/views/authorize/cas_sso_submint.ftl
+14
-9
未找到文件。
maxkey-persistence/src/main/java/org/maxkey/persistence/service/AppsCasDetailsService.java
浏览文件 @
0636df5d
...
...
@@ -54,7 +54,9 @@ public class AppsCasDetailsService extends JpaBaseService<AppsCasDetails>{
details
=
detailsCache
.
getIfPresent
(
id
);
if
(
details
==
null
)
{
details
=
getMapper
().
getAppDetails
(
id
);
detailsCache
.
put
(
id
,
details
);
if
(
details
!=
null
)
{
detailsCache
.
put
(
id
,
details
);
}
}
}
else
{
details
=
getMapper
().
getAppDetails
(
id
);
...
...
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasAuthorizeEndpoint.java
浏览文件 @
0636df5d
...
...
@@ -37,8 +37,8 @@ import org.maxkey.web.WebConstants;
import
org.maxkey.web.WebContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -58,36 +58,41 @@ public class CasAuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
final
static
Logger
_logger
=
LoggerFactory
.
getLogger
(
CasAuthorizeEndpoint
.
class
);
@Operation
(
summary
=
"CAS页面跳转service认证接口"
,
description
=
"传递参数service"
,
method
=
"GET"
)
@
Reques
tMapping
(
CasConstants
.
ENDPOINT
.
ENDPOINT_LOGIN
)
public
ModelAndView
casLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
(
value
=
CasConstants
.
PARAMETER
.
SERVICE
,
required
=
false
)
String
casService
){
@
Ge
tMapping
(
CasConstants
.
ENDPOINT
.
ENDPOINT_LOGIN
)
public
ModelAndView
casLogin
(
@RequestParam
(
value
=
CasConstants
.
PARAMETER
.
SERVICE
,
required
=
false
)
String
casService
,
HttpServletRequest
request
,
HttpServletResponse
response
){
AppsCasDetails
casDetails
=
casDetailsService
.
getAppDetails
(
casService
,
true
);
AppsCasDetails
casDetails
=
casDetailsService
.
getAppDetails
(
casService
,
true
);
return
buildCasModelAndView
(
request
,
response
,
casDetails
,
casService
);
}
@Operation
(
summary
=
"CAS页面跳转应用ID认证接口"
,
description
=
"传递参数应用ID"
,
method
=
"GET"
)
@
Reques
tMapping
(
CasConstants
.
ENDPOINT
.
ENDPOINT_BASE
+
"/{id}"
)
public
ModelAndView
authorize
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
(
"id"
)
String
id
){
@
Ge
tMapping
(
CasConstants
.
ENDPOINT
.
ENDPOINT_BASE
+
"/{id}"
)
public
ModelAndView
authorize
(
@PathVariable
(
"id"
)
String
id
,
HttpServletRequest
request
,
HttpServletResponse
response
){
AppsCasDetails
casDetails
=
casDetailsService
.
getAppDetails
(
id
,
true
);
AppsCasDetails
casDetails
=
casDetailsService
.
getAppDetails
(
id
,
true
);
return
buildCasModelAndView
(
request
,
response
,
casDetails
,
casDetails
.
getCallbackUrl
());
return
buildCasModelAndView
(
request
,
response
,
casDetails
,
casDetails
==
null
?
id
:
casDetails
.
getCallbackUrl
());
}
private
ModelAndView
buildCasModelAndView
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AppsCasDetails
casDetails
,
String
casService
){
private
ModelAndView
buildCasModelAndView
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AppsCasDetails
casDetails
,
String
casService
){
if
(
casDetails
==
null
)
{
_logger
.
debug
(
"service {} not registered "
,
casService
);
ModelAndView
modelAndView
=
new
ModelAndView
(
"authorize/cas_sso_submint"
);
modelAndView
.
addObject
(
"errorMessage"
,
casService
);
return
modelAndView
;
}
_logger
.
debug
(
"
"
+
casDetails
);
_logger
.
debug
(
"
Detail {}"
,
casDetails
);
Map
<
String
,
String
>
parameterMap
=
WebContext
.
getRequestParameterMap
(
request
);
String
service
=
casService
;
_logger
.
debug
(
"CAS Parameter service = {}"
,
service
);
...
...
@@ -101,23 +106,21 @@ public class CasAuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
}
_logger
.
debug
(
"CAS service with Parameter : {}"
,
parameterMap
);
}
WebContext
.
setAttribute
(
CasConstants
.
PARAMETER
.
PARAMETER_MAP
,
parameterMap
);
WebContext
.
setAttribute
(
CasConstants
.
PARAMETER
.
PARAMETER_MAP
,
parameterMap
);
WebContext
.
setAttribute
(
CasConstants
.
PARAMETER
.
ENDPOINT_CAS_DETAILS
,
casDetails
);
WebContext
.
setAttribute
(
WebConstants
.
SINGLE_SIGN_ON_APP_ID
,
casDetails
.
getId
());
WebContext
.
setAttribute
(
WebConstants
.
AUTHORIZE_SIGN_ON_APP
,
casDetails
);
return
WebContext
.
redirect
(
CasConstants
.
ENDPOINT
.
ENDPOINT_SERVICE_TICKET_GRANTING
);
}
@RequestMapping
(
CasConstants
.
ENDPOINT
.
ENDPOINT_SERVICE_TICKET_GRANTING
)
public
ModelAndView
grantingTicket
(
Principal
principal
,
@AuthenticationPrincipal
Object
user
,
HttpServletRequest
request
,
HttpServletResponse
response
){
public
ModelAndView
grantingTicket
(
Principal
principal
,
HttpServletRequest
request
,
HttpServletResponse
response
){
ModelAndView
modelAndView
=
new
ModelAndView
(
"authorize/cas_sso_submint"
);
AppsCasDetails
casDetails
=
(
AppsCasDetails
)
WebContext
.
getAttribute
(
CasConstants
.
PARAMETER
.
ENDPOINT_CAS_DETAILS
);
ServiceTicketImpl
serviceTicket
=
new
ServiceTicketImpl
(
AuthorizationUtils
.
getAuthentication
(),
casDetails
);
String
ticket
=
ticketServices
.
createTicket
(
serviceTicket
,
casDetails
.
getExpires
());
...
...
@@ -150,7 +153,7 @@ public class CasAuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
}
if
(
casDetails
.
getLogoutType
()==
LogoutType
.
BACK_CHANNEL
)
{
String
sessionId
=
AuthorizationUtils
.
getPrincipal
().
getSession
().
getId
();
String
sessionId
=
AuthorizationUtils
.
getPrincipal
().
getSession
().
getId
();
Session
session
=
sessionManager
.
get
(
sessionId
);
//set cas ticket as OnlineTicketId
casDetails
.
setOnlineTicket
(
ticket
);
...
...
@@ -159,8 +162,6 @@ public class CasAuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
}
_logger
.
debug
(
"redirect to CAS Client URL {}"
,
callbackUrl
);
ModelAndView
modelAndView
=
new
ModelAndView
(
"authorize/cas_sso_submint"
);
modelAndView
.
addObject
(
"callbackUrl"
,
callbackUrl
.
toString
());
return
modelAndView
;
}
...
...
@@ -174,11 +175,9 @@ public class CasAuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
*/
@Operation
(
summary
=
"CAS注销接口"
,
description
=
"CAS注销接口"
,
method
=
"GET"
)
@RequestMapping
(
CasConstants
.
ENDPOINT
.
ENDPOINT_LOGOUT
)
public
ModelAndView
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
(
value
=
CasConstants
.
PARAMETER
.
SERVICE
,
required
=
false
)
String
casService
){
StringBuffer
logoutUrl
=
new
StringBuffer
(
"/force/logout"
);
public
ModelAndView
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
(
value
=
CasConstants
.
PARAMETER
.
SERVICE
,
required
=
false
)
String
casService
){
StringBuffer
logoutUrl
=
new
StringBuffer
(
"force/logout"
);
if
(
StringUtils
.
isNotBlank
(
casService
)){
logoutUrl
.
append
(
"?"
).
append
(
"redirect_uri="
).
append
(
casService
);
}
...
...
maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/interceptor/SingleSignOnInterceptor.java
浏览文件 @
0636df5d
...
...
@@ -106,6 +106,12 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
request
.
getParameter
(
OAuth2Constants
.
PARAMETER
.
CLIENT_ID
),
true
);
}
}
if
(
app
==
null
)
{
_logger
.
debug
(
"preHandle app is not exist . "
);
return
true
;
}
SignPrincipal
principal
=
AuthorizationUtils
.
getPrincipal
();
if
(
principal
!=
null
&&
app
!=
null
)
{
if
(
principal
.
getGrantedAuthorityApps
().
contains
(
new
SimpleGrantedAuthority
(
app
.
getId
())))
{
...
...
maxkey-webs/maxkey-web-maxkey/src/main/resources/templates/views/authorize/cas_sso_submint.ftl
浏览文件 @
0636df5d
...
...
@@ -5,24 +5,29 @@
<
#include
"
authorize_common.ftl
"
>
<script
type=
"text/javascript"
>
function
redirectToLogin
(){
<
#
if
callbackUrl
??
>
var
srcUrl
=
window
.
top
.
location
.
href
;
srcUrl
=
srcUrl
.
substring
(
srcUrl
.
indexOf
(
"
#
"
));
var
callbackUrl
=
"
${callbackUrl}
"
;
var
callbackUrl
=
"
${callbackUrl
!
}
"
;
if
(
srcUrl
.
indexOf
(
"
#
"
)
>-
1
){
callbackUrl
=
callbackUrl
+
srcUrl
;
}
window
.
top
.
location
.
href
=
callbackUrl
;
<
/#if
>
}
</script>
</head>
<body
onload=
"redirectToLogin()"
style=
"display:none"
>
<form
id=
"cas_sso_form"
name=
"cas_sso_form"
action=
"${callbackUrl}"
method=
"get"
>
<table
style=
"width:100%"
>
<tr>
<td
colspan=
"2"
><input
type=
"submit"
name=
"submitBtn"
value=
"Continue..."
/></td>
</tr>
</table>
</form>
<body
onload=
"redirectToLogin()"
>
<form
id=
"cas_sso_form"
name=
"cas_sso_form"
action=
"${callbackUrl!}"
method=
"get"
style=
"display:none"
>
<table
style=
"width:100%"
>
<tr>
<td
colspan=
"2"
><input
type=
"submit"
name=
"submitBtn"
value=
"Continue..."
/></td>
</tr>
</table>
</form>
<
#if
errorMessage
??
>
service ${errorMessage!} not registered .
</
#
if>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录