48 const STAGEID =
'sspmod_authYubiKey_Auth_Source_YubiKey.state';
59 const AUTHID =
'sspmod_authYubiKey_Auth_Source_YubiKey.AuthId';
75 assert(is_array(
$info));
81 if (array_key_exists(
'id',
$config)) {
85 if (array_key_exists(
'key',
$config)) {
86 $this->yubi_key =
$config[
'key'];
127 assert(is_string($otp));
133 assert(array_key_exists(self::AUTHID,
$state));
136 throw new Exception(
'Could not find authentication source with id '.
$state[self::AUTHID]);
148 return 'WRONGUSERPASS';
166 $uid = substr($otp, 0, strlen ($otp) - self::TOKENSIZE);
184 assert(is_string($otp));
186 require_once dirname(dirname(dirname(dirname(__FILE__)))).
'/libextinc/Yubico.php';
189 $yubi =
new Auth_Yubico($this->yubi_id, $this->yubi_key);
193 }
catch (Exception $e) {
194 SimpleSAML\Logger::info(
'YubiKey:'.$this->authId.
': Validation error (otp '.$otp.
'), debug output: '.$yubi->getLastResponse());
198 SimpleSAML\Logger::info(
'YubiKey:'.$this->authId.
': YubiKey otp '.$otp.
' validated successfully: '.$yubi->getLastResponse());
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
An exception for terminatinating execution or to throw for unit testing.
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
static getById($authId, $type=null)
Retrieve authentication source.
static completeAuth(&$state)
Complete authentication.
static saveState(&$state, $stage, $rawId=false)
Save the state.
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
getErrorCode()
Retrieve the error code given when throwing this error.
__construct($info, $config)
Constructor for this authentication source.
const AUTHID
The key of the AuthId field in the state.
const TOKENSIZE
The number of characters of the OTP that is the secure token.
login($otp)
Attempt to log in using the given username and password.
$yubi_id
The client id/key for use with the Auth_Yubico PHP module.
authenticate(&$state)
Initialize login.
static handleLogin($authStateId, $otp)
Handle login request.
static getYubiKeyPrefix($otp)
Return the user id part of a one time passord.
const STAGEID
The string used to identify our states.
if(!array_key_exists('StateId', $_REQUEST)) $id
if(array_key_exists('yes', $_REQUEST)) $attributes
if(!array_key_exists('AuthState', $_REQUEST)) $authStateId