MediaWiki  1.27.2
AuthenticationResponse.php
Go to the documentation of this file.
1 <?php
24 namespace MediaWiki\Auth;
25 
26 use Message;
27 
35  const PASS = 'PASS';
36 
38  const FAIL = 'FAIL';
39 
44  const RESTART = 'RESTART';
45 
47  const ABSTAIN = 'ABSTAIN';
48 
50  const UI = 'UI';
51 
53  const REDIRECT = 'REDIRECT';
54 
56  public $status;
57 
59  public $redirectTarget = null;
60 
66  public $redirectApiData = null;
67 
72  public $neededRequests = [];
73 
75  public $message = null;
76 
81  public $username = null;
82 
96  public $createRequest = null;
97 
104  public $linkRequest = null;
105 
111  public $loginRequest = null;
112 
117  public static function newPass( $username = null ) {
120  $ret->username = $username;
121  return $ret;
122  }
123 
128  public static function newFail( Message $msg ) {
131  $ret->message = $msg;
132  return $ret;
133  }
134 
139  public static function newRestart( Message $msg ) {
142  $ret->message = $msg;
143  return $ret;
144  }
145 
149  public static function newAbstain() {
152  return $ret;
153  }
154 
160  public static function newUI( array $reqs, Message $msg ) {
161  if ( !$reqs ) {
162  throw new \InvalidArgumentException( '$reqs may not be empty' );
163  }
164 
167  $ret->neededRequests = $reqs;
168  $ret->message = $msg;
169  return $ret;
170  }
171 
178  public static function newRedirect( array $reqs, $redirectTarget, $redirectApiData = null ) {
179  if ( !$reqs ) {
180  throw new \InvalidArgumentException( '$reqs may not be empty' );
181  }
182 
185  $ret->neededRequests = $reqs;
186  $ret->redirectTarget = $redirectTarget;
187  $ret->redirectApiData = $redirectApiData;
188  return $ret;
189  }
190 
191 }
the array() calling protocol came about after MediaWiki 1.4rc1.
const ABSTAIN
Indicates that the authentication provider does not handle this request.
const RESTART
Indicates that third-party authentication succeeded but no user exists.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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:1798
string $status
One of the constants above.
This is a value object to hold authentication response data.
AuthenticationRequest null $loginRequest
Returned with an AuthManager account creation PASS, this holds a request to pass to AuthManager::begi...
static newRedirect(array $reqs, $redirectTarget, $redirectApiData=null)
string null $redirectTarget
URL to redirect to for a REDIRECT response.
const FAIL
Indicates that the authentication failed.
static newUI(array $reqs, Message $msg)
mixed $redirectApiData
Data for a REDIRECT response that a client might use to query the remote site via its API rather than...
AuthenticationRequest null $linkRequest
Returned with a PrimaryAuthenticationProvider login PASS with no username, this holds a request to pa...
const PASS
Indicates that the authentication succeeded.
string null $username
Local user name from authentication.
const REDIRECT
Indicates that the authentication needs to be redirected to a third party to proceed.
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:35
AuthenticationRequest null $createRequest
Returned with a PrimaryAuthenticationProvider login FAIL or a PASS with no username, this holds a request that should result in a PASS when passed to that provider's PrimaryAuthenticationProvider::beginPrimaryAccountCreation().
AuthenticationRequest[] $neededRequests
Needed AuthenticationRequests to continue after a UI or REDIRECT response.
Message null $message
I18n message to display in case of UI or FAIL.
const UI
Indicates that the authentication needs further user input of some sort.