SessionManager

This commit is contained in:
MaxKey
2022-04-26 22:30:24 +08:00
parent 10b964ad79
commit 773334ad47
23 changed files with 111 additions and 109 deletions

View File

@@ -21,7 +21,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.authn.session.SessionService;
import org.maxkey.authn.session.SessionManager;
import org.maxkey.entity.HistoryLogin;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
@@ -57,7 +57,7 @@ public class LoginSessionController {
HistoryLoginService historyLoginService;
@Autowired
SessionService sessionService;
SessionManager sessionManager;
/**
* 查询登录日志.
@@ -90,7 +90,7 @@ public class LoginSessionController {
continue;//skip current session
}
sessionService.terminate(
sessionManager.terminate(
sessionId,
currentUser.getId(),
currentUser.getUsername());

View File

@@ -23,7 +23,7 @@ import java.util.Map.Entry;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.authn.session.Session;
import org.maxkey.authn.session.SessionService;
import org.maxkey.authn.session.SessionManager;
import org.maxkey.authz.singlelogout.SamlSingleLogout;
import org.maxkey.authz.singlelogout.DefaultSingleLogout;
import org.maxkey.authz.singlelogout.LogoutType;
@@ -48,14 +48,14 @@ public class LogoutEndpoint {
private static Logger _logger = LoggerFactory.getLogger(LogoutEndpoint.class);
@Autowired
protected SessionService sessionService;
protected SessionManager sessionManager;
@Operation(summary = "单点注销接口", description = "reLoginUrl跳转地址",method="GET")
@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 sessionId = currentUser.getSessionId();
Session session = sessionService.get(sessionId);
Session session = sessionManager.get(sessionId);
if(session != null) {
Set<Entry<String, Apps>> entrySet = session.getAuthorizedApps().entrySet();
@@ -74,7 +74,7 @@ public class LogoutEndpoint {
}
}
sessionService.terminate(
sessionManager.terminate(
session.getId(),
currentUser.getId(),
currentUser.getUsername());

View File

@@ -20,7 +20,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.jwt.AuthJwtService;
import org.maxkey.authn.session.SessionService;
import org.maxkey.authn.session.SessionManager;
import org.maxkey.authn.web.AuthorizationUtils;
import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.crypto.Base64Utils;
@@ -39,7 +39,7 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
ApplicationConfig applicationConfig;
@Autowired
SessionService sessionService;
SessionManager sessionManager;
@Autowired
AuthJwtService authJwtService ;
@@ -51,7 +51,7 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
_logger.trace("Single Sign On Interceptor");
AuthorizationUtils.authenticateWithCookie(
request,authJwtService,sessionService);
request,authJwtService,sessionManager);
if(AuthorizationUtils.isNotAuthenticated()){
String loginUrl = applicationConfig.getFrontendUri() + "/#/passport/login?redirect_uri=%s";