Skip to content

Commit

Permalink
Adding support for custom YubiKey validation server
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas K. Dionysopoulos committed Nov 23, 2013
1 parent 98048b8 commit fead88c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

PLG_TWOFACTORAUTH_YUBIKEY="Two Factor Authentication - YubiKey"

PLG_TWOFACTORAUTH_YUBIKEY_CUSTOMSERVER_DESC="Enter the full URL of your custom validation server, e.g. <tt>http://www.example.com/mykeyserver/wsapi/2.0/verify</tt>. Custom validation servers can be created by using the Free and Open Source Software published by YubiCo at http://www.yubico.com/develop/open-source-software/validation-server/ Leave this blank if you want to use the public YubiCloud servers (default) or if you are not sure what this option means."
PLG_TWOFACTORAUTH_YUBIKEY_CUSTOMSERVER_LABEL="Custom validation server"
PLG_TWOFACTORAUTH_YUBIKEY_ERR_VALIDATIONFAILED="You did not enter a valid YubiKey secret code or the YubiCloud servers are unreachable at this time."
PLG_TWOFACTORAUTH_YUBIKEY_INTRO="This feature allows you to use a YubiKey secure hardware token for two factor authentication. On top of your username and password you will also need to insert your YubiKey in your computer's USB port, click inside the Secret Key area of the site's login area and touch YubiKey's gold disk. The secret code generated by your YubiKey is unique to your device and changes constantly. This provides extra protection against hackers logging in to your account even if they were able to get hold of your password."
PLG_TWOFACTORAUTH_YUBIKEY_METHOD_TITLE="YubiKey"
Expand Down
29 changes: 23 additions & 6 deletions plugins/twofactorauth/yubikey/yubikey.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,22 @@ public function onUserTwofactorAuthenticate($credentials, $options)
*/
public function validateYubikeyOTP($otp)
{
$server_queue = array(
'api.yubico.com', 'api2.yubico.com', 'api3.yubico.com',
'api4.yubico.com', 'api5.yubico.com'
);
$customURL = $this->params->get('customserver', '');
$customURL = trim($customURL);

shuffle($server_queue);
if (!empty($customURL))
{
$server_queue = array($customURL);
}
else
{
$server_queue = array(
'api.yubico.com', 'api2.yubico.com', 'api3.yubico.com',
'api4.yubico.com', 'api5.yubico.com'
);

shuffle($server_queue);
}

$gotResponse = false;
$check = false;
Expand All @@ -299,7 +309,14 @@ public function validateYubikeyOTP($otp)
{
$server = array_shift($server_queue);

$uri = new JUri('https://' . $server . '/wsapi/2.0/verify');
if (!empty($customURL))
{
$uri = new JUri($server);
}
else
{
$uri = new JUri('https://' . $server . '/wsapi/2.0/verify');
}

// I don't see where this ID is used?
$uri->setVar('id', 1);
Expand Down
5 changes: 5 additions & 0 deletions plugins/twofactorauth/yubikey/yubikey.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<option value="2">PLG_TWOFACTORAUTH_YUBIKEY_SECTION_ADMIN</option>
<option value="3">PLG_TWOFACTORAUTH_YUBIKEY_SECTION_BOTH</option>
</field>

<field name="customserver" type="text"
default=""
description="PLG_TWOFACTORAUTH_YUBIKEY_CUSTOMSERVER_DESC"
label="PLG_TWOFACTORAUTH_YUBIKEY_CUSTOMSERVER_LABEL" />
</fieldset>
</fields>
</config>
Expand Down

0 comments on commit fead88c

Please sign in to comment.