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);
191 $uid = self::getYubiKeyPrefix($otp);
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());
static getYubiKeyPrefix($otp)
Return the user id part of a one time passord.
$yubi_id
The client id/key for use with the Auth_Yubico PHP module.
const AUTHID
The key of the AuthId field in the state.
login($otp)
Attempt to log in using the given username and password.
const TOKENSIZE
The number of characters of the OTP that is the secure token.
if(!array_key_exists('StateId', $_REQUEST)) $id
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
__construct($info, $config)
Constructor for this authentication source.
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
authenticate(&$state)
Initialize login.
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
if(array_key_exists('yes', $_REQUEST)) $attributes
const STAGEID
The string used to identify our states.
static handleLogin($authStateId, $otp)
Handle login request.
static completeAuth(&$state)
Complete authentication.
static getById($authId, $type=null)
Retrieve authentication source.
if(!array_key_exists('AuthState', $_REQUEST)) $authStateId
getErrorCode()
Retrieve the error code given when throwing this error.
static saveState(&$state, $stage, $rawId=false)
Save the state.