Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sh-ds
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李良停
sh-ds
Commits
ec1161da
Commit
ec1161da
authored
Mar 17, 2021
by
喻春霖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
789dd4bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
110 deletions
+57
-110
AuthController.java
...eall/eden/authcenter/agent/controller/AuthController.java
+46
-99
ds.html
eden-authcenter-agent/src/main/resources/templates/ds.html
+11
-11
No files found.
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/AuthController.java
View file @
ec1161da
...
@@ -38,7 +38,7 @@ import java.util.function.Function;
...
@@ -38,7 +38,7 @@ import java.util.function.Function;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Controller
@Controller
@RequestMapping
(
"
auth
"
)
@RequestMapping
(
"
/
"
)
public
class
AuthController
{
public
class
AuthController
{
Logger
logger
=
Logger
.
getLogger
(
AuthController
.
class
);
Logger
logger
=
Logger
.
getLogger
(
AuthController
.
class
);
...
@@ -53,108 +53,55 @@ public class AuthController {
...
@@ -53,108 +53,55 @@ public class AuthController {
private
AuthLogService
authLogService
;
private
AuthLogService
authLogService
;
// @RequestMapping("index")
// public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
@RequestMapping
(
value
=
{
""
,
"auth"
,
"auth/index"
})
// ModelAndView modelAndView = new ModelAndView();
// modelAndView.setViewName("index2");
// Map<String, ClientItem> clientItemMap = oauthClient.getClients().stream().collect(Collectors.toMap(ClientItem::getClientId, Function.identity()));
// try {
// String clientId = request.getParameter("client_id");
// String returnUrl = request.getParameter("redirect_uri");
// ClientItem clientItem = clientItemMap.get(clientId);
// AuthLog authLog = new AuthLog();
// authLog.setLogType(LogType.login);
// if (null == clientItem) {
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "client_id为空或者不正确");
// return modelAndView;
// }
// authLog.setClientId(clientId);
// authLog.setAuthSource(clientItem.getClientName());
// String sign = request.getParameter("sign");
// String signOrigin = clientItem.getClientId() + "$$" + clientItem.getClientSecret();
//
// String md5Hex = EncodeUtil.md5(signOrigin);
// if (!Objects.equals(sign, md5Hex)) {
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "请求不合法");
// return modelAndView;
// }
// if (StringUtils.isEmpty(returnUrl)) {
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "登录成功回调地址为空");
// return modelAndView;
// }
// String loginType = request.getParameter("login_type");
// if(StringUtils.isNotEmpty(loginType) && OauthType.getValue(loginType)!=null) {
// OauthConfigItem oauthConfigItem = oauthConfig.getItems().get(OauthType.getValue(loginType).getCode());
// authLog.setFowardUrl(oauthConfigItem.getOauthUrl());
// authLog.setOauthType(OauthType.getValue(loginType).getCode());
// // 阅览室日志分离
// ClientItem item = clientItemMap.get("readingroomClientId");
// authLog.setAuthSource(item.getClientName());
// authLogService.save(authLog);
// response.sendRedirect(generateLoginUrl(returnUrl, OauthType.getValue(loginType).getCode(), authLog.getId()));
// return null;
// } else {
// authLogService.save(authLog);
// String url1 = generateLoginUrl(returnUrl, OauthType.dianjiaoguan.getCode(), authLog.getId());
// modelAndView.addObject("loginUrl1", url1);
// String url2 = generateLoginUrl(returnUrl, OauthType.edenoperation.getCode(), authLog.getId());
// modelAndView.addObject("loginUrl2", url2);
// modelAndView.addObject("logId", authLog.getId());
// }
// } catch (Exception e) {
// e.printStackTrace();
// modelAndView.setViewName("error");
// modelAndView.addObject("message", "未知错误");
// }
// return modelAndView;
// }
@RequestMapping
(
"index"
)
public
ModelAndView
index
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
ModelAndView
index
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ModelAndView
modelAndView
=
new
ModelAndView
();
ModelAndView
modelAndView
=
new
ModelAndView
();
modelAndView
.
setViewName
(
"ds"
);
modelAndView
.
setViewName
(
"ds"
);
Map
<
String
,
ClientItem
>
clientItemMap
=
oauthClient
.
getClients
().
stream
().
collect
(
Collectors
.
toMap
(
ClientItem:
:
getClientId
,
Function
.
identity
()));
Map
<
String
,
ClientItem
>
clientItemMap
=
oauthClient
.
getClients
().
stream
().
collect
(
Collectors
.
toMap
(
ClientItem:
:
getClientId
,
Function
.
identity
()));
try
{
try
{
String
clientId
=
request
.
getParameter
(
"client_id"
);
String
clientId
=
request
.
getParameter
(
"client_id"
);
String
returnUrl
=
request
.
getParameter
(
"redirect_uri"
);
String
returnUrl
=
request
.
getParameter
(
"redirect_uri"
);
ClientItem
clientItem
=
clientItemMap
.
get
(
clientId
);
AuthLog
authLog
=
new
AuthLog
();
AuthLog
authLog
=
new
AuthLog
();
authLog
.
setLogType
(
LogType
.
login
);
authLog
.
setLogType
(
LogType
.
login
);
if
(
null
==
clientItem
)
{
if
(
StringUtils
.
isNotEmpty
(
clientId
)){
modelAndView
.
setViewName
(
"error"
);
modelAndView
.
addObject
(
"message"
,
"client_id为空或者不正确"
);
return
modelAndView
;
}
authLog
.
setClientId
(
clientId
);
authLog
.
setAuthSource
(
clientItem
.
getClientName
());
String
sign
=
request
.
getParameter
(
"sign"
);
String
signOrigin
=
clientItem
.
getClientId
()
+
"$$"
+
clientItem
.
getClientSecret
();
String
md5Hex
=
EncodeUtil
.
md5
(
signOrigin
);
ClientItem
clientItem
=
clientItemMap
.
get
(
clientId
);
if
(!
Objects
.
equals
(
sign
,
md5Hex
))
{
if
(
null
==
clientItem
)
{
modelAndView
.
setViewName
(
"error"
);
modelAndView
.
setViewName
(
"error"
);
modelAndView
.
addObject
(
"message"
,
"请求不合法"
);
modelAndView
.
addObject
(
"message"
,
"client_id为空或者不正确"
);
return
modelAndView
;
return
modelAndView
;
}
}
if
(
StringUtils
.
isEmpty
(
returnUrl
))
{
authLog
.
setClientId
(
clientId
);
modelAndView
.
setViewName
(
"error"
);
authLog
.
setAuthSource
(
clientItem
.
getClientName
());
modelAndView
.
addObject
(
"message"
,
"登录成功回调地址为空"
);
String
sign
=
request
.
getParameter
(
"sign"
);
return
modelAndView
;
String
signOrigin
=
clientItem
.
getClientId
()
+
"$$"
+
clientItem
.
getClientSecret
();
}
String
loginType
=
request
.
getParameter
(
"login_type"
);
String
md5Hex
=
EncodeUtil
.
md5
(
signOrigin
);
OauthType
oauthType
=
OauthType
.
getValue
(
loginType
);
if
(!
Objects
.
equals
(
sign
,
md5Hex
))
{
if
(
StringUtils
.
isNotEmpty
(
loginType
)
&&
oauthType
!=
null
)
{
modelAndView
.
setViewName
(
"error"
);
if
(
StringUtils
.
isNotEmpty
(
returnUrl
)
&&
returnUrl
.
contains
(
"readinglab"
)){
modelAndView
.
addObject
(
"message"
,
"请求不合法"
);
// 阅览室日志分离
return
modelAndView
;
ClientItem
item
=
clientItemMap
.
get
(
"readingroomClientId"
);
}
authLog
.
setAuthSource
(
item
.
getClientName
());
if
(
StringUtils
.
isEmpty
(
returnUrl
))
{
modelAndView
.
setViewName
(
"error"
);
modelAndView
.
addObject
(
"message"
,
"登录成功回调地址为空"
);
return
modelAndView
;
}
String
loginType
=
request
.
getParameter
(
"login_type"
);
OauthType
oauthType
=
OauthType
.
getValue
(
loginType
);
if
(
StringUtils
.
isNotEmpty
(
loginType
)
&&
oauthType
!=
null
)
{
if
(
StringUtils
.
isNotEmpty
(
returnUrl
)
&&
returnUrl
.
contains
(
"readinglab"
)){
// 阅览室日志分离
ClientItem
item
=
clientItemMap
.
get
(
"readingroomClientId"
);
authLog
.
setAuthSource
(
item
.
getClientName
());
}
modelAndView
.
addObject
(
"loginType"
,
loginType
);
}
else
{
modelAndView
.
addObject
(
"loginType"
,
""
);
}
}
modelAndView
.
addObject
(
"loginType"
,
loginType
);
}
else
{
modelAndView
.
addObject
(
"loginType"
,
""
);
}
}
authLogService
.
save
(
authLog
);
authLogService
.
save
(
authLog
);
...
@@ -175,7 +122,7 @@ public class AuthController {
...
@@ -175,7 +122,7 @@ public class AuthController {
return
modelAndView
;
return
modelAndView
;
}
}
@RequestMapping
(
"tologin"
)
@RequestMapping
(
"
auth/
tologin"
)
public
ModelAndView
toLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
ModelAndView
toLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ModelAndView
modelAndView
=
new
ModelAndView
();
ModelAndView
modelAndView
=
new
ModelAndView
();
String
loginUrl
=
request
.
getParameter
(
"loginUrl"
);
String
loginUrl
=
request
.
getParameter
(
"loginUrl"
);
...
@@ -212,7 +159,7 @@ public class AuthController {
...
@@ -212,7 +159,7 @@ public class AuthController {
return
modelAndView
;
return
modelAndView
;
}
}
@RequestMapping
(
"logout"
)
@RequestMapping
(
"
auth/
logout"
)
public
ModelAndView
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
ModelAndView
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ModelAndView
modelAndView
=
new
ModelAndView
();
ModelAndView
modelAndView
=
new
ModelAndView
();
modelAndView
.
setViewName
(
"logout"
);
modelAndView
.
setViewName
(
"logout"
);
...
@@ -279,7 +226,7 @@ public class AuthController {
...
@@ -279,7 +226,7 @@ public class AuthController {
return
modelAndView
;
return
modelAndView
;
}
}
@RequestMapping
(
value
=
"loginsuccess"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"
auth/
loginsuccess"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
loginsuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
ModelAndView
modelAndView
)
{
public
ModelAndView
loginsuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
ModelAndView
modelAndView
)
{
modelAndView
.
setViewName
(
"loginsuccess"
);
modelAndView
.
setViewName
(
"loginsuccess"
);
String
code
=
request
.
getParameter
(
"code"
);
String
code
=
request
.
getParameter
(
"code"
);
...
@@ -364,7 +311,7 @@ public class AuthController {
...
@@ -364,7 +311,7 @@ public class AuthController {
return
modelAndView
;
return
modelAndView
;
}
}
@RequestMapping
(
value
=
"idp/loginsuccess"
)
@RequestMapping
(
value
=
"
auth/
idp/loginsuccess"
)
public
ModelAndView
idploginsuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
ModelAndView
modelAndView
)
{
public
ModelAndView
idploginsuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
ModelAndView
modelAndView
)
{
modelAndView
.
setViewName
(
"loginsuccess"
);
modelAndView
.
setViewName
(
"loginsuccess"
);
String
code
=
request
.
getParameter
(
"code"
);
String
code
=
request
.
getParameter
(
"code"
);
...
@@ -431,7 +378,7 @@ public class AuthController {
...
@@ -431,7 +378,7 @@ public class AuthController {
}
}
@RequestMapping
(
value
=
"logoutsuccess"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"
auth/
logoutsuccess"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
loginoutsuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
ModelAndView
modelAndView
)
throws
IOException
{
public
ModelAndView
loginoutsuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
ModelAndView
modelAndView
)
throws
IOException
{
String
returnUrl
=
request
.
getParameter
(
"return_url"
);
String
returnUrl
=
request
.
getParameter
(
"return_url"
);
if
(
StringUtils
.
isNotEmpty
(
returnUrl
)){
if
(
StringUtils
.
isNotEmpty
(
returnUrl
)){
...
@@ -591,7 +538,7 @@ public class AuthController {
...
@@ -591,7 +538,7 @@ public class AuthController {
return
newUrl
;
return
newUrl
;
}
}
@RequestMapping
(
"shauth"
)
@RequestMapping
(
"
auth/
shauth"
)
public
ModelAndView
chineseallLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
ModelAndView
chineseallLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ModelAndView
modelAndView
=
new
ModelAndView
();
ModelAndView
modelAndView
=
new
ModelAndView
();
modelAndView
.
setViewName
(
"toward"
);
modelAndView
.
setViewName
(
"toward"
);
...
@@ -637,7 +584,7 @@ public class AuthController {
...
@@ -637,7 +584,7 @@ public class AuthController {
return
modelAndView
;
return
modelAndView
;
}
}
@RequestMapping
(
"shlogout"
)
@RequestMapping
(
"
auth/
shlogout"
)
public
ModelAndView
shLogout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
ModelAndView
shLogout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
ModelAndView
modelAndView
=
new
ModelAndView
();
ModelAndView
modelAndView
=
new
ModelAndView
();
modelAndView
.
setViewName
(
"logout"
);
modelAndView
.
setViewName
(
"logout"
);
...
...
eden-authcenter-agent/src/main/resources/templates/ds.html
View file @
ec1161da
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<html
class=
"no-js"
xmlns:th=
"http://www.w3.org/1999/xhtml"
>
<!--<![endif]-->
<html
class=
"no-js"
xmlns:th=
"http://www.w3.org/1999/xhtml"
>
<!--<![endif]-->
<head>
<head>
<script
type=
"text/javascript"
src=
"../static/js/browser.js
"
></script>
<script
type=
"text/javascript"
th:src=
"@{/static/js/browser.js}
"
></script>
<script
th:inline=
"javascript"
>
<script
th:inline=
"javascript"
>
/*<![CDATA[*/
/*<![CDATA[*/
var
loginUrl1
=
[[
$
{
loginUrl1
}]];
var
loginUrl1
=
[[
$
{
loginUrl1
}]];
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
window
.
location
.
href
=
baseUrl
+
idp
+
"&loginUrl="
+
encodeURIComponent
(
loginUrl3
+
"&auth_source="
+
idp
)
+
"&browser="
+
info
.
browser
+
"&device="
+
info
.
device
+
"&os="
+
info
.
os
+
"&version="
+
info
.
version
;
window
.
location
.
href
=
baseUrl
+
idp
+
"&loginUrl="
+
encodeURIComponent
(
loginUrl3
+
"&auth_source="
+
idp
)
+
"&browser="
+
info
.
browser
+
"&device="
+
info
.
device
+
"&os="
+
info
.
os
+
"&version="
+
info
.
version
;
}
}
}
}
if
(
loginType
.
length
>
0
){
if
(
loginType
&&
loginType
.
length
>
0
){
toLogin
(
loginType
);
toLogin
(
loginType
);
}
}
</script>
</script>
...
@@ -64,29 +64,29 @@
...
@@ -64,29 +64,29 @@
<div
class=
"ds-content-city-float"
>
<div
class=
"ds-content-city-float"
>
<p>
市认证源
</p>
<p>
市认证源
</p>
<button
onclick=
"toLogin('edenoperation')"
class=
"logo-btn city-btn"
<button
onclick=
"toLogin('edenoperation')"
class=
"logo-btn city-btn"
style=
"background: white url('../static/img/logo-shszjc.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-shszjc.png} +')'
"
type=
"button"
></button>
<button
onclick=
"toLogin('dianjiaoguan')"
class=
"logo-btn city-btn"
<button
onclick=
"toLogin('dianjiaoguan')"
class=
"logo-btn city-btn"
style=
"background: white url('../static/img/logo-tyrz.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-tyrz.png} +')'
"
type=
"button"
></button>
</div>
</div>
</div>
</div>
<div
class=
"ds-divide-line"
></div>
<div
class=
"ds-divide-line"
></div>
<div
class=
"ds-content-district"
>
<div
class=
"ds-content-district"
>
<p>
区认证源
</p>
<p>
区认证源
</p>
<div>
<div>
<button
onclick=
"toLogin('qpjy')"
class=
"logo-btn idp-btn"
style=
"background: url('../static/img/logo-qp.png')
"
<button
onclick=
"toLogin('qpjy')"
class=
"logo-btn idp-btn"
th:style=
"'background: url('+@{/static/img/logo-qp.png} +')'
"
type=
"button"
></button>
type=
"button"
></button>
<button
onclick=
"toLogin('jsjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
<button
onclick=
"toLogin('jsjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
style=
"background: url('../static/img/logo-js.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-js.png} +')'
"
type=
"button"
></button>
<button
onclick=
"toLogin('hpjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
<button
onclick=
"toLogin('hpjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
style=
"background: url('../static/img/logo-hp.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-hp.png} +')'
"
type=
"button"
></button>
<button
onclick=
"toLogin('fxjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
<button
onclick=
"toLogin('fxjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
style=
"background: url('../static/img/logo-fx.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-fx.png} +')'
"
type=
"button"
></button>
<button
onclick=
"toLogin('pdjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
<button
onclick=
"toLogin('pdjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
style=
"background: url('../static/img/logo-pd.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-pd.png} +')'
"
type=
"button"
></button>
<button
onclick=
"toLogin('ypjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
<button
onclick=
"toLogin('ypjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
style=
"background: url('../static/img/logo-yp.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-yp.png} +')'
"
type=
"button"
></button>
<button
onclick=
"toLogin('cnjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
<button
onclick=
"toLogin('cnjy')"
class=
"logo-btn idp-btn logo-btn-mask"
disabled=
"disabled"
style=
"background: url('../static/img/logo-cn.png')
"
type=
"button"
></button>
th:style=
"'background: url('+@{/static/img/logo-cn.png} +')'
"
type=
"button"
></button>
</div>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment