AuthSessionStorage
extends BaseEntity
in package
implements
AuthStorageInterface
One shared login storage instance for all modules (Front and Admin).
It lives here as the single copy because it has no module-specific content; every module has its own Manager/Service/Mapper/Repository on top of it.
IMPORTANT: the section is named auth (formerly front.auth). Front and admin still share
one login, but existing sessions keep their token under the old section name, which is no
longer read, so everyone logged in is logged out once at deployment.
Table of Contents
Interfaces
Constants
- ADMIN_REMEMBER_TIMEOUT_SECONDS : int = 28800
- "Remember me" in the admin: a working day, not a month, because admin access is more sensitive than a website account.
- IDLE_TIMEOUT_SECONDS : int = 1800
- Inactivity after which the login expires. The Nette identity always had `setExpiration('30 minutes')`, but the `auth` section (access + refresh token) had no expiry and `checkAuthentication()` logged the user in again right after the identity expired, so effectively the session (31 days) applied. Inactivity is now measured here, over the tokens; when exceeded the section is cleared and the tokens are revoked.
- REMEMBER_TIMEOUT_SECONDS : int = 2678400
- "Remember me" on the front end: as long as the session lasts in Redis (31 days).
Properties
- $section : SessionSection
Methods
- __construct() : mixed
- adminIdleTimeoutSeconds() : int
- Inactivity limit in the admin: 8 h with admin "remember me", otherwise 30 min (front end `remember` does not count).
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- clear() : void
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getLastActivity() : int|null
- getPayload() : array<string|int, mixed>|null
- getRefreshToken() : string|null
- getSection() : SessionSection
- getToken() : string|null
- idleTimeoutSeconds() : int
- Inactivity limit on the front end: 31 days with its "remember me", 8 h after a remembered admin login, otherwise 30 min.
- isAdminRemember() : bool
- isAuthenticated() : bool
- isIdleExpired() : bool
- Returns whether the login expired by inactivity. A section without a timestamp (a session from before the inactivity limit) has not expired and gets one on its next request; otherwise a deployment would log everyone out at once.
- isRemember() : bool
- setAdminRemember() : void
- Whether "remember me" was ticked on the admin login (8 h). A separate flag: the `auth` section is shared with the front end and its `remember` means 31 days, which the admin does not read.
- setPayload() : void
- setRefreshToken() : void
- setRemember() : void
- Whether "remember me" was ticked on the front end login (31 days).
- setToken() : void
- touchActivity() : void
- Last request with a valid login (unix time).
- getSectionName() : string
- Name of the session section. Changing it logs everyone out (see the class docblock).
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Constants
ADMIN_REMEMBER_TIMEOUT_SECONDS
"Remember me" in the admin: a working day, not a month, because admin access is more sensitive than a website account.
public
int
ADMIN_REMEMBER_TIMEOUT_SECONDS
= 28800
IDLE_TIMEOUT_SECONDS
Inactivity after which the login expires. The Nette identity always had `setExpiration('30 minutes')`, but the `auth` section (access + refresh token) had no expiry and `checkAuthentication()` logged the user in again right after the identity expired, so effectively the session (31 days) applied. Inactivity is now measured here, over the tokens; when exceeded the section is cleared and the tokens are revoked.
public
int
IDLE_TIMEOUT_SECONDS
= 1800
REMEMBER_TIMEOUT_SECONDS
"Remember me" on the front end: as long as the session lasts in Redis (31 days).
public
int
REMEMBER_TIMEOUT_SECONDS
= 2678400
Properties
$section
private
SessionSection
$section
Methods
__construct()
public
__construct(Session $session) : mixed
Parameters
- $session : Session
adminIdleTimeoutSeconds()
Inactivity limit in the admin: 8 h with admin "remember me", otherwise 30 min (front end `remember` does not count).
public
adminIdleTimeoutSeconds() : int
Return values
intcallInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
clear()
public
clear() : void
getAllTraits()
Returns all traits the class uses, including those used by parent classes and nested traits.
public
getAllTraits() : array<string, string>
Return values
array<string, string>getLastActivity()
public
getLastActivity() : int|null
Return values
int|nullgetPayload()
public
getPayload() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetRefreshToken()
public
getRefreshToken() : string|null
Return values
string|nullgetSection()
public
getSection() : SessionSection
Return values
SessionSectiongetToken()
public
getToken() : string|null
Return values
string|nullidleTimeoutSeconds()
Inactivity limit on the front end: 31 days with its "remember me", 8 h after a remembered admin login, otherwise 30 min.
public
idleTimeoutSeconds() : int
Return values
intisAdminRemember()
public
isAdminRemember() : bool
Return values
boolisAuthenticated()
public
isAuthenticated() : bool
Return values
boolisIdleExpired()
Returns whether the login expired by inactivity. A section without a timestamp (a session from before the inactivity limit) has not expired and gets one on its next request; otherwise a deployment would log everyone out at once.
public
isIdleExpired(int $now[, int|null $timeoutSeconds = null ]) : bool
Parameters
- $now : int
- $timeoutSeconds : int|null = null
-
fixed limit (admin: adminIdleTimeoutSeconds());
null= idleTimeoutSeconds()
Return values
boolisRemember()
public
isRemember() : bool
Return values
boolsetAdminRemember()
Whether "remember me" was ticked on the admin login (8 h). A separate flag: the `auth` section is shared with the front end and its `remember` means 31 days, which the admin does not read.
public
setAdminRemember(bool $remember) : void
Parameters
- $remember : bool
setPayload()
public
setPayload(array<string|int, mixed> $payload) : void
Parameters
- $payload : array<string|int, mixed>
setRefreshToken()
public
setRefreshToken(string|null $refreshToken) : void
Parameters
- $refreshToken : string|null
setRemember()
Whether "remember me" was ticked on the front end login (31 days).
public
setRemember(bool $remember) : void
Parameters
- $remember : bool
setToken()
public
setToken(string $token) : void
Parameters
- $token : string
touchActivity()
Last request with a valid login (unix time).
public
touchActivity(int $now) : void
Parameters
- $now : int
getSectionName()
Name of the session section. Changing it logs everyone out (see the class docblock).
protected
static getSectionName() : string
Return values
stringgetTraitsRecursive()
Walks the trait list recursively and collects nested traits too.
private
static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
- $traits : array<string, string>