mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 01:48:33 +08:00
ROLE_ALL_USER
This commit is contained in:
parent
b1b021e63f
commit
8db33b0e8d
@ -138,7 +138,8 @@ public abstract class AbstractAuthenticationProvider {
|
||||
//create session
|
||||
this.sessionManager.create(session.getId(), session);
|
||||
|
||||
AuthorizationUtils.setSession(session);
|
||||
//set Authentication to http session
|
||||
AuthorizationUtils.setAuthentication(authenticationToken);
|
||||
|
||||
return authenticationToken;
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class InMemorySessionManager extends AbstractSessionManager{
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
Duration duration = Duration.between(currentTime, session.getLastAccessTime());
|
||||
|
||||
_logger.trace("OnlineTicket duration " + duration.getSeconds());
|
||||
_logger.trace("Session duration " + duration.getSeconds());
|
||||
|
||||
if(duration.getSeconds() > Session.MAX_EXPIRY_DURATION) {
|
||||
session.setLastAccessTime(currentTime);
|
||||
|
||||
@ -59,8 +59,8 @@ public class RedisSessionManager extends AbstractSessionManager {
|
||||
|
||||
@Override
|
||||
public void create(String sessionId, Session ticket) {
|
||||
RedisConnection conn=connectionFactory.getConnection();
|
||||
conn.setexObject(PREFIX+sessionId, serviceTicketValiditySeconds, ticket);
|
||||
RedisConnection conn = connectionFactory.getConnection();
|
||||
conn.setexObject(PREFIX + sessionId, serviceTicketValiditySeconds, ticket);
|
||||
conn.close();
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class RedisSessionManager extends AbstractSessionManager {
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
Duration duration = Duration.between(currentTime, session.getLastAccessTime());
|
||||
|
||||
_logger.trace("OnlineTicket duration " + duration.getSeconds());
|
||||
_logger.trace("Session duration " + duration.getSeconds());
|
||||
|
||||
if(duration.getSeconds() > Session.MAX_EXPIRY_DURATION) {
|
||||
session.setLastAccessTime(currentTime);
|
||||
|
||||
@ -44,7 +44,7 @@ public class AuthorizationUtils {
|
||||
AuthJwtService authJwtService,
|
||||
SessionManager sessionManager
|
||||
) throws ParseException{
|
||||
if(getSession() == null) {
|
||||
if(getAuthentication() == null) {
|
||||
Cookie authCookie = WebContext.getCookie(request, Authorization_Cookie);
|
||||
if(authCookie != null ) {
|
||||
String authorization = authCookie.getValue();
|
||||
@ -59,7 +59,7 @@ public class AuthorizationUtils {
|
||||
AuthJwtService authJwtService,
|
||||
SessionManager sessionManager
|
||||
) throws ParseException{
|
||||
if(getSession() == null) {
|
||||
if(getAuthentication() == null) {
|
||||
String authorization = AuthorizationHeaderUtils.resolveBearer(request);
|
||||
if(authorization != null ) {
|
||||
doJwtAuthenticate(authorization,authJwtService,sessionManager);
|
||||
@ -76,27 +76,11 @@ public class AuthorizationUtils {
|
||||
String sessionId = authJwtService.resolveJWTID(authorization);
|
||||
Session session = sessionManager.get(sessionId);
|
||||
if(session != null) {
|
||||
setSession(session);
|
||||
setAuthentication(session.getAuthentication());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//set session to http session
|
||||
public static void setSession(Session session) {
|
||||
WebContext.setAttribute(WebConstants.SESSION, session);
|
||||
}
|
||||
|
||||
public static Session getSession() {
|
||||
Session session = getSession(WebContext.getRequest());
|
||||
return session;
|
||||
}
|
||||
|
||||
//get session to http session
|
||||
public static Session getSession(HttpServletRequest request) {
|
||||
Session session = (Session) request.getSession().getAttribute(WebConstants.SESSION);
|
||||
return session;
|
||||
}
|
||||
|
||||
public static Authentication getAuthentication() {
|
||||
Authentication authentication = (Authentication) getAuthentication(WebContext.getRequest());
|
||||
@ -108,12 +92,13 @@ public class AuthorizationUtils {
|
||||
return authentication;
|
||||
}
|
||||
|
||||
//set Authentication to http session
|
||||
public static void setAuthentication(Authentication authentication) {
|
||||
WebContext.setAttribute(WebConstants.AUTHENTICATION, authentication);
|
||||
}
|
||||
|
||||
public static boolean isAuthenticated() {
|
||||
return getSession() != null;
|
||||
return getAuthentication() != null;
|
||||
}
|
||||
|
||||
public static boolean isNotAuthenticated() {
|
||||
|
||||
@ -166,6 +166,17 @@ public class Groups extends JpaBaseEntity implements Serializable {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* ROLE_ALL_USER must be
|
||||
* 1, dynamic
|
||||
* 2, all orgIdsList
|
||||
* 3, not filters
|
||||
*/
|
||||
public void setDefaultAllUser() {
|
||||
this.dynamic = "1";
|
||||
this.orgIdsList ="";
|
||||
this.filters ="";
|
||||
}
|
||||
|
||||
public String getDynamic() {
|
||||
return dynamic;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -92,6 +92,9 @@ public class GroupsController {
|
||||
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public ResponseEntity<?> update(@RequestBody Groups group,@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug("-update group :" + group);
|
||||
if(group.getId().equalsIgnoreCase("ROLE_ALL_USER")) {
|
||||
group.setDefaultAllUser();
|
||||
}
|
||||
group.setInstId(currentUser.getInstId());
|
||||
if (groupsService.update(group)) {
|
||||
groupsService.refreshDynamicGroups(group);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user