Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7db3df7
[WIP] Add google2fa depend and views
asbiin Dec 22, 2017
b8f3803
[WIP] Add check for code when enabling 2FA, improve views
asbiin Dec 26, 2017
280498a
Update composer
asbiin Dec 26, 2017
f5ef3f9
Add a Command to deactivate 2FA for a user
asbiin Dec 26, 2017
9c956a5
Add a new conf in the .env file to enable/disable 2FA
asbiin Dec 26, 2017
70cb16b
Use the login function from Authenticator
asbiin Dec 26, 2017
a6cbd94
Add some tests
asbiin Dec 27, 2017
b0ef8cc
Updating composer
asbiin Dec 27, 2017
df3b0a4
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Dec 27, 2017
a1c1468
Commit StyleCI analysis
asbiin Dec 27, 2017
e49f927
Add a Security item in the sidebar, and fix other stuffs (translation…
asbiin Jan 1, 2018
63bc2f3
Update lang file (en) that was missed on the last commit
asbiin Jan 1, 2018
6f44483
Add a comment to the env example file
asbiin Jan 1, 2018
0d37211
Renaming controller, add good return message
asbiin Jan 2, 2018
c8c8266
StyleCI recommandations
asbiin Jan 2, 2018
db98f2c
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Jan 2, 2018
b81a417
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Jan 2, 2018
6006cf6
Update messages
asbiin Jan 4, 2018
663db7c
Use app laravel function
asbiin Jan 4, 2018
42260cf
Change route for 2fa validation
asbiin Jan 4, 2018
2c5b1db
Fix layout and some messages
asbiin Jan 6, 2018
a740b68
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Jan 6, 2018
b37c399
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Jan 6, 2018
28380f2
Fix styleci
asbiin Jan 6, 2018
fbe4586
Merge branch '164-2FA-two-factor-auth' of github.com:asbiin/monica in…
asbiin Jan 6, 2018
efe87c5
Add texts to every lang files
asbiin Jan 6, 2018
8d0e1bf
Fix stylceci
asbiin Jan 6, 2018
151535b
Add some infos
asbiin Jan 6, 2018
a7c0cfa
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Jan 6, 2018
0b0f393
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Jan 6, 2018
d2159bb
Merge branch 'master' into 164-2FA-two-factor-auth
asbiin Jan 7, 2018
06612eb
Review AddGoogle2faSecretToUsers
asbiin Jan 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[WIP] Add google2fa depend and views
  • Loading branch information
asbiin committed Dec 22, 2017
commit 7db3df78f4f2886c5cd6f6d4c85898932b254322
81 changes: 81 additions & 0 deletions app/Http/Controllers/Settings/Google2FAController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace App\Http\Controllers\Settings;

use Crypt;
use Google2FA;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Validation\ValidatesRequests;
use \ParagonIE\ConstantTime\Base32;

class Google2FAController extends Controller
{
use ValidatesRequests;

/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('web');
}

/**
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function enableTwoFactor(Request $request)
{
//generate new secret
$secret = $this->generateSecret();

//get user
$user = $request->user();

//encrypt and then save secret
$user->google2fa_secret = Crypt::encrypt($secret);
$user->save();

//generate image for QR barcode
$imageDataUri = Google2FA::getQRCodeInline(
$request->getHttpHost(),
$user->email,
$secret,
200
);

return view('settings.2fa.enable', ['image' => $imageDataUri, 'secret' => $secret]);
}

/**
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function disableTwoFactor(Request $request)
{
$user = $request->user();

//make secret column blank
$user->google2fa_secret = null;
$user->save();

return view('settings.2fa.disable');
}

/**
* Generate a secret key in Base32 format
*
* @return string
*/
private function generateSecret()
{
$google2fa = app('pragmarx.google2fa');

return $google2fa->generateSecretKey(32);
}
}
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ class Kernel extends HttpKernel
//'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'throttle' => \App\Http\Middleware\ThrottleRequestsMiddleware::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'2fa' => \PragmaRX\Google2FALaravel\Middleware::class,
];
}
2 changes: 1 addition & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class User extends Authenticatable
* @var array
*/
protected $hidden = [
'password', 'remember_token',
'password', 'remember_token', 'google2fa_secret',
];

/**
Expand Down
28 changes: 16 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@
"type": "project",
"require": {
"php": ">=7.0.0",
"laravel/framework": "5.5.*",
"barryvdh/laravel-debugbar": "^2.2",
"jenssegers/date": "^3.2",
"ext-intl": "*",
"predis/predis": "^1.1",
"guzzlehttp/guzzle": "^6.2",
"fzaninotto/faker": "^1.6",
"bacon/bacon-qr-code": "^1.0",
"barryvdh/laravel-debugbar": "^2.2",
"doctrine/dbal": "^2.5",
"laravel/socialite": "^3.0",
"intervention/image": "^2.3",
"sabre/vobject": "^4.1",
"erusev/parsedown": "~1.6",
"fzaninotto/faker": "^1.6",
"guzzlehttp/guzzle": "^6.2",
"intervention/image": "^2.3",
"jenssegers/date": "^3.2",
"laravel/cashier": "~7.0",
"roave/security-advisories": "dev-master",
"laravel/dusk": "^1.1",
"sentry/sentry-laravel": "^0.7.0",
"laravel/framework": "5.5.*",
"laravel/passport": "^4.0",
"laravel/socialite": "^3.0",
"league/flysystem-aws-s3-v3": "~1.0",
"laravel/passport": "^4.0"
"paragonie/constant_time_encoding": "^2.2",
"pragmarx/google2fa": "^2.0",
"pragmarx/google2fa-laravel": "^0.1.4",
"predis/predis": "^1.1",
"roave/security-advisories": "dev-master",
"sabre/vobject": "^4.1",
"sentry/sentry-laravel": "^0.7.0"
},
"require-dev": {
"mockery/mockery": "0.9.*",
Expand Down
Loading