BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
MediaWiki\Auth\AuthenticationRequest Class Reference
Inheritance diagram for MediaWiki\Auth\AuthenticationRequest:
Collaboration diagram for MediaWiki\Auth\AuthenticationRequest:

Public Member Functions

 getUniqueId ()
 
 getFieldInfo ()
 
 getMetadata ()
 
 loadFromSubmission (array $data)
 
 describeCredentials ()
 

Static Public Member Functions

static loadRequestsFromSubmission (array $reqs, array $data)
 
static getRequestByClass (array $reqs, $class, $allowSubclasses=false)
 
static getUsernameFromRequests (array $reqs)
 
static mergeFieldInfo (array $reqs)
 
static __set_state ($data)
 

Public Attributes

const OPTIONAL = 0
 
const REQUIRED = 1
 
const PRIMARY_REQUIRED = 2
 
 $action = null
 
 $required = self::REQUIRED
 
 $returnToUrl = null
 
 $username = null
 

Detailed Description

This is a value object for authentication requests.

An AuthenticationRequest represents a set of form fields that are needed on and provided from a login, account creation, password change or similar form.

Since
1.27

Member Function Documentation

static MediaWiki\Auth\AuthenticationRequest::__set_state (   $data)
static

Implementing this mainly for use from the unit tests.

Parameters
array$data
Returns
AuthenticationRequest
MediaWiki\Auth\AuthenticationRequest::describeCredentials ( )

Describe the credentials represented by this request

This is used on requests returned by AuthenticationProvider::getAuthenticationRequests() for ACTION_LINK and ACTION_REMOVE and for requests returned in AuthenticationResponse::$linkRequest to create useful user interfaces.

Returns
Message[] with the following keys:
  • provider: A Message identifying the service that provides the credentials, e.g. the name of the third party authentication service.
  • account: A Message identifying the credentials themselves, e.g. the email address used with the third party authentication service.
MediaWiki\Auth\AuthenticationRequest::getFieldInfo ( )
abstract

Fetch input field info

The field info is an associative array mapping field names to info arrays. The info arrays have the following keys:

  • type: (string) Type of input. Types and equivalent HTML widgets are:
    • string: <input type="text">
    • password: <input type="password">
    • select: <select>
    • checkbox: <input type="checkbox">
    • multiselect: More a grid of checkboxes than <select multi>="">
    • button: <input type="submit"> (uses 'label' as button text)
    • hidden: Not visible to the user, but needs to be preserved for the next request
    • null: No widget, just display the 'label' message.
  • options: (array) Maps option values to Messages for the 'select' and 'multiselect' types.
  • value: (string) Value (for 'null' and 'hidden') or default value (for other types).
  • label: (Message) Text suitable for a label in an HTML form
  • help: (Message) Text suitable as a description of what the field is
  • optional: (bool) If set and truthy, the field may be left empty
  • sensitive: (bool) If set and truthy, the field is considered sensitive. Code using the request should avoid exposing the value of the field.
  • skippable: (bool) If set and truthy, the client is free to hide this field from the user to streamline the workflow. If all fields are skippable (except possibly a single button), no user interaction is required at all.

All AuthenticationRequests are populated from the same data, so most of the time you'll want to prefix fields names with something unique to the extension/provider (although in some cases sharing the field with other requests is the right thing to do, e.g. for a 'password' field).

Returns
array As above
MediaWiki\Auth\AuthenticationRequest::getMetadata ( )

Returns metadata about this request.

This is mainly for the benefit of API clients which need more detailed render hints than what's available through getFieldInfo(). Semantics are unspecified and left to the individual subclasses, but the contents of the array should be primitive types so that they can be transformed into JSON or similar formats.

Returns
array A (possibly nested) array with primitive types
static MediaWiki\Auth\AuthenticationRequest::getRequestByClass ( array  $reqs,
  $class,
  $allowSubclasses = false 
)
static

Select a request by class name.

Parameters
AuthenticationRequest[]$reqs
string$classClass name
bool$allowSubclassesIf true, also returns any request that's a subclass of the given class.
Returns
AuthenticationRequest|null Returns null if there is not exactly one matching request.
MediaWiki\Auth\AuthenticationRequest::getUniqueId ( )

Supply a unique key for deduplication

When the AuthenticationRequests instances returned by the providers are merged, the value returned here is used for keeping only one copy of duplicate requests.

Subclasses should override this if multiple distinct instances would make sense, i.e. the request class has internal state of some sort.

This value might be exposed to the user in web forms so it should not contain private information.

Returns
string
static MediaWiki\Auth\AuthenticationRequest::getUsernameFromRequests ( array  $reqs)
static

Get the username from the set of requests

Only considers requests that have a "username" field.

Parameters
AuthenticationRequest[]$reqs
Returns
string|null
Exceptions
\UnexpectedValueExceptionIf multiple different usernames are present.
MediaWiki\Auth\AuthenticationRequest::loadFromSubmission ( array  $data)

Initialize form submitted form data.

The default behavior is to to check for each key of self::getFieldInfo() in the submitted data, and copy the value - after type-appropriate transformations - to $this->$key. Most subclasses won't need to override this; if you do override it, make sure to always return false if self::getFieldInfo() returns an empty array.

Parameters
array$dataSubmitted data as an associative array (keys will correspond to getFieldInfo())
Returns
bool Whether the request data was successfully loaded
static MediaWiki\Auth\AuthenticationRequest::loadRequestsFromSubmission ( array  $reqs,
array  $data 
)
static

Update a set of requests with form submit data, discarding ones that fail

Parameters
AuthenticationRequest[]$reqs
array$data
Returns
AuthenticationRequest[]
static MediaWiki\Auth\AuthenticationRequest::mergeFieldInfo ( array  $reqs)
static

Merge the output of multiple AuthenticationRequest::getFieldInfo() calls.

Parameters
AuthenticationRequest[]$reqs
Returns
array
Exceptions
\UnexpectedValueExceptionIf fields cannot be merged

Member Data Documentation

const MediaWiki\Auth\AuthenticationRequest::OPTIONAL = 0

Indicates that the request is not required for authentication to proceed.

const MediaWiki\Auth\AuthenticationRequest::PRIMARY_REQUIRED = 2

Indicates that the request is required by a primary authentication provider. Since the user can choose which primary to authenticate with, the request might or might not end up being actually required.

const MediaWiki\Auth\AuthenticationRequest::REQUIRED = 1

Indicates that the request is required for authentication to proceed. This will only be used for UI purposes; it is the authentication providers' responsibility to verify that all required requests are present.


The documentation for this class was generated from the following file: