47 const STAGEID =
'sspmod_authYubiKey_Auth_Source_YubiKey.state';
58 const AUTHID =
'sspmod_authYubiKey_Auth_Source_YubiKey.AuthId';
73 assert(
'is_array($info)');
74 assert(
'is_array($config)');
79 if (array_key_exists(
'id',
$config)) {
83 if (array_key_exists(
'key',
$config)) {
84 $this->yubi_key =
$config[
'key'];
98 assert(
'is_array($state)');
123 assert(
'is_string($authStateId)');
124 assert(
'is_string($otp)');
130 assert(
'array_key_exists(self::AUTHID, $state)');
133 throw new Exception(
'Could not find authentication source with id ' .
$state[self::AUTHID]);
146 return 'WRONGUSERPASS';
163 $uid = substr ($otp, 0, strlen ($otp) - self::TOKENSIZE);
181 assert(
'is_string($otp)');
183 require_once dirname(dirname(dirname(dirname(__FILE__)))) .
'/libextinc/Yubico.php';
188 $yubi =
new Auth_Yubico($this->yubi_id, $this->yubi_key);
189 $auth = $yubi->verify($otp);
192 }
catch (Exception $e) {
193 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('AuthState', $_REQUEST)) $authStateId