MediaWiki REL1_32
AuthenticationResponse.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Auth;
25
27
39 const PASS = 'PASS';
40
42 const FAIL = 'FAIL';
43
49 const RESTART = 'RESTART';
50
52 const ABSTAIN = 'ABSTAIN';
53
55 const UI = 'UI';
56
58 const REDIRECT = 'REDIRECT';
59
61 public $status;
62
64 public $redirectTarget = null;
65
71 public $redirectApiData = null;
72
79 public $neededRequests = [];
80
82 public $message = null;
83
85 public $messageType = 'warning';
86
91 public $username = null;
92
109 public $createRequest = null;
110
119 public $linkRequest = null;
120
127 public $loginRequest = null;
128
134 public static function newPass( $username = null ) {
136 $ret->status = self::PASS;
137 $ret->username = $username;
138 return $ret;
139 }
140
146 public static function newFail( Message $msg ) {
148 $ret->status = self::FAIL;
149 $ret->message = $msg;
150 $ret->messageType = 'error';
151 return $ret;
152 }
153
159 public static function newRestart( Message $msg ) {
161 $ret->status = self::RESTART;
162 $ret->message = $msg;
163 return $ret;
164 }
165
170 public static function newAbstain() {
172 $ret->status = self::ABSTAIN;
173 return $ret;
174 }
175
183 public static function newUI( array $reqs, Message $msg, $msgtype = 'warning' ) {
184 if ( !$reqs ) {
185 throw new \InvalidArgumentException( '$reqs may not be empty' );
186 }
187 if ( $msgtype !== 'warning' && $msgtype !== 'error' ) {
188 throw new \InvalidArgumentException( $msgtype . ' is not a valid message type.' );
189 }
190
192 $ret->status = self::UI;
193 $ret->neededRequests = $reqs;
194 $ret->message = $msg;
195 $ret->messageType = $msgtype;
196 return $ret;
197 }
198
206 public static function newRedirect( array $reqs, $redirectTarget, $redirectApiData = null ) {
207 if ( !$reqs ) {
208 throw new \InvalidArgumentException( '$reqs may not be empty' );
209 }
210
212 $ret->status = self::REDIRECT;
213 $ret->neededRequests = $reqs;
214 $ret->redirectTarget = $redirectTarget;
215 $ret->redirectApiData = $redirectApiData;
216 return $ret;
217 }
218
219}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This is a value object for authentication requests.
This is a value object to hold authentication response data.
const FAIL
Indicates that the authentication failed.
const PASS
Indicates that the authentication succeeded.
string null $username
Local user name from authentication.
string null $redirectTarget
URL to redirect to for a REDIRECT response.
AuthenticationRequest null $linkRequest
When returned with a PrimaryAuthenticationProvider login PASS with no username, the request this hold...
const UI
Indicates that the authentication needs further user input of some sort.
static newRedirect(array $reqs, $redirectTarget, $redirectApiData=null)
AuthenticationRequest[] $neededRequests
Needed AuthenticationRequests to continue after a UI or REDIRECT response.
const REDIRECT
Indicates that the authentication needs to be redirected to a third party to proceed.
string $status
One of the constants above.
const ABSTAIN
Indicates that the authentication provider does not handle this request.
Message null $message
I18n message to display in case of UI or FAIL.
mixed $redirectApiData
Data for a REDIRECT response that a client might use to query the remote site via its API rather than...
AuthenticationRequest null $loginRequest
Returned with an AuthManager account creation PASS, this holds a request to pass to AuthManager::begi...
string $messageType
Whether the $message is an error or warning message, for styling reasons.
AuthenticationRequest null $createRequest
Returned with a PrimaryAuthenticationProvider login FAIL or a PASS with no username,...
static newUI(array $reqs, Message $msg, $msgtype='warning')
const RESTART
Indicates that third-party authentication succeeded but no user exists.
The Message class provides methods which fulfil two basic services:
Definition Message.php:160
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 noclasses & $ret
Definition hooks.txt:2054
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
Definition injection.txt:37
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))