Some logging and return 404 when not ready

This commit is contained in:
Deon George 2020-08-12 23:18:59 +10:00
parent a473a50341
commit 8f8b50d630
2 changed files with 14 additions and 3 deletions

View File

@ -70,7 +70,6 @@ class Nonce
return NULL;
}
Log::debug(sprintf('A: %s, B: %s',$o->created_at->diffInMinutes(Carbon::now()),config('sqrl.nonce_age')));
// Delete the old nonce
if ($o->created_at->diffInMinutes(Carbon::now()) > config('sqrl.nonce_age')) {
$o->delete();

View File

@ -138,6 +138,8 @@ class SQRLController extends Controller
// If the nonce is old or doesnt exist.
if (! $o) {
Log::debug(sprintf('isReady: Invalid Nonce [%s]',$request->get('nut')));
return response()->json([
'isReady'=>FALSE,
'msg'=>'Invalid Nonce, or Nonce expired'
@ -146,6 +148,8 @@ class SQRLController extends Controller
// Validate the IP matches - since the request would come from the same device client
if ($o->ip !== $request->ip()) {
Log::debug(sprintf('isReady: IP Mismatch [%s] != [%s]',$o->ip,$request->ip));
return response()->json([
'isReady'=>FALSE,
'msg' => 'IP Mismatch',
@ -154,13 +158,17 @@ class SQRLController extends Controller
// Has the nonce be validated
if ($o->verified != 1) {
Log::debug(sprintf('isReady: Not Verified [%s]',$o->verified));
return response()->json([
'isReady'=>FALSE,
'msg'=>'Not Ready'
],200);
],404);
}
if ($o->pubkey && $o->pubkey->disabled) {
Log::debug(sprintf('isReady: SQRL Disabled [%s]',$o->pubkey));
return response()->json([
'isReady'=>FALSE,
'msg'=>'SQRL disabled for user'
@ -169,6 +177,8 @@ class SQRLController extends Controller
switch ($o->type) {
case 'auth':
Log::debug(sprintf('isReady: Authenticated [%s]',$o->pubkey));
return response()->json([
'isReady'=>TRUE,
'msg'=>'SQRL authenticated',
@ -180,10 +190,12 @@ class SQRLController extends Controller
}
} else {
Log::debug(sprintf('isReady: Not Nut?',$request->get('nut')));
return response()->json([
'isReady'=>FALSE,
'msg'=>'Not Found!'
],404);
],200);
}
}
}