This commit is contained in:
MaxKey
2022-04-26 17:41:04 +08:00
parent 946b346282
commit e51a3a25ba
37 changed files with 236 additions and 218 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.online.OnlineTicketService;
import org.maxkey.authn.session.SessionService;
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
OnlineTicketService onlineTicketService;
SessionService sessionService;
/**
* 查询登录日志.
@@ -90,7 +90,7 @@ public class LoginSessionController {
continue;//skip current session
}
onlineTicketService.terminate(
sessionService.terminate(
sessionId,
currentUser.getId(),
currentUser.getUsername());

View File

@@ -22,8 +22,8 @@ import java.util.Set;
import java.util.Map.Entry;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.authn.online.OnlineTicket;
import org.maxkey.authn.online.OnlineTicketService;
import org.maxkey.authn.session.Session;
import org.maxkey.authn.session.SessionService;
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 OnlineTicketService onlineTicketService;
protected SessionService sessionService;
@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 onlineTicketId = currentUser.getOnlineTicket();
OnlineTicket onlineTicket = onlineTicketService.get(onlineTicketId);
Session onlineTicket = sessionService.get(onlineTicketId);
if(onlineTicket != null) {
Set<Entry<String, Apps>> entrySet = onlineTicket.getAuthorizedApps().entrySet();
@@ -74,7 +74,7 @@ public class LogoutEndpoint {
}
}
onlineTicketService.terminate(
sessionService.terminate(
onlineTicketId,
currentUser.getId(),
currentUser.getUsername());

View File

@@ -84,7 +84,7 @@ public class HistorySignOnAppInterceptor implements AsyncHandlerInterceptor {
SigninPrincipal principal = AuthorizationUtils.getPrincipal();
if(principal != null && app !=null) {
final UserInfo userInfo = principal.getUserInfo();
String sessionId = principal.getOnlineTicket().getTicketId();
String sessionId = principal.getSession().getId();
_logger.debug("sessionId : " + sessionId + " ,appId : " + app.getId());
HistoryLoginApps historyLoginApps = new HistoryLoginApps();
historyLoginApps.setAppId(app.getId());

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.online.OnlineTicketService;
import org.maxkey.authn.session.SessionService;
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
OnlineTicketService onlineTicketService;
SessionService sessionService;
@Autowired
AuthJwtService authJwtService ;
@@ -51,7 +51,7 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
_logger.trace("Single Sign On Interceptor");
AuthorizationUtils.authenticateWithCookie(
request,authJwtService,onlineTicketService);
request,authJwtService,sessionService);
if(AuthorizationUtils.isNotAuthenticated()){
String loginUrl = applicationConfig.getFrontendUri() + "/#/passport/login?redirect_uri=%s";