|
MediaWiki master
|
This is the actual workhorse for Session. More...
Public Member Functions | |
| __construct (SessionId $id, SessionInfo $info, SessionStore $sessionStore, LoggerInterface $logger, HookContainer $hookContainer, $lifetime) | |
| addData (array $newData) | |
| Add data to the session. | |
| allowSecuritySensitiveOperationIfCannotReauthenticate ( $index) | |
| Whether security-sensitive operations should be allowed at all. | |
| canSetUser () | |
| Whether the session user info can be changed. | |
| delaySave () | |
| Delay automatic saving while multiple updates are being made. | |
| deregisterSession ( $index) | |
| Deregister a Session. | |
| dirty () | |
| Mark data as dirty. | |
| getAllowedUserRights () | |
| & | getData () |
| Fetch the session data array. | |
| getId () | |
| Return the session ID. | |
| getLoggedOutTimestamp () | |
| Fetch the "logged out" timestamp. | |
| getProvider () | |
| Fetch the SessionProvider for this session. | |
| getProviderMetadata () | |
| Fetch provider metadata. | |
| getRequest ( $index) | |
| Return the request associated with a Session. | |
| getRestrictions () | |
| getSession (WebRequest $request) | |
| Create a new Session for this backend. | |
| getSessionId () | |
| Fetch the SessionId object. | |
| getUser () | |
| Return the authenticated user for this session. | |
| isPersistent () | |
| Whether this session is persisted across requests. | |
| persist (bool $force=false) | |
| Make this session persisted across requests by calling SessionProvider::persist() and saving the session data and metadata to the session store. | |
| renew () | |
| Renew the session by re-saving all data with a new TTL. | |
| resetId () | |
| Change the session ID. | |
| save () | |
| Save the session. | |
| setForceHTTPS ( $force) | |
| Set whether HTTPS should be forced. | |
| setLoggedOutTimestamp ( $ts=null) | |
| setProviderMetadata ( $metadata) | |
| setRememberUser ( $remember) | |
| Set whether the user should be remembered, independently of the session ID. | |
| setUser ( $user) | |
| Set a new User object for this session. | |
| shouldForceHTTPS () | |
| Whether HTTPS should be forced. | |
| shouldRememberUser () | |
| Whether the user should be remembered, independently of the session ID. | |
| shutdown () | |
| Shut down a session. | |
| suggestLoginUsername ( $index) | |
| unpersist () | |
| Make this session not persisted across requests. | |
This is the actual workhorse for Session.
Most code does not need to use this class, you want \MediaWiki\Session\Session. The exceptions are SessionProviders and SessionMetadata hook functions, which get an instance of this class rather than Session.
The reasons for this split are:
Definition at line 40 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::__construct | ( | SessionId | $id, |
| SessionInfo | $info, | ||
| SessionStore | $sessionStore, | ||
| LoggerInterface | $logger, | ||
| HookContainer | $hookContainer, | ||
| $lifetime ) |
| SessionId | $id | |
| SessionInfo | $info | Session info to populate from |
| SessionStore | $sessionStore | |
| LoggerInterface | $logger | |
| HookContainer | $hookContainer | |
| int | $lifetime | Session data lifetime in seconds |
Definition at line 121 of file SessionBackend.php.
References MediaWiki\Session\SessionInfo\forceHTTPS(), MediaWiki\Session\SessionInfo\getId(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Session\SessionInfo\getPriority(), MediaWiki\Session\SessionInfo\getProvider(), MediaWiki\Session\SessionInfo\getProviderMetadata(), MediaWiki\Session\SessionInfo\getUserInfo(), persist(), MediaWiki\Session\SessionInfo\wasPersisted(), and MediaWiki\Session\SessionInfo\wasRemembered().
| MediaWiki\Session\SessionBackend::addData | ( | array | $newData | ) |
Add data to the session.
Overwrites any existing data under the same keys.
| array | $newData | Key-value pairs to add to the session |
Definition at line 606 of file SessionBackend.php.
References getData(), and wfGetAllCallers().
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession().
| MediaWiki\Session\SessionBackend::allowSecuritySensitiveOperationIfCannotReauthenticate | ( | $index | ) |
Whether security-sensitive operations should be allowed at all.
| int | $index | Request index |
Definition at line 456 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::canSetUser | ( | ) |
Whether the session user info can be changed.
Definition at line 445 of file SessionBackend.php.
Referenced by setUser().
| MediaWiki\Session\SessionBackend::delaySave | ( | ) |
Delay automatic saving while multiple updates are being made.
Calls to save() will not be delayed.
Definition at line 673 of file SessionBackend.php.
References delaySave(), and save().
Referenced by delaySave().
| MediaWiki\Session\SessionBackend::deregisterSession | ( | $index | ) |
Deregister a Session.
| int | $index |
Definition at line 234 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::dirty | ( | ) |
Mark data as dirty.
Definition at line 626 of file SessionBackend.php.
References wfGetAllCallers().
| MediaWiki\Session\SessionBackend::getAllowedUserRights | ( | ) |
Definition at line 427 of file SessionBackend.php.
| & MediaWiki\Session\SessionBackend::getData | ( | ) |
Fetch the session data array.
Note the caller is responsible for calling $this->dirty() if anything in the array is changed.
Definition at line 595 of file SessionBackend.php.
Referenced by addData().
| MediaWiki\Session\SessionBackend::getId | ( | ) |
Return the session ID.
Definition at line 253 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
| MediaWiki\Session\SessionBackend::getLoggedOutTimestamp | ( | ) |
| MediaWiki\Session\SessionBackend::getProvider | ( | ) |
Fetch the SessionProvider for this session.
Definition at line 308 of file SessionBackend.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\getAllowedUserRights(), and MediaWiki\Session\SessionProvider\getAllowedUserRights().
| MediaWiki\Session\SessionBackend::getProviderMetadata | ( | ) |
Fetch provider metadata.
Definition at line 561 of file SessionBackend.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\getAllowedUserRights().
| MediaWiki\Session\SessionBackend::getRequest | ( | $index | ) |
Return the request associated with a Session.
| int | $index | Session index |
Definition at line 408 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::getRestrictions | ( | ) |
Definition at line 436 of file SessionBackend.php.
References getRestrictions(), and return.
Referenced by getRestrictions().
| MediaWiki\Session\SessionBackend::getSession | ( | WebRequest | $request | ) |
Create a new Session for this backend.
| WebRequest | $request |
Definition at line 221 of file SessionBackend.php.
References $request.
| MediaWiki\Session\SessionBackend::getSessionId | ( | ) |
Fetch the SessionId object.
Definition at line 263 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionManager\changeBackendId(), and save().
| MediaWiki\Session\SessionBackend::getUser | ( | ) |
Return the authenticated user for this session.
Definition at line 418 of file SessionBackend.php.
References return.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
| MediaWiki\Session\SessionBackend::isPersistent | ( | ) |
Whether this session is persisted across requests.
For example, if cookies are set.
Definition at line 317 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::persist | ( | bool | $force = false | ) |
Make this session persisted across requests by calling SessionProvider::persist() and saving the session data and metadata to the session store.
Mutable sessions are started by application code calling persist(), and then the session will exist until unpersist() is called, the session expires, or the client stops sending the session tokens needed by the SessionProvider to return a non-null value from provideSessionInfo(). Immutable sessions are started by the client sending the needed session tokens; persist() / unpersist() will only determine whether the session data is saved to the session store.
If the session is already persistent, persist() equivalent to calling $this->renew(), except when the $force flag is set.
Definition at line 335 of file SessionBackend.php.
References persist(), and renew().
Referenced by __construct(), persist(), renew(), save(), and unpersist().
| MediaWiki\Session\SessionBackend::renew | ( | ) |
Renew the session by re-saving all data with a new TTL.
Resets the TTL in the backend store if the session is near expiring, and re-persists the session to any active WebRequests if persistent. No-op otherwise to reduce cookie churn in browsers.
Definition at line 643 of file SessionBackend.php.
References persist(), and wfGetAllCallers().
Referenced by persist().
| MediaWiki\Session\SessionBackend::resetId | ( | ) |
Change the session ID.
Definition at line 272 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::save | ( | ) |
Save the session.
Update both the backend data and the associated WebRequest(s) to reflect the state of the SessionBackend. This might include persisting or unpersisting the session.
Definition at line 706 of file SessionBackend.php.
References $request, MediaWiki\MediaWikiServices\getInstance(), getSessionId(), and persist().
Referenced by delaySave(), and shutdown().
| MediaWiki\Session\SessionBackend::setForceHTTPS | ( | $force | ) |
Set whether HTTPS should be forced.
| bool | $force |
Definition at line 516 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setLoggedOutTimestamp | ( | $ts = null | ) |
| int | null | $ts |
Definition at line 541 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setProviderMetadata | ( | $metadata | ) |
| array | null | $metadata |
Definition at line 569 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setRememberUser | ( | $remember | ) |
Set whether the user should be remembered, independently of the session ID.
| bool | $remember |
Definition at line 388 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setUser | ( | $user | ) |
Set a new User object for this session.
TODO: Consider changing to a "UserIdentity" instead.
| User | $user | User to set on the session. |
Definition at line 474 of file SessionBackend.php.
References canSetUser().
| MediaWiki\Session\SessionBackend::shouldForceHTTPS | ( | ) |
Whether HTTPS should be forced.
Definition at line 508 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
| MediaWiki\Session\SessionBackend::shouldRememberUser | ( | ) |
Whether the user should be remembered, independently of the session ID.
Definition at line 379 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\CookieSessionProvider\setForceHTTPSCookie().
| MediaWiki\Session\SessionBackend::shutdown | ( | ) |
Shut down a session.
Definition at line 243 of file SessionBackend.php.
References save().
| MediaWiki\Session\SessionBackend::suggestLoginUsername | ( | $index | ) |
| int | $index | Session index |
Definition at line 497 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::unpersist | ( | ) |
Make this session not persisted across requests.
Definition at line 355 of file SessionBackend.php.
References persist().