PHP Class SimpleSAML_Auth_Simple, simplesamlphp

Datei anzeigen Open project: simplesamlphp/simplesamlphp Class Usage Examples

Public Methods

Method Description
__construct ( string $authSource ) Create an instance with the specified authsource.
getAttributes ( ) : array Retrieve attributes of the current user.
getAuthData ( string $name ) : mixed | null Retrieve authentication data.
getAuthDataArray ( ) : array | null Retrieve all authentication data.
getAuthSource ( ) : SimpleSAML_Auth_Source Retrieve the implementing authentication source.
getLoginURL ( string | null $returnTo = null ) : string Retrieve a URL that can be used to log the user in.
getLogoutURL ( string | null $returnTo = null ) : string Retrieve a URL that can be used to log the user out.
isAuthenticated ( ) : boolean Check if the user is authenticated.
login ( array $params = [] ) Start an authentication process.
logout ( string | array | null $params = null ) Log the user out.
logoutCompleted ( array $state ) Called when logout operation completes.
requireAuth ( array $params = [] ) Require the user to be authenticated.

Method Details

__construct() public method

Create an instance with the specified authsource.
public __construct ( string $authSource )
$authSource string The id of the authentication source.

getAttributes() public method

This function will retrieve the attributes of the current user if the user is authenticated. If the user isn't authenticated, it will return an empty array.
public getAttributes ( ) : array
return array The users attributes.

getAuthData() public method

Retrieve authentication data.
public getAuthData ( string $name ) : mixed | null
$name string The name of the parameter, e.g. 'Attributes', 'Expire' or 'saml:sp:IdP'.
return mixed | null The value of the parameter, or null if it isn't found or we are unauthenticated.

getAuthDataArray() public method

Retrieve all authentication data.
public getAuthDataArray ( ) : array | null
return array | null All persistent authentication data, or null if we aren't authenticated.

getAuthSource() public method

Retrieve the implementing authentication source.
public getAuthSource ( ) : SimpleSAML_Auth_Source
return SimpleSAML_Auth_Source The authentication source.

getLoginURL() public method

Retrieve a URL that can be used to log the user in.
public getLoginURL ( string | null $returnTo = null ) : string
$returnTo string | null The page the user should be returned to afterwards. If this parameter is null, the user will be returned to the current page.
return string A URL which is suitable for use in link-elements.

getLogoutURL() public method

Retrieve a URL that can be used to log the user out.
public getLogoutURL ( string | null $returnTo = null ) : string
$returnTo string | null The page the user should be returned to afterwards. If this parameter is null, the user will be returned to the current page.
return string A URL which is suitable for use in link-elements.

isAuthenticated() public method

This function checks if the user is authenticated with the default authentication source selected by the 'default-authsource' option in 'config.php'.
public isAuthenticated ( ) : boolean
return boolean True if the user is authenticated, false if not.

login() public method

This function accepts an array $params, which controls some parts of the authentication. The accepted parameters depends on the authentication source being used. Some parameters are generic: - 'ErrorURL': A URL that should receive errors from the authentication. - 'KeepPost': If the current request is a POST request, keep the POST data until after the authentication. - 'ReturnTo': The URL the user should be returned to after authentication. - 'ReturnCallback': The function we should call after the user has finished authentication. Please note: this function never returns.
public login ( array $params = [] )
$params array Various options to the authentication request.

logout() public method

This function logs the user out. It will never return. By default, it will cause a redirect to the current page after logging the user out, but a different URL can be given with the $params parameter. Generic parameters are: - 'ReturnTo': The URL the user should be returned to after logout. - 'ReturnCallback': The function that should be called after logout. - 'ReturnStateParam': The parameter we should return the state in when redirecting. - 'ReturnStateStage': The stage the state array should be saved with.
public logout ( string | array | null $params = null )
$params string | array | null Either the URL the user should be redirected to after logging out, or an array with parameters for the logout. If this parameter is null, we will return to the current page.

logoutCompleted() public static method

This function never returns.
public static logoutCompleted ( array $state )
$state array The state after the logout.

requireAuth() public method

If the user is authenticated, this function returns immediately. If the user isn't authenticated, this function will authenticate the user with the authentication source, and then return the user to the current page. This function accepts an array $params, which controls some parts of the authentication. See the login() method for a description.
public requireAuth ( array $params = [] )
$params array Various options to the authentication request. See the documentation.