Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loginservice
Overview
Overview
Details
Activity
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
lanmw
loginservice
Commits
969f2a0e
Commit
969f2a0e
authored
Feb 02, 2021
by
chenzx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tbsso,添加cookie日志
parent
590e98e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
LoginManagement.java
src/main/java/com/keymobile/proxy/api/LoginManagement.java
+9
-0
RESTAuthenticationSuccessHandler.java
...eymobile/proxy/conf/RESTAuthenticationSuccessHandler.java
+10
-1
application-test.yml
src/main/resources/application-test.yml
+3
-0
No files found.
src/main/java/com/keymobile/proxy/api/LoginManagement.java
View file @
969f2a0e
...
...
@@ -4,6 +4,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
...
...
@@ -19,6 +20,14 @@ public class LoginManagement {
@RequestMapping
(
value
=
"/sessionInfo"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
Map
<
String
,
Object
>
verifyLogin
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
null
==
cookies
){
System
.
out
.
println
(
"sessionInfo--cookie-->null"
);
}
else
{
for
(
Cookie
cookie
:
cookies
)
{
System
.
out
.
println
(
"sessionInfo--cookie-->"
+
cookie
.
getName
()+
":"
+
cookie
.
getValue
());
}
}
UserDetails
userDetails
=
(
UserDetails
)
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
Map
<
String
,
Object
>
rs
=
new
HashMap
<>();
String
userNameWithIdAttached
=
userDetails
.
getUsername
();
...
...
src/main/java/com/keymobile/proxy/conf/RESTAuthenticationSuccessHandler.java
View file @
969f2a0e
...
...
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
import
com.keymobile.proxy.api.Constants
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -35,7 +36,15 @@ public class RESTAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuc
}
String
returnStatus
=
data
;
//check if allow root login
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
null
==
cookies
){
System
.
out
.
println
(
"RESTAuthenticationSuccessHandler--cookie-->null"
);
}
else
{
for
(
Cookie
cookie
:
cookies
)
{
System
.
out
.
println
(
"RESTAuthenticationSuccessHandler--cookie-->"
+
cookie
.
getName
()+
":"
+
cookie
.
getValue
());
}
}
UserDetails
userDetails
=
(
UserDetails
)
authentication
.
getPrincipal
();
String
userNameWithIdAttached
=
userDetails
.
getUsername
();
if
(
userNameWithIdAttached
.
split
(
":"
)[
0
].
equalsIgnoreCase
(
"root"
)
...
...
src/main/resources/application-test.yml
View file @
969f2a0e
...
...
@@ -38,6 +38,9 @@ eureka:
registryFetchIntervalSeconds
:
5
serviceUrl
:
defaultZone
:
http://192.168.0.216:8081/eureka/
instance
:
prefer-ip-address
:
true
hostname
:
192.168.0.110
zuul
:
prefix
:
/api
...
...
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