PHP Class OneLogin_Saml2_Auth

Mostra file Open project: onelogin/php-saml Class Usage Examples

Public Methods

Method Description
__construct ( array | object | null $oldSettings = null ) Initializes the SP SAML instance.
buildRequestSignature ( string $samlRequest, string $relayState, string $signAlgorithm = XMLSecurityKey::RSA_SHA1 ) : string Generates the Signature for a SAML Request
buildResponseSignature ( string $samlResponse, string $relayState, string $signAlgorithm = XMLSecurityKey::RSA_SHA1 ) : string Generates the Signature for a SAML Response
getAttribute ( string $name ) : array | null Returns the requested SAML attribute
getAttributes ( ) : array Returns the set of SAML attributes.
getErrors ( ) : array Returns if there were any error
getLastErrorReason ( ) : string Returns the reason for the last error
getLastRequestID ( ) : string Gets the ID of the last AuthNRequest or LogoutRequest generated by the Service Provider.
getNameId ( ) : string Returns the nameID
getNameIdFormat ( ) : string Returns the nameID Format
getSLOurl ( ) : string Gets the SLO url.
getSSOurl ( ) : string Gets the SSO url.
getSessionExpiration ( ) : DateTime | null Returns the SessionNotOnOrAfter
getSessionIndex ( ) : string | null Returns the SessionIndex
getSettings ( ) : OneLogin_Saml2_Settings Returns the settings info
isAuthenticated ( ) : boolean Checks if the user is authenticated or not.
login ( string | null $returnTo = null, array $parameters = [], boolean $forceAuthn = false, boolean $isPassive = false, boolean $stay = false, boolean $setNameIdPolicy = true ) : If Initiates the SSO process.
logout ( string | null $returnTo = null, array $parameters = [], string | null $nameId = null, string | null $sessionIndex = null, boolean $stay = false, string | null $nameIdFormat = null ) : If Initiates the SLO process.
processResponse ( string | null $requestId = null ) Process the SAML Response sent by the IdP.
processSLO ( boolean $keepLocalSession = false, string | null $requestId = null, boolean $retrieveParametersFromServer = false, callable $cbDeleteSession = null, boolean $stay = false ) : string | void Process the SAML Logout Response / Logout Request sent by the IdP.
redirectTo ( string $url = '', array $parameters = [], boolean $stay = false ) Redirects the user to the url past by parameter or to the url that we defined in our SSO Request.
setStrict ( boolean $value ) : array Set the strict mode active/disable

Method Details

__construct() public method

Initializes the SP SAML instance.
public __construct ( array | object | null $oldSettings = null )
$oldSettings array | object | null Setting data (You can provide a OneLogin_Saml_Settings, the settings object of the Saml folder implementation)

buildRequestSignature() public method

Generates the Signature for a SAML Request
public buildRequestSignature ( string $samlRequest, string $relayState, string $signAlgorithm = XMLSecurityKey::RSA_SHA1 ) : string
$samlRequest string The SAML Request
$relayState string The RelayState
$signAlgorithm string Signature algorithm method
return string A base64 encoded signature

buildResponseSignature() public method

Generates the Signature for a SAML Response
public buildResponseSignature ( string $samlResponse, string $relayState, string $signAlgorithm = XMLSecurityKey::RSA_SHA1 ) : string
$samlResponse string The SAML Response
$relayState string The RelayState
$signAlgorithm string Signature algorithm method
return string A base64 encoded signature

getAttribute() public method

Returns the requested SAML attribute
public getAttribute ( string $name ) : array | null
$name string The requested attribute of the user.
return array | null Requested SAML attribute ($name).

getAttributes() public method

Returns the set of SAML attributes.
public getAttributes ( ) : array
return array Attributes of the user.

getErrors() public method

Returns if there were any error
public getErrors ( ) : array
return array Errors

getLastErrorReason() public method

Returns the reason for the last error
public getLastErrorReason ( ) : string
return string Error reason

