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);
190 $uid = self::getYubiKeyPrefix($otp);
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());
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.
Create styles array
The data for the language used.
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.