PHP Class SimpleSAML_Auth_State, simplesamlphp

The state must be an associative array. This class will add additional keys to this array. These keys will always start with 'SimpleSAML_Auth_State.'. It is also possible to add a restart URL to the state. If state information is lost, for example because it timed out, or the user loaded a bookmarked page, the loadState function will redirect to this URL. To use this, set $state[SimpleSAML_Auth_State::RESTART] to this URL. Both the saveState and the loadState function takes in a $stage parameter. This parameter is a security feature, and is used to prevent the user from taking a state saved one place and using it as input a different place. The $stage parameter must be a unique string. To maintain uniqueness, it must be on the form "." or ":". There is also support for passing exceptions through the state. By defining an exception handler when creating the state array, users of the state array can call throwException with the state and the exception. This exception will be passed to the handler defined by the EXCEPTION_HANDLER_URL or EXCEPTION_HANDLER_FUNC elements of the state array.
Author: Olav Morken, UNINETT AS.
Afficher le fichier Open project: simplesamlphp/simplesamlphp Class Usage Examples

Méthodes publiques

Méthode Description
cloneState ( array $state ) : array Clone the state.
deleteState ( &$state ) Delete state.
getPersistentAuthData ( array $state ) : array Get the persistent authentication state from the state array.
getStateId ( &$state, boolean $rawId = false ) : string Retrieve the ID of a state array.
loadExceptionState ( string | null $id = null ) : array | null Retrieve an exception state.
loadState ( string $id, string $stage, boolean $allowMissing = false ) : array | null Retrieve saved state.
parseStateID ( string $stateId ) : array Get the ID and (optionally) a URL embedded in a StateID, in the form 'id:url'.
saveState ( &$state, string $stage, boolean $rawId = false ) : string Save the state.
throwException ( array $state, SimpleSAML_Error_Exception $exception ) Throw exception to the state exception handler.

Private Methods

Méthode Description
getStateTimeout ( ) : integer Retrieve state timeout.

Method Details

cloneState() public static méthode

This function clones and returns the new cloned state.
public static cloneState ( array $state ) : array
$state array The original request state.
Résultat array Cloned state data.

deleteState() public static méthode

This function deletes the given state to prevent the user from reusing it later.
public static deleteState ( &$state )

getPersistentAuthData() public static méthode

Get the persistent authentication state from the state array.
public static getPersistentAuthData ( array $state ) : array
$state array The state array to analyze.
Résultat array The persistent authentication state.

getStateId() public static méthode

Note that this function will not save the state.
public static getStateId ( &$state, boolean $rawId = false ) : string
$rawId boolean Return a raw ID, without a restart URL. Defaults to FALSE.
Résultat string Identifier which can be used to retrieve the state later.

loadExceptionState() public static méthode

Retrieve an exception state.
public static loadExceptionState ( string | null $id = null ) : array | null
$id string | null The exception id. Can be NULL, in which case it will be retrieved from the request.
Résultat array | null The state array with the exception, or NULL if no exception was thrown.

loadState() public static méthode

This function retrieves saved state information. If the state information has been lost, it will attempt to restart the request by calling the restart URL which is embedded in the state information. If there is no restart information available, an exception will be thrown.
public static loadState ( string $id, string $stage, boolean $allowMissing = false ) : array | null
$id string State identifier (with embedded restart information).
$stage string The stage the state should have been saved in.
$allowMissing boolean Whether to allow the state to be missing.
Résultat array | null State information, or null if the state is missing and $allowMissing is true.

parseStateID() public static méthode

Get the ID and (optionally) a URL embedded in a StateID, in the form 'id:url'.
Author: Andreas Solberg, UNINETT AS ([email protected])
Author: Jaime Perez, UNINETT AS ([email protected])
public static parseStateID ( string $stateId ) : array
$stateId string The state ID to use.
Résultat array A hashed array with the ID and the URL (if any), in the 'id' and 'url' keys, respectively. If there's no URL in the input parameter, NULL will be returned as the value for the 'url' key.

saveState() public static méthode

This function saves the state, and returns an id which can be used to retrieve it later. It will also update the $state array with the identifier.
public static saveState ( &$state, string $stage, boolean $rawId = false ) : string
$stage string The current stage in the login process.
$rawId boolean Return a raw ID, without a restart URL.
Résultat string Identifier which can be used to retrieve the state later.

throwException() public static méthode

Throw exception to the state exception handler.
public static throwException ( array $state, SimpleSAML_Error_Exception $exception )
$state array The state array.
$exception SimpleSAML_Error_Exception The exception.