Go to the documentation of this file.
55 parent::__construct();
58 'cookieOptions' => [],
63 if ( !isset(
$params[
'priority'] ) ) {
64 throw new \InvalidArgumentException( __METHOD__ .
': priority must be specified' );
69 throw new \InvalidArgumentException( __METHOD__ .
': Invalid priority' );
72 if ( !is_array(
$params[
'cookieOptions'] ) ) {
73 throw new \InvalidArgumentException( __METHOD__ .
': cookieOptions must be an array' );
76 $this->priority =
$params[
'priority'];
77 $this->cookieOptions =
$params[
'cookieOptions'];
79 unset( $this->params[
'priority'] );
80 unset( $this->params[
'cookieOptions'] );
89 'callUserSetCookiesHook' =>
false,
95 $this->cookieOptions += [
101 'httpOnly' =>
$config->
get(
'CookieHttpOnly' ),
106 $sessionId = $this->
getCookie( $request, $this->params[
'sessionName'],
'' );
109 'forceHTTPS' => $this->
getCookie( $request,
'forceHTTPS',
'',
false )
112 $info[
'id'] = $sessionId;
113 $info[
'persisted'] =
true;
117 if ( $userId !==
null ) {
120 }
catch ( \InvalidArgumentException $ex ) {
125 if ( $userName !==
null && $userInfo->getName() !== $userName ) {
126 $this->logger->warning(
127 'Session "{session}" requested with mismatched UserID and UserName cookies.',
129 'session' => $sessionId,
132 'cookie_username' => $userName,
133 'username' => $userInfo->getName(),
139 if ( $token !==
null ) {
140 if ( !hash_equals( $userInfo->getToken(), $token ) ) {
141 $this->logger->warning(
142 'Session "{session}" requested with invalid Token cookie.',
144 'session' => $sessionId,
146 'username' => $userInfo->getName(),
150 $info[
'userInfo'] = $userInfo->verified();
151 $info[
'persisted'] =
true;
152 } elseif ( isset( $info[
'id'] ) ) {
153 $info[
'userInfo'] = $userInfo;
159 } elseif ( isset( $info[
'id'] ) ) {
165 $this->logger->debug(
166 'Session "{session}" requested without UserID cookie',
168 'session' => $info[
'id'],
192 $this->logger->debug( __METHOD__ .
': Headers already sent' );
202 if ( $this->params[
'callUserSetCookiesHook'] && !
$user->isAnon() ) {
213 $options[
'secure'] = $this->config->get(
'CookieSecure' );
216 $response->setCookie( $this->params[
'sessionName'], $session->
getId(),
null,
220 foreach ( $cookies
as $key =>
$value ) {
225 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
233 if ( $sessionData ) {
234 $session->
addData( $sessionData );
242 $this->logger->debug( __METHOD__ .
': Headers already sent' );
252 $this->params[
'sessionName'], [
'prefix' =>
'' ] + $this->cookieOptions
255 foreach ( $cookies
as $key =>
$value ) {
256 $response->clearCookie( $key, $this->cookieOptions );
273 if ( $backend->shouldRememberUser() ) {
278 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
282 $response->setCookie(
'forceHTTPS',
'true', $expiration,
283 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
286 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
296 if ( $loggedOut + 86400 > time() &&
297 $loggedOut !== (
int)$this->
getCookie( $request,
'LoggedOut', $this->cookieOptions[
'prefix'] )
299 $request->response()->setCookie(
'LoggedOut', $loggedOut, $loggedOut + 86400,
300 $this->cookieOptions );
308 $this->cookieOptions[
'prefix'] .
'Token',
309 $this->cookieOptions[
'prefix'] .
'LoggedOut',
310 $this->params[
'sessionName'],
316 $name = $this->
getCookie( $request,
'UserName', $this->cookieOptions[
'prefix'] );
317 if (
$name !==
null ) {
329 $prefix = $this->cookieOptions[
'prefix'];
347 if (
$value ===
'deleted' ) {
365 if (
$user->isAnon() ) {
372 'UserID' =>
$user->getId(),
373 'UserName' =>
$user->getName(),
374 'Token' => $remember ? (
string)
$user->getToken() :
false,
387 if ( !
$user->isAnon() && $this->params[
'callUserSetCookiesHook'] ) {
389 'wsUserID' =>
$user->getId(),
390 'wsToken' =>
$user->getToken(),
391 'wsUserName' =>
$user->getName(),
399 return wfMessage(
'sessionprovider-nocookies' );
414 return [
'UserID',
'UserName',
'Token' ];
429 $normalExpiration = $this->config->get(
'CookieExpiration' );
431 if ( $shouldRememberUser && in_array( $cookieName, $extendedCookies,
true ) ) {
432 $extendedExpiration = $this->config->get(
'ExtendedLoginCookieExpiration' );
434 return ( $extendedExpiration !==
null ) ? (int)$extendedExpiration : (
int)$normalExpiration;
436 return (
int)$normalExpiration;
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Allows to change the fields on the form that will be generated $name
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
this hook is for auditing only $response
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.