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
ed7abd98
Commit
ed7abd98
authored
Mar 17, 2021
by
曹雷
Browse files
Options
Browse Files
Download
Plain Diff
2021.03.17 adjust ds.html & loginSuccess.html
parents
e98e6b77
789dd4bc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
28 deletions
+181
-28
AuthController.java
...eall/eden/authcenter/agent/controller/AuthController.java
+67
-22
LogStatisticsController.java
.../authcenter/agent/controller/LogStatisticsController.java
+25
-5
application.yml
eden-authcenter-agent/src/main/resources/application.yml
+1
-1
ds.html
eden-authcenter-agent/src/main/resources/templates/ds.html
+88
-0
No files found.
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/AuthController.java
View file @
ed7abd98
...
...
@@ -145,26 +145,28 @@ public class AuthController {
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
);
String
url3
=
generateSpLoginUrl
(
returnUrl
,
OauthType
.
qpjy
.
getCode
(),
authLog
.
getId
());
modelAndView
.
addObject
(
"loginUrl3"
,
url3
);
modelAndView
.
addObject
(
"logId"
,
authLog
.
getId
());
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"
,
""
);
}
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
);
String
url3
=
generateSpLoginUrl
(
returnUrl
,
OauthType
.
qpjy
.
getCode
(),
authLog
.
getId
());
modelAndView
.
addObject
(
"loginUrl3"
,
url3
);
modelAndView
.
addObject
(
"logId"
,
authLog
.
getId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
modelAndView
.
setViewName
(
"error"
);
...
...
@@ -257,8 +259,17 @@ public class AuthController {
authLog
.
setAuthSource
(
clientItem
.
getClientName
());
authLog
.
setLogType
(
LogType
.
logout
);
authLogService
.
save
(
authLog
);
if
(
StringUtils
.
isNotEmpty
(
service
))
response
.
sendRedirect
(
generateLogoutUrl
(
service
,
type
.
name
()));
if
(
StringUtils
.
isNotEmpty
(
service
))
{
if
(!
OauthType
.
dianjiaoguan
.
equals
(
type
)
&&
!
OauthType
.
edenoperation
.
equals
(
type
)){
if
(
OauthType
.
qpjy
.
equals
(
type
)){
response
.
sendRedirect
(
generateSpLogoutUrl
(
service
,
type
.
name
()));
}
}
else
{
response
.
sendRedirect
(
generateLogoutUrl
(
service
,
type
.
name
()));
}
}
return
null
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -463,7 +474,7 @@ public class AuthController {
if
(!
oauthConfigItem
.
getOauthUrl
().
endsWith
(
"/"
))
{
loginUrlBuilder
.
append
(
"/"
);
}
loginUrlBuilder
.
append
(
"?client_id="
).
append
(
oauthConfigItem
.
getClientId
());
loginUrlBuilder
.
append
(
"
login
?client_id="
).
append
(
oauthConfigItem
.
getClientId
());
String
loginSuccessUrl
=
oauthConfigItem
.
getLoginSuccessUrl
();
loginSuccessUrl
=
loginSuccessUrl
+
"?log_id="
+
logId
+
"&oauth_type="
+
oauthType
;
if
(
StringUtils
.
isNotEmpty
(
returnUrl
))
{
...
...
@@ -481,6 +492,7 @@ public class AuthController {
//oauthConfig + "/authorize?client_id=testClentId&redirect_uri=http%3a%2f%2f192.168.17.129%3a7774%2fauth%2floginsuccess.do&state=state"
StringBuilder
loginUrlBuilder
=
new
StringBuilder
();
OauthConfigItem
oauthConfigItem
=
oauthConfig
.
getItems
().
get
(
oauthType
);
loginUrlBuilder
.
append
(
oauthConfigItem
.
getOauthUrl
());
if
(!
oauthConfigItem
.
getOauthUrl
().
endsWith
(
"/"
))
{
loginUrlBuilder
.
append
(
"/"
);
...
...
@@ -495,6 +507,39 @@ public class AuthController {
return
loginUrlBuilder
.
toString
();
}
private
String
generateSpLogoutUrl
(
String
returnUrl
,
String
oauthType
)
{
if
(
oauthType
.
equals
(
"qpjy"
)){
returnUrl
=
"https://idp.qpedu.cn/logout/logout.html?redirect_url="
+
returnUrl
;
returnUrl
=
"https://sp.etextbook.cn/Shibboleth.sso/Logout?return="
+
URLEncoder
.
encode
(
returnUrl
);
return
returnUrl
;
}
StringBuilder
loginUrlBuilder
=
new
StringBuilder
();
OauthConfigItem
oauthConfigItem
=
oauthConfig
.
getItems
().
get
(
oauthType
);
loginUrlBuilder
.
append
(
oauthConfigItem
.
getOauthUrl
());
if
(!
oauthConfigItem
.
getOauthUrl
().
endsWith
(
"/"
))
{
loginUrlBuilder
.
append
(
"/"
);
}
String
service
=
oauthConfigItem
.
getLogoutSuccessUrl
();
if
(
StringUtils
.
isNotEmpty
(
returnUrl
))
{
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"return_url"
,
URLEncoder
.
encode
(
returnUrl
));
service
=
appendUrl
(
service
,
param
);
}
String
clientId
=
oauthConfigItem
.
getClientId
();
String
signOrigin
=
oauthConfigItem
.
getClientId
()
+
"$$"
+
oauthConfigItem
.
getClientSecret
();
String
md5Hex
=
EncodeUtil
.
md5
(
signOrigin
);
loginUrlBuilder
.
append
(
"logout?service="
).
append
(
URLEncoder
.
encode
(
service
));
loginUrlBuilder
.
append
(
"&client_id="
+
clientId
);
loginUrlBuilder
.
append
(
"&sign="
+
md5Hex
);
return
loginUrlBuilder
.
toString
();
}
private
String
generateUserInfoUrl
(
String
accessToken
,
String
oauthType
)
{
//String url = "http://castest.edu.sh.cn/CAS/oauth2.0/accessToken?client_id=testClentId&client_secret=testClientSecret&redirect_uri=http%3a%2f%2f192.168.17.129%3a7774%2fauth%2floginsuccess2.do&code=" + code;
StringBuilder
builder
=
new
StringBuilder
();
...
...
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/LogStatisticsController.java
View file @
ed7abd98
...
...
@@ -111,19 +111,29 @@ public class LogStatisticsController {
if
(
null
!=
month
){
param
.
put
(
"yearMonth"
,
month
);
}
long
all_auth
=
authLogService
.
count
(
param
);
List
<
StatItem
>
browserResult
=
new
ArrayList
<>();
List
<
String
>
browserList
=
authLogService
.
distinct
(
"browser"
,
param
);
long
unknownBrowser
=
all_auth
;
if
(
CollectionUtils
.
isNotEmpty
(
browserList
)){
browserList
.
forEach
(
item
->
{
for
(
String
item
:
browserList
)
{
param
.
put
(
"browser"
,
item
);
long
count
=
authLogService
.
count
(
param
);
StatItem
statItem
=
new
StatItem
();
statItem
.
setName
(
item
);
statItem
.
setCount
(
count
);
unknownBrowser
=
unknownBrowser
-
count
;
browserResult
.
add
(
statItem
);
}
);
}
}
if
(
unknownBrowser
>
0
){
StatItem
statItem
=
new
StatItem
();
statItem
.
setName
(
"unknown"
);
statItem
.
setCount
(
unknownBrowser
);
browserResult
.
add
(
statItem
);
}
result
.
put
(
"browser"
,
browserResult
);
...
...
@@ -132,15 +142,25 @@ public class LogStatisticsController {
param
.
remove
(
"browser"
);
List
<
String
>
osList
=
authLogService
.
distinct
(
"os"
,
param
);
long
unknownOs
=
all_auth
;
if
(
CollectionUtils
.
isNotEmpty
(
osList
)){
osList
.
forEach
(
item
->
{
for
(
String
item
:
osList
)
{
param
.
put
(
"os"
,
item
);
long
count
=
authLogService
.
count
(
param
);
StatItem
statItem
=
new
StatItem
();
statItem
.
setName
(
item
);
statItem
.
setCount
(
count
);
osResult
.
add
(
statItem
);
});
unknownOs
=
unknownOs
-
count
;
}
}
if
(
unknownOs
>
0
){
StatItem
statItem
=
new
StatItem
();
statItem
.
setName
(
"unknown"
);
statItem
.
setCount
(
unknownOs
);
osResult
.
add
(
statItem
);
}
result
.
put
(
"os"
,
osResult
);
return
MapMessage
.
successMessage
().
add
(
"data"
,
result
);
...
...
eden-authcenter-agent/src/main/resources/application.yml
View file @
ed7abd98
...
...
@@ -44,7 +44,7 @@ oauth:
logoutSuccessUrl
:
https://ds-test.etextbook.cn/authcenter/auth/logoutsuccess
qpjy
:
#idp
#oauthUrl: https://operator-api-test.etextbook.cn/cas
oauthUrl
:
https://sp.etextbook.cn/authcenter/auth
/login
oauthUrl
:
https://sp.etextbook.cn/authcenter/auth
clientId
:
dsClentId
clientSecret
:
VjyqUkkM5Znu
loginSuccessUrl
:
https://ds-test.etextbook.cn/authcenter/auth/idp/loginsuccess
...
...
eden-authcenter-agent/src/main/resources/templates/ds.html
View file @
ed7abd98
...
...
@@ -5,6 +5,31 @@
<html
class=
"no-js"
xmlns:th=
"http://www.w3.org/1999/xhtml"
>
<!--<![endif]-->
<head>
<script
type=
"text/javascript"
src=
"../static/js/browser.js"
></script>
<script
th:inline=
"javascript"
>
/*<![CDATA[*/
var
loginUrl1
=
[[
$
{
loginUrl1
}]];
var
loginUrl2
=
[[
$
{
loginUrl2
}]];
var
loginUrl3
=
[[
$
{
loginUrl3
}]];
var
logId
=
[[
$
{
logId
}]];
var
loginType
=
[[
$
{
loginType
}]];
var
ctxPath
=
/*[[@{/}]]*/
''
;
function
toLogin
(
idp
)
{
var
info
=
new
Browser
();
var
baseUrl
=
ctxPath
+
"auth/tologin?logId="
+
logId
+
"&oauthType="
;
if
(
idp
==
"dianjiaoguan"
)
{
window
.
location
.
href
=
baseUrl
+
"dianjiaoguan&loginUrl="
+
encodeURIComponent
(
loginUrl1
)
+
"&browser="
+
info
.
browser
+
"&device="
+
info
.
device
+
"&os="
+
info
.
os
+
"&version="
+
info
.
version
;
}
else
if
(
idp
==
"edenoperation"
)
{
window
.
location
.
href
=
baseUrl
+
"edenoperation&loginUrl="
+
encodeURIComponent
(
loginUrl2
)
+
"&browser="
+
info
.
browser
+
"&device="
+
info
.
device
+
"&os="
+
info
.
os
+
"&version="
+
info
.
version
;
}
else
{
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
){
toLogin
(
loginType
);
}
</script>
<meta
charset=
"utf-8"
/>
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
<meta
content=
""
name=
"description"
/>
...
...
@@ -14,6 +39,7 @@
<link
rel=
"stylesheet"
th:href=
"@{/static/css/bootstrap.min.css}"
/>
<link
rel=
"stylesheet"
th:href=
"@{/static/css/normalize.css}"
/>
<script
type=
"text/javascript"
th:src=
"@{/static/js/jquery-1.10.2.min.js}"
></script>
<
<<<<<<
HEAD
<
script
type=
"text/javascript"
src=
"@{/static/js/browser.js}"
></script>
<style>
...
...
@@ -85,11 +111,63 @@
<button
class=
"login-btn-idp login-btn-idp-enable"
onclick=
"toLogin('qp')"
type=
"button"
>
青浦区
</button>
<button
class=
"login-btn-idp"
disabled=
"disabled"
onclick=
"toLogin('fx')"
type=
"button"
>
奉贤区
</button>
<button
class=
"login-btn-idp"
disabled=
"disabled"
onclick=
"toLogin('cm')"
type=
"button"
>
崇明区
</button>
=======
<!--<script src="../js/vendor/modernizr-2.6.2.min.js"></script>-->
</head>
<body
id=
"body"
style=
"display: none"
>
<!--[if lt IE 7]>
<p class="browsehappy">
You are using an <strong>outdated</strong> browser. Please
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
your experience.
</p>
<![endif]-->
<!-- Add your site or application content here -->
<!-- Add your site or application content here -->
<div
class=
"ds"
>
<div
class=
"ds-header"
>
<img
class=
"ds-header-img"
th:src=
"@{/static/img/Rlogo.png}"
alt=
""
/>
</div>
<div
class=
"ds-content"
>
<div
class=
"ds-content-mask"
>
<p
class=
"ds-content-title"
>
发现服务 · 速享之旅
</p>
<div
class=
"ds-content-source"
>
<div
class=
"ds-content-city"
>
<div
class=
"ds-content-city-float"
>
<p>
市认证源
</p>
<button
onclick=
"toLogin('edenoperation')"
class=
"logo-btn city-btn"
style=
"background: white url('../static/img/logo-shszjc.png')"
type=
"button"
></button>
<button
onclick=
"toLogin('dianjiaoguan')"
class=
"logo-btn city-btn"
style=
"background: white url('../static/img/logo-tyrz.png')"
type=
"button"
></button>
</div>
</div>
<div
class=
"ds-divide-line"
></div>
<div
class=
"ds-content-district"
>
<p>
区认证源
</p>
<div>
<button
onclick=
"toLogin('qpjy')"
class=
"logo-btn idp-btn"
style=
"background: url('../static/img/logo-qp.png')"
type=
"button"
></button>
<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>
<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>
<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>
<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>
<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>
<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>
</div>
>>>>>>> 789dd4bcb823cf73303fe6d05b16b8c3f8ab75ad
</div>
</div>
</div>
</div>
</div>
<
<<<<<<
HEAD
<
div
class=
"footer"
>
<p
class=
"footer-text"
>
版权所有
©
上海教育认证中心
</p>
</div>
...
...
@@ -115,5 +193,15 @@
}
}
</script>
=======
>>>>>>> 789dd4bcb823cf73303fe6d05b16b8c3f8ab75ad
</body>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
(){
$
(
"#body"
).
show
();
});
</script>
</html>
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