-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ground work for 2FA Push and support for Authy Push notifications. #35
- Loading branch information
Showing
9 changed files
with
225 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
use shanemcc\phpdb\DB; | ||
|
||
/** | ||
* Task to verify 2FA Keys. | ||
* | ||
* Payload should be a json string with 'keyid', 'userid' and 'message' fields. | ||
*/ | ||
class verify_2fa_push extends TaskWorker { | ||
public function run($job) { | ||
$payload = $job->getPayload(); | ||
|
||
if (isset($payload['keyid']) && isset($payload['userid']) && isset($payload['message'])) { | ||
|
||
$key = TwoFactorKey::loadFromUserKey(DB::get(), $payload['userid'], $payload['keyid']); | ||
|
||
if ($key != FALSE && $key->isPush()) { | ||
if ($key->pushVerify($message)) { | ||
$key->setActive(true); | ||
if (!$key->isOneTime()) { $key->setLastUsed(time()); } | ||
$key->save(); | ||
|
||
$job->setResult('OK'); | ||
} else { | ||
$job->setError('Push not approved.'); | ||
} | ||
} else { | ||
$job->setError('Key not found'); | ||
} | ||
|
||
|
||
} else { | ||
$job->setError('Missing fields in payload.'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters