mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 12:32:09 +08:00
AuthorizationUtils
This commit is contained in:
@@ -86,7 +86,7 @@ public class LoginSessionController {
|
||||
try {
|
||||
for(String sessionId : StringUtils.string2List(ids, ",")) {
|
||||
_logger.trace("terminate session Id {} ",sessionId);
|
||||
if(currentUser.getOnlineTicket().contains(sessionId)) {
|
||||
if(currentUser.getSessionId().contains(sessionId)) {
|
||||
continue;//skip current session
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ public class LogoutEndpoint {
|
||||
@RequestMapping(value={"/logout"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public ResponseEntity<?> logout(@CurrentUser UserInfo currentUser){
|
||||
//if logined in have onlineTicket ,need remove or logout back
|
||||
String onlineTicketId = currentUser.getOnlineTicket();
|
||||
Session onlineTicket = sessionService.get(onlineTicketId);
|
||||
if(onlineTicket != null) {
|
||||
Set<Entry<String, Apps>> entrySet = onlineTicket.getAuthorizedApps().entrySet();
|
||||
String sessionId = currentUser.getSessionId();
|
||||
Session session = sessionService.get(sessionId);
|
||||
if(session != null) {
|
||||
Set<Entry<String, Apps>> entrySet = session.getAuthorizedApps().entrySet();
|
||||
|
||||
Iterator<Entry<String, Apps>> iterator = entrySet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -70,12 +70,12 @@ public class LogoutEndpoint {
|
||||
}else {
|
||||
singleLogout = new DefaultSingleLogout();
|
||||
}
|
||||
singleLogout.sendRequest(onlineTicket.getAuthentication(), mapEntry.getValue());
|
||||
singleLogout.sendRequest(session.getAuthentication(), mapEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
sessionService.terminate(
|
||||
onlineTicketId,
|
||||
session.getId(),
|
||||
currentUser.getId(),
|
||||
currentUser.getUsername());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.maxkey.web.interceptor;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.authn.SigninPrincipal;
|
||||
import org.maxkey.authn.SignPrincipal;
|
||||
import org.maxkey.authn.web.AuthorizationUtils;
|
||||
import org.maxkey.entity.HistoryLoginApps;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
@@ -56,7 +56,7 @@ public class HistorySignOnAppInterceptor implements AsyncHandlerInterceptor {
|
||||
throws Exception {
|
||||
_logger.debug("preHandle");
|
||||
final Apps app = (Apps)WebContext.getAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP);
|
||||
SigninPrincipal principal = AuthorizationUtils.getPrincipal();
|
||||
SignPrincipal principal = AuthorizationUtils.getPrincipal();
|
||||
if(principal != null && app !=null) {
|
||||
if(principal.getGrantedAuthorityApps().contains(new SimpleGrantedAuthority(app.getId()))) {
|
||||
_logger.trace("preHandle have authority access " + app);
|
||||
@@ -81,7 +81,7 @@ public class HistorySignOnAppInterceptor implements AsyncHandlerInterceptor {
|
||||
|
||||
final Apps app = (Apps)WebContext.getAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP);
|
||||
|
||||
SigninPrincipal principal = AuthorizationUtils.getPrincipal();
|
||||
SignPrincipal principal = AuthorizationUtils.getPrincipal();
|
||||
if(principal != null && app !=null) {
|
||||
final UserInfo userInfo = principal.getUserInfo();
|
||||
String sessionId = principal.getSession().getId();
|
||||
|
||||
@@ -87,7 +87,7 @@ public class LoginSessionController {
|
||||
try {
|
||||
for(String sessionId : StringUtils.string2List(ids, ",")) {
|
||||
_logger.trace("terminate session Id {} ",sessionId);
|
||||
if(currentUser.getOnlineTicket().contains(sessionId)) {
|
||||
if(currentUser.getSessionId().contains(sessionId)) {
|
||||
continue;//skip current session
|
||||
}
|
||||
sessionService.terminate(sessionId,currentUser.getId(),currentUser.getUsername());
|
||||
|
||||
@@ -36,7 +36,7 @@ public class LogoutEndpoint {
|
||||
@RequestMapping(value={"/logout"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public ResponseEntity<?> logout(@CurrentUser UserInfo currentUser){
|
||||
sessionService.terminate(
|
||||
currentUser.getOnlineTicket(),
|
||||
currentUser.getSessionId(),
|
||||
currentUser.getId(),
|
||||
currentUser.getUsername());
|
||||
return new Message<String>().buildResponse();
|
||||
|
||||
Reference in New Issue
Block a user