Some logging and return 404 when not ready
This commit is contained in:
parent
a473a50341
commit
8f8b50d630
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user