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
be9763ef
Commit
be9763ef
authored
Dec 20, 2022
by
mahx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加登录和退出日志
parent
73904261
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
RESTAuthenticationSuccessHandler.java
...eymobile/login/conf/RESTAuthenticationSuccessHandler.java
+3
-0
RESTLogoutSuccessHandler.java
...va/com/keymobile/login/conf/RESTLogoutSuccessHandler.java
+10
-0
LogConstants.java
src/main/java/com/keymobile/login/logging/LogConstants.java
+2
-0
No files found.
src/main/java/com/keymobile/login/conf/RESTAuthenticationSuccessHandler.java
View file @
be9763ef
package
com
.
keymobile
.
login
.
conf
;
import
com.keymobile.login.logging.LogConstants
;
import
com.keymobile.login.logging.LogManager
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.userdetails.UserDetails
;
...
...
@@ -27,6 +29,7 @@ public class RESTAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuc
UserDetails
userDetails
=
(
UserDetails
)
authentication
.
getPrincipal
();
String
userNameWithIdAttached
=
userDetails
.
getUsername
();
LogManager
.
logInfo
(
LogConstants
.
CTX_API
,
userNameWithIdAttached
+
" 登录了系统"
);
if
(
userNameWithIdAttached
.
split
(
":"
)[
0
].
equalsIgnoreCase
(
"root"
)
&&
!
rootAllowLogin
)
returnStatus
=
"root not allow login"
;
...
...
src/main/java/com/keymobile/login/conf/RESTLogoutSuccessHandler.java
View file @
be9763ef
package
com
.
keymobile
.
login
.
conf
;
import
com.keymobile.auth.common.security.GrantedAuthHelper
;
import
com.keymobile.login.logging.LogConstants
;
import
com.keymobile.login.logging.LogManager
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.web.AuthenticationEntryPoint
;
import
org.springframework.security.web.authentication.logout.LogoutSuccessHandler
;
import
org.springframework.stereotype.Component
;
...
...
@@ -17,6 +22,11 @@ public class RESTLogoutSuccessHandler implements LogoutSuccessHandler {
public
void
onLogoutSuccess
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Authentication
authentication
)
throws
IOException
,
ServletException
{
if
(
authentication
!=
null
)
{
UserDetails
userDetails
=
(
UserDetails
)
authentication
.
getPrincipal
();
String
userNameWithIdAttached
=
userDetails
!=
null
?
userDetails
.
getUsername
()
:
authentication
.
getName
();
LogManager
.
logInfo
(
LogConstants
.
CTX_API
,
userNameWithIdAttached
+
" 退出了系统"
);
}
response
.
setStatus
(
HttpStatus
.
OK
.
value
());
response
.
getWriter
().
flush
();
}
...
...
src/main/java/com/keymobile/login/logging/LogConstants.java
View file @
be9763ef
...
...
@@ -2,4 +2,6 @@ package com.keymobile.login.logging;
public
interface
LogConstants
{
String
CTX_API
=
"sso.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