Skip to content

Commit

Permalink
[Feature] Added additional settings to config
Browse files Browse the repository at this point in the history
  • Loading branch information
janicerar committed Oct 22, 2018
1 parent 8a73472 commit 37942ad
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
28 changes: 28 additions & 0 deletions config/lifeonscreen2fa.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
<?php

return [
/**
* Disable or enable middleware.
*/
'enabled' => env('GOOGLE_2FA_ENABLED', true),

'models' => [
/**
* Change this variable to your User model.
*/
'user' => 'App\User',
],
'tables' => [
/**
* Table in witch users are stored.
*/
'user' => 'users',
],

'recovery_codes' => [
/**
* Number of recovery codes that will be generated.
*/
'count' => 8,

/**
* Number of blocks in each recovery code.
*/
'blocks' => 3,

/**
* Number of characters in each block in recovery code.
*/
'chars_in_block' => 16,
],
];
8 changes: 4 additions & 4 deletions src/Google2fa.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public function authenticate()
$google2fa = new G2fa();
$recovery = new Recovery();
$secretKey = $google2fa->generateSecretKey();
$data['recovery'] = $recovery = $recovery
->setCount(8)
->setBlocks(3)
->setChars(16)
$data['recovery'] = $recovery
->setCount(config('lifeonscreen2fa.recovery_codes.count'))
->setBlocks(config('lifeonscreen2fa.recovery_codes.blocks'))
->setChars(config('lifeonscreen2fa.recovery_codes.chars_in_block'))
->toArray();

User2fa::where('user_id', auth()->user()->id)->delete();
Expand Down
11 changes: 7 additions & 4 deletions src/Http/Middleware/Google2fa.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Google2fa
*/
public function handle($request, Closure $next)
{
if (!config('lifeonscreen2fa.enabled')) {
return $next($request);
}
if ($request->path() === 'los/2fa/confirm' || $request->path() === 'los/2fa/authenticate'
|| $request->path() === 'los/2fa/register') {
return $next($request);
Expand All @@ -37,10 +40,10 @@ public function handle($request, Closure $next)
$google2fa = new G2fa();
$recovery = new Recovery();
$secretKey = $google2fa->generateSecretKey();
$data['recovery'] = $recovery = $recovery
->setCount(8)
->setBlocks(3)
->setChars(16)
$data['recovery'] = $recovery
->setCount(config('lifeonscreen2fa.recovery_codes.count'))
->setBlocks(config('lifeonscreen2fa.recovery_codes.blocks'))
->setChars(config('lifeonscreen2fa.recovery_codes.chars_in_block'))
->toArray();

User2fa::where('user_id', auth()->user()->id)->delete();
Expand Down

0 comments on commit 37942ad

Please sign in to comment.