getLastRequestID() public method

Gets the ID of the last AuthNRequest or LogoutRequest generated by the Service Provider.
public getLastRequestID ( ) : string
return string The ID of the Request SAML message.

getNameId() public method

Returns the nameID
public getNameId ( ) : string
return string The nameID of the assertion

getNameIdFormat() public method

Returns the nameID Format
public getNameIdFormat ( ) : string
return string The nameID Format of the assertion

getSLOurl() public method

Gets the SLO url.
public getSLOurl ( ) : string
return string The url of the Single Logout Service

getSSOurl() public method

Gets the SSO url.
public getSSOurl ( ) : string
return string The url of the Single Sign On Service

getSessionExpiration() public method

Returns the SessionNotOnOrAfter
public getSessionExpiration ( ) : DateTime | null
return DateTime | null The SessionNotOnOrAfter of the assertion

getSessionIndex() public method

Returns the SessionIndex
public getSessionIndex ( ) : string | null
return string | null The SessionIndex of the assertion

getSettings() public method

Returns the settings info
public getSettings ( ) : OneLogin_Saml2_Settings
return OneLogin_Saml2_Settings The settings data.

isAuthenticated() public method

Checks if the user is authenticated or not.
public isAuthenticated ( ) : boolean
return boolean True if the user is authenticated

login() public method

Initiates the SSO process.
public login ( string | null $returnTo = null, array $parameters = [], boolean $forceAuthn = false, boolean $isPassive = false, boolean $stay = false, boolean $setNameIdPolicy = true ) : If
$returnTo string | null The target URL the user should be returned to after login.
$parameters array Extra parameters to be added to the GET
$forceAuthn boolean When true the AuthNReuqest will set the ForceAuthn='true'
$isPassive boolean When true the AuthNReuqest will set the Ispassive='true'
$stay boolean True if we want to stay (returns the url string) False to redirect
$setNameIdPolicy boolean When true the AuthNReuqest will set a nameIdPolicy element
return If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters

logout() public method

Initiates the SLO process.
public logout ( string | null $returnTo = null, array $parameters = [], string | null $nameId = null, string | null $sessionIndex = null, boolean $stay = false, string | null $nameIdFormat = null ) : If
$returnTo string | null The target URL the user should be returned to after logout.
$parameters array Extra parameters to be added to the GET
$nameId string | null The NameID that will be set in the LogoutRequest.
$sessionIndex string | null The SessionIndex (taken from the SAML Response in the SSO process).
$stay boolean True if we want to stay (returns the url string) False to redirect
$nameIdFormat string | null The NameID Format will be set in the LogoutRequest.
return If $stay is True, it return a string with the SLO URL + LogoutRequest + parameters

processResponse() public method

Process the SAML Response sent by the IdP.
public processResponse ( string | null $requestId = null )
$requestId string | null The ID of the AuthNRequest sent by this SP to the IdP

processSLO() public method

Process the SAML Logout Response / Logout Request sent by the IdP.
public processSLO ( boolean $keepLocalSession = false, string | null $requestId = null, boolean $retrieveParametersFromServer = false, callable $cbDeleteSession = null, boolean $stay = false ) : string | void
$keepLocalSession boolean When false will destroy the local session, otherwise will keep it
$requestId string | null The ID of the LogoutRequest sent by this SP to the IdP
$retrieveParametersFromServer boolean
$cbDeleteSession callable
$stay boolean True if we want to stay (returns the url string) False to redirect
return string | void

redirectTo() public method

Redirects the user to the url past by parameter or to the url that we defined in our SSO Request.
public redirectTo ( string $url = '', array $parameters = [], boolean $stay = false )
$url string The target URL to redirect the user.
$parameters array Extra parameters to be passed as part of the url
$stay boolean True if we want to stay (returns the url string) False to redirect

setStrict() public method

Set the strict mode active/disable
public setStrict ( boolean $value ) : array
$value boolean Strict parameter
return array The settings data.