MediaWiki
1.27.3
|
This serves as the entry point to the MediaWiki session handling system. More...
Public Member Functions | |
__construct ($options=[]) | |
getEmptySession (WebRequest $request=null) | |
Fetch a new, empty session. More... | |
getSessionById ($id, $create=false, WebRequest $request=null) | |
Fetch a session by ID. More... | |
getSessionForRequest (WebRequest $request) | |
Fetch the session for a request. More... | |
getVaryCookies () | |
Return the list of cookies that need varying on. More... | |
getVaryHeaders () | |
Return the HTTP headers that need varying on. More... | |
invalidateSessionsForUser (User $user) | |
Invalidate sessions for a user. More... | |
setLogger (LoggerInterface $logger) | |
Static Public Member Functions | |
static | getGlobalSession () |
Get the "global" session. More... | |
static | singleton () |
Get the global SessionManager. More... | |
static | validateSessionId ($id) |
Validate a session ID. More... | |
Private Member Functions | |
getEmptySessionInternal (WebRequest $request=null, $id=null) | |
Private Attributes | |
SessionBackend[] | $allSessionBackends = [] |
SessionId[] | $allSessionIds = [] |
Config | $config |
LoggerInterface | $logger |
string[] | $preventUsers = [] |
SessionProvider[] | $sessionProviders = null |
CachedBagOStuff null | $store |
string[] | $varyCookies = null |
array | $varyHeaders = null |
Static Private Attributes | |
static Session null | $globalSession = null |
static WebRequest null | $globalSessionRequest = null |
static SessionManager null | $instance = null |
Internal methods | |
static | autoCreateUser (User $user) |
Auto-create the given user, if necessary. More... | |
static | resetCache () |
Reset the internal caching for unit testing. More... | |
preventSessionsForUser ($username) | |
Prevent future sessions for the user. More... | |
isUserSessionPrevented ($username) | |
Test if a user is prevented. More... | |
getProvider ($name) | |
Get a session provider by name. More... | |
shutdown () | |
Save all active sessions on shutdown. More... | |
getSessionFromInfo (SessionInfo $info, WebRequest $request) | |
Create a session corresponding to the passed SessionInfo. More... | |
deregisterSessionBackend (SessionBackend $backend) | |
Deregister a SessionBackend. More... | |
changeBackendId (SessionBackend $backend) | |
Change a SessionBackend's ID. More... | |
generateSessionId () | |
Generate a new random session ID. More... | |
setupPHPSessionHandler (PHPSessionHandler $handler) | |
Call setters on a PHPSessionHandler. More... | |
getSessionInfoForRequest (WebRequest $request) | |
Fetch the SessionInfo(s) for a request. More... | |
loadSessionInfoFromStore (SessionInfo &$info, WebRequest $request) | |
Load and verify the session info against the store. More... | |
getProviders () | |
Get the available SessionProviders. More... | |
This serves as the entry point to the MediaWiki session handling system.
Definition at line 41 of file SessionManager.php.
MediaWiki\Session\SessionManager::__construct | ( | $options = [] | ) |
array | $options |
Definition at line 139 of file SessionManager.php.
References $options, ConfigFactory\getDefaultInstance(), ObjectCache\getInstance(), MediaWiki\Session\SessionManager\setLogger(), and store.
|
static |
Auto-create the given user, if necessary.
Definition at line 379 of file SessionManager.php.
References wfDeprecated().
MediaWiki\Session\SessionManager::changeBackendId | ( | SessionBackend | $backend | ) |
Change a SessionBackend's ID.
SessionBackend | $backend |
Definition at line 903 of file SessionManager.php.
References MediaWiki\Session\SessionManager\generateSessionId(), MediaWiki\Session\SessionBackend\getSessionId(), and string.
MediaWiki\Session\SessionManager::deregisterSessionBackend | ( | SessionBackend | $backend | ) |
Deregister a SessionBackend.
SessionBackend | $backend |
Definition at line 885 of file SessionManager.php.
References MediaWiki\Session\SessionBackend\getId(), and MediaWiki\Session\SessionBackend\getSessionId().
MediaWiki\Session\SessionManager::generateSessionId | ( | ) |
Generate a new random session ID.
Definition at line 925 of file SessionManager.php.
References $key, MWCryptRand\generateHex(), store, wfBaseConvert(), and wfMemcKey().
Referenced by MediaWiki\Session\SessionManager\changeBackendId().
MediaWiki\Session\SessionManager::getEmptySession | ( | WebRequest | $request = null | ) |
Fetch a new, empty session.
The first provider configured that is able to provide an empty session will be used.
WebRequest | null | $request | Corresponding request. Any existing session associated with this WebRequest object will be overwritten. |
Implements MediaWiki\Session\SessionManagerInterface.
Definition at line 234 of file SessionManager.php.
References $request, and MediaWiki\Session\SessionManager\getEmptySessionInternal().
Referenced by MediaWiki\Session\SessionManager\getSessionForRequest().
|
private |
WebRequest | null | $request | |
string | null | $id | ID to force on the new session |
Definition at line 244 of file SessionManager.php.
References $key, $request, as, MediaWiki\Session\SessionInfo\compare(), MediaWiki\Session\SessionManager\getProviders(), MediaWiki\Session\SessionManager\getSessionFromInfo(), store, and wfMemcKey().
Referenced by MediaWiki\Session\SessionManager\getEmptySession(), and MediaWiki\Session\SessionManager\getSessionById().
|
static |
Get the "global" session.
If PHP's session_id() has been set, returns that session. Otherwise returns the session for RequestContext::getMain()->getRequest().
Definition at line 98 of file SessionManager.php.
References $request, RequestContext\getMain(), and MediaWiki\Session\PHPSessionHandler\isEnabled().
Referenced by MediaWiki\Auth\RememberMeAuthenticationRequest\__construct(), MediaWiki\Session\SessionBackend\checkPHPSession(), ApiLogout\execute(), SpecialUserLogout\execute(), ApiLogin\execute(), RequestContext\exportSession(), RawAction\onView(), SubmitAction\show(), ApiTestCase\tearDown(), and MediaWiki\Session\SessionManagerTest\testGetGlobalSession().
MediaWiki\Session\SessionManager::getProvider | ( | $name | ) |
Get a session provider by name.
Generally, this will only be used by internal implementation of some special session-providing mechanism. General purpose code, if it needs to access a SessionProvider at all, will use Session::getProvider().
string | $name |
Definition at line 447 of file SessionManager.php.
References $name, and MediaWiki\Session\SessionManager\getProviders().
Referenced by MediaWiki\Session\SessionManager\loadSessionInfoFromStore().
|
protected |
Get the available SessionProviders.
Definition at line 420 of file SessionManager.php.
References MediaWiki\Session\SessionManager\$sessionProviders, as, ObjectFactory\getObjectFromSpec(), and string.
Referenced by MediaWiki\Session\SessionManager\getEmptySessionInternal(), MediaWiki\Session\SessionManager\getProvider(), MediaWiki\Session\SessionManager\getSessionInfoForRequest(), MediaWiki\Session\SessionManager\getVaryCookies(), MediaWiki\Session\SessionManager\getVaryHeaders(), MediaWiki\Session\SessionManager\invalidateSessionsForUser(), and MediaWiki\Session\SessionManager\preventSessionsForUser().
MediaWiki\Session\SessionManager::getSessionById | ( | $id, | |
$create = false , |
|||
WebRequest | $request = null |
||
) |
Fetch a session by ID.
string | $id | |
bool | $create | If no session exists for $id, try to create a new one. May still return null if a session for $id exists but cannot be loaded. |
WebRequest | null | $request | Corresponding request. Any existing session associated with this WebRequest object will be overwritten. |
Implements MediaWiki\Session\SessionManagerInterface.
Definition at line 192 of file SessionManager.php.
References $key, $request, MediaWiki\Session\SessionManager\getEmptySessionInternal(), MediaWiki\Session\SessionManager\getSessionFromInfo(), MediaWiki\Session\SessionManager\loadSessionInfoFromStore(), MediaWiki\Session\SessionInfo\MIN_PRIORITY, store, and wfMemcKey().
MediaWiki\Session\SessionManager::getSessionForRequest | ( | WebRequest | $request | ) |
Fetch the session for a request.
WebRequest | $request | Any existing associated session will be reset to the session corresponding to the data in the request itself. |
if there are multiple sessions tied for top priority in the request. Exception has a property "sessionInfos" holding the SessionInfo objects for the sessions involved. |
Implements MediaWiki\Session\SessionManagerInterface.
Definition at line 181 of file SessionManager.php.
References MediaWiki\Session\SessionManager\getEmptySession(), MediaWiki\Session\SessionManager\getSessionFromInfo(), and MediaWiki\Session\SessionManager\getSessionInfoForRequest().
MediaWiki\Session\SessionManager::getSessionFromInfo | ( | SessionInfo | $info, |
WebRequest | $request | ||
) |
Create a session corresponding to the passed SessionInfo.
SessionInfo | $info | |
WebRequest | $request |
Definition at line 829 of file SessionManager.php.
References ScopedCallback\consume(), MediaWiki\Session\SessionBackend\delaySave(), MediaWiki\Session\SessionInfo\getId(), MediaWiki\Session\SessionInfo\isIdSafe(), MW_NO_SESSION, WebRequest\setSessionId(), store, MediaWiki\Session\SessionInfo\wasPersisted(), and MediaWiki\Session\SessionInfo\wasRemembered().
Referenced by MediaWiki\Session\SessionManager\getEmptySessionInternal(), MediaWiki\Session\SessionManager\getSessionById(), and MediaWiki\Session\SessionManager\getSessionForRequest().
|
private |
Fetch the SessionInfo(s) for a request.
WebRequest | $request |
Definition at line 475 of file SessionManager.php.
References as, MediaWiki\Session\SessionInfo\compare(), MediaWiki\Session\SessionManager\getProviders(), and MediaWiki\Session\SessionManager\loadSessionInfoFromStore().
Referenced by MediaWiki\Session\SessionManager\getSessionForRequest().
MediaWiki\Session\SessionManager::getVaryCookies | ( | ) |
Return the list of cookies that need varying on.
Implements MediaWiki\Session\SessionManagerInterface.
Definition at line 341 of file SessionManager.php.
References MediaWiki\Session\SessionManager\$varyCookies, as, MediaWiki\Session\SessionManager\getProviders(), and MW_NO_SESSION.
MediaWiki\Session\SessionManager::getVaryHeaders | ( | ) |
Return the HTTP headers that need varying on.
The return value is such that someone could theoretically do this:
Implements MediaWiki\Session\SessionManagerInterface.
Definition at line 318 of file SessionManager.php.
References $options, MediaWiki\Session\SessionManager\$varyHeaders, as, MediaWiki\Session\SessionManager\getProviders(), and MW_NO_SESSION.
MediaWiki\Session\SessionManager::invalidateSessionsForUser | ( | User | $user | ) |
Invalidate sessions for a user.
After calling this, existing sessions should be invalid. For mutable session providers, this generally means the user has to log in again; for immutable providers, it generally means the loss of session data.
User | $user |
Implements MediaWiki\Session\SessionManagerInterface.
Definition at line 304 of file SessionManager.php.
References as, MediaWiki\Auth\AuthManager\callLegacyAuthPlugin(), MediaWiki\Session\SessionManager\getProviders(), User\saveSettings(), and User\setToken().
MediaWiki\Session\SessionManager::isUserSessionPrevented | ( | $username | ) |
Test if a user is prevented.
string | $username |
Definition at line 412 of file SessionManager.php.
References $username.
|
private |
Load and verify the session info against the store.
SessionInfo | &$info | Will likely be replaced with an updated SessionInfo instance |
WebRequest | $request |
Definition at line 539 of file SessionManager.php.
References $blob, $key, false, MediaWiki\Session\SessionInfo\forceHTTPS(), MediaWiki\Session\SessionInfo\forceUse(), MediaWiki\Session\MetadataMergeException\getContext(), MediaWiki\Session\SessionInfo\getId(), MediaWiki\Session\SessionInfo\getPriority(), MediaWiki\Session\SessionInfo\getProvider(), MediaWiki\Session\SessionManager\getProvider(), MediaWiki\Session\SessionInfo\getProviderMetadata(), MediaWiki\Session\SessionInfo\getUserInfo(), MediaWiki\Session\SessionInfo\isIdSafe(), MediaWiki\Session\UserInfo\newAnonymous(), MediaWiki\Session\UserInfo\newFromId(), MediaWiki\Session\UserInfo\newFromName(), Hooks\run(), store, use, MediaWiki\Session\SessionInfo\wasPersisted(), MediaWiki\Session\SessionInfo\wasRemembered(), and wfMemcKey().
Referenced by MediaWiki\Session\SessionManager\getSessionById(), and MediaWiki\Session\SessionManager\getSessionInfoForRequest().
MediaWiki\Session\SessionManager::preventSessionsForUser | ( | $username | ) |
Prevent future sessions for the user.
The intention is that the named account will never again be usable for normal login (i.e. there is no way to undo the prevention of access).
string | $username |
Definition at line 397 of file SessionManager.php.
References $username, as, and MediaWiki\Session\SessionManager\getProviders().
|
static |
Reset the internal caching for unit testing.
Definition at line 945 of file SessionManager.php.
Referenced by MediaWikiTestCase\tearDown().
MediaWiki\Session\SessionManager::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 177 of file SessionManager.php.
References MediaWiki\Session\SessionManager\$logger.
Referenced by MediaWiki\Session\SessionManager\__construct().
MediaWiki\Session\SessionManager::setupPHPSessionHandler | ( | PHPSessionHandler | $handler | ) |
Call setters on a PHPSessionHandler.
PHPSessionHandler | $handler |
Definition at line 938 of file SessionManager.php.
References MediaWiki\Session\PHPSessionHandler\setManager(), and store.
Referenced by MediaWiki\Session\PHPSessionHandler\__construct(), and MediaWiki\Session\PHPSessionHandler\install().
MediaWiki\Session\SessionManager::shutdown | ( | ) |
Save all active sessions on shutdown.
Definition at line 456 of file SessionManager.php.
References as.
|
static |
Get the global SessionManager.
Definition at line 83 of file SessionManager.php.
Referenced by RequestContext\importScopedSession(), BotPassword\login(), MediaWiki\Auth\AuthManagerAuthPluginUser\resetAuthToken(), MediaWiki\Session\CookieSessionProviderTest\testCookieData(), MediaWiki\Session\CookieSessionProviderTest\testGetCookie(), MediaWiki\Session\SessionManagerTest\testGetGlobalSession(), MediaWiki\Session\CookieSessionProviderTest\testGetLoginCookieExpiration(), MediaWiki\Session\CookieSessionProviderTest\testGetRememberUserDuration(), MediaWiki\Session\CookieSessionProviderTest\testPersistSession(), MediaWiki\Session\CookieSessionProviderTest\testPersistSessionWithHook(), MediaWiki\Session\SessionBackendTest\testResetIdOfGlobalSession(), MediaWiki\Session\CookieSessionProviderTest\testSetLoggedOutCookie(), MediaWiki\Session\SessionManagerTest\testSingleton(), MediaWiki\Session\SessionBackendTest\testTakeOverGlobalSession(), MediaWiki\Session\SessionBackendTest\testUnpersistOfGlobalSession(), and MediaWiki\Session\CookieSessionProviderTest\testUnpersistSession().
|
static |
Validate a session ID.
string | $id |
Definition at line 362 of file SessionManager.php.
Referenced by MediaWiki\Session\SessionInfo\__construct(), MediaWiki\Session\ImmutableSessionProviderWithCookie\getSessionIdFromCookie(), MediaWiki\Session\CookieSessionProvider\provideSessionInfo(), and MediaWiki\Session\SessionManagerTest\testGenerateSessionId().
|
private |
Definition at line 70 of file SessionManager.php.
|
private |
Definition at line 73 of file SessionManager.php.
|
private |
Definition at line 55 of file SessionManager.php.
|
staticprivate |
Definition at line 46 of file SessionManager.php.
|
staticprivate |
Definition at line 49 of file SessionManager.php.
|
staticprivate |
Definition at line 43 of file SessionManager.php.
|
private |
Definition at line 52 of file SessionManager.php.
Referenced by MediaWiki\Session\SessionManager\setLogger().
|
private |
Definition at line 76 of file SessionManager.php.
|
private |
Definition at line 61 of file SessionManager.php.
Referenced by MediaWiki\Session\SessionManager\getProviders().
|
private |
Definition at line 58 of file SessionManager.php.
|
private |
Definition at line 64 of file SessionManager.php.
Referenced by MediaWiki\Session\SessionManager\getVaryCookies().
|
private |
Definition at line 67 of file SessionManager.php.
Referenced by MediaWiki\Session\SessionManager\getVaryHeaders().