Package com.axelor.auth.pac4j
Class AxelorWebSecurityManager
java.lang.Object
org.apache.shiro.mgt.CachingSecurityManager
org.apache.shiro.mgt.RealmSecurityManager
org.apache.shiro.mgt.AuthenticatingSecurityManager
org.apache.shiro.mgt.AuthorizingSecurityManager
org.apache.shiro.mgt.SessionsSecurityManager
org.apache.shiro.mgt.DefaultSecurityManager
org.apache.shiro.web.mgt.DefaultWebSecurityManager
com.axelor.auth.pac4j.AxelorWebSecurityManager
- All Implemented Interfaces:
org.apache.shiro.authc.Authenticator,org.apache.shiro.authz.Authorizer,org.apache.shiro.cache.CacheManagerAware,org.apache.shiro.event.EventBusAware,org.apache.shiro.lang.util.Destroyable,org.apache.shiro.mgt.SecurityManager,org.apache.shiro.session.mgt.SessionManager,org.apache.shiro.web.mgt.WebSecurityManager
@Singleton
public class AxelorWebSecurityManager
extends org.apache.shiro.web.mgt.DefaultWebSecurityManager
Web Security Manager
Since Shiro 2.2, a successful login stops the existing session and creates a new one to guard against session fixation. The attributes of the old session are copied to the new one.
This implementation adapts that behavior:
- Session-less clients disable session creation for the request, so the attempt to recreate
the session would throw
DisabledSessionExceptiononce the old one is stopped. The session renewal is skipped for them, andAxelorWebSessionStorageEvaluatorprevents their login from being stored in the existing session. - The CSRF token is not carried over to the renewed session, so that a token issued before authentication cannot be used afterwards. A new token is generated on the login response.
-
Field Summary
Fields inherited from class org.apache.shiro.web.mgt.DefaultWebSecurityManager
HTTP_SESSION_MODE, NATIVE_SESSION_MODEFields inherited from class org.apache.shiro.mgt.DefaultSecurityManager
rememberMeManager, subjectDAO, subjectFactory -
Constructor Summary
ConstructorsConstructorDescriptionAxelorWebSecurityManager(Collection<org.apache.shiro.realm.Realm> realms, Set<org.apache.shiro.authc.AuthenticationListener> authenticationListeners, org.apache.shiro.authc.pam.ModularRealmAuthenticator authenticator, AxelorSessionManager sessionManager, AxelorWebSessionStorageEvaluator sessionStorageEvaluator, AxelorJCacheManager cacheManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbeforeSuccessfulLogin(org.apache.shiro.subject.Subject subject) Renews the existing session, unless session creation is disabled for the current request, and resets the CSRF token.Methods inherited from class org.apache.shiro.web.mgt.DefaultWebSecurityManager
afterSessionManagerSet, beforeLogout, copy, createSessionContext, createSessionManager, createSubjectContext, getSessionKey, getSessionMode, isHttpSessionMode, removeRequestIdentity, setSessionManager, setSessionMode, setSubjectDAOMethods inherited from class org.apache.shiro.mgt.DefaultSecurityManager
bind, createSubject, createSubject, delete, doCreateSubject, ensureSecurityManager, getRememberedIdentity, getRememberMeManager, getSubjectDAO, getSubjectFactory, login, logout, onFailedLogin, onSuccessfulLogin, rememberMeFailedLogin, rememberMeLogout, rememberMeSuccessfulLogin, resolveContextSession, resolvePrincipals, resolveSession, save, setRememberMeManager, setSubjectFactory, stopSession, unbindMethods inherited from class org.apache.shiro.mgt.SessionsSecurityManager
afterCacheManagerSet, afterEventBusSet, applyCacheManagerToSessionManager, applyEventBusToSessionManager, destroy, getSession, getSessionManager, startMethods inherited from class org.apache.shiro.mgt.AuthorizingSecurityManager
afterRealmsSet, checkPermission, checkPermission, checkPermissions, checkPermissions, checkRole, checkRoles, checkRoles, getAuthorizer, hasAllRoles, hasRole, hasRoles, isPermitted, isPermitted, isPermitted, isPermitted, isPermittedAll, isPermittedAll, setAuthorizerMethods inherited from class org.apache.shiro.mgt.AuthenticatingSecurityManager
authenticate, getAuthenticator, setAuthenticatorMethods inherited from class org.apache.shiro.mgt.RealmSecurityManager
applyCacheManagerToRealms, applyEventBusToRealms, getRealms, setRealm, setRealmsMethods inherited from class org.apache.shiro.mgt.CachingSecurityManager
applyEventBusToCacheManager, getCacheManager, getEventBus, setCacheManager, setEventBusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.shiro.authc.Authenticator
authenticateMethods inherited from interface org.apache.shiro.authz.Authorizer
checkPermission, checkPermission, checkPermissions, checkPermissions, checkRole, checkRoles, checkRoles, hasAllRoles, hasRole, hasRoles, isPermitted, isPermitted, isPermitted, isPermitted, isPermittedAll, isPermittedAllMethods inherited from interface org.apache.shiro.mgt.SecurityManager
createSubject, login, logoutMethods inherited from interface org.apache.shiro.session.mgt.SessionManager
getSession, start
-
Constructor Details
-
AxelorWebSecurityManager
@Inject public AxelorWebSecurityManager(Collection<org.apache.shiro.realm.Realm> realms, Set<org.apache.shiro.authc.AuthenticationListener> authenticationListeners, org.apache.shiro.authc.pam.ModularRealmAuthenticator authenticator, AxelorSessionManager sessionManager, AxelorWebSessionStorageEvaluator sessionStorageEvaluator, AxelorJCacheManager cacheManager)
-
-
Method Details
-
beforeSuccessfulLogin
protected void beforeSuccessfulLogin(org.apache.shiro.subject.Subject subject) Renews the existing session, unless session creation is disabled for the current request, and resets the CSRF token.- Overrides:
beforeSuccessfulLoginin classorg.apache.shiro.web.mgt.DefaultWebSecurityManager- Parameters:
subject- the subject about to be logged in
-