diff --git a/app/config/app.php b/app/config/app.php index 539138aa..231531cb 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -135,6 +135,7 @@ return [ 'Thujohn\Rss\RssServiceProvider', 'Jenssegers\Date\DateServiceProvider', 'McCool\LaravelAutoPresenter\LaravelAutoPresenterServiceProvider', + 'PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider', /* * Application Service Providers... @@ -172,17 +173,17 @@ return [ 'aliases' => [ - 'App' => 'Illuminate\Support\Facades\App', - 'Auth' => 'Illuminate\Support\Facades\Auth', - 'Form' => 'Illuminate\Support\Facades\Form', - 'Input' => 'Illuminate\Support\Facades\Input', - 'Redirect' => 'Illuminate\Support\Facades\Redirect', - 'Request' => 'Illuminate\Support\Facades\Request', - 'Response' => 'Illuminate\Support\Facades\Response', - 'Route' => 'Illuminate\Support\Facades\Route', - 'Session' => 'Illuminate\Support\Facades\Session', - 'Setting' => 'CachetHQ\Cachet\Models\Setting', - 'Str' => 'Illuminate\Support\Str', + 'App' => 'Illuminate\Support\Facades\App', + 'Auth' => 'Illuminate\Support\Facades\Auth', + 'Form' => 'Illuminate\Support\Facades\Form', + 'Input' => 'Illuminate\Support\Facades\Input', + 'Redirect' => 'Illuminate\Support\Facades\Redirect', + 'Request' => 'Illuminate\Support\Facades\Request', + 'Response' => 'Illuminate\Support\Facades\Response', + 'Route' => 'Illuminate\Support\Facades\Route', + 'Session' => 'Illuminate\Support\Facades\Session', + 'Setting' => 'CachetHQ\Cachet\Models\Setting', + 'Str' => 'Illuminate\Support\Str', ], diff --git a/app/database/migrations/2015_01_09_083419_AlterTableUsersAdd2FA.php b/app/database/migrations/2015_01_09_083419_AlterTableUsersAdd2FA.php new file mode 100644 index 00000000..3e933caf --- /dev/null +++ b/app/database/migrations/2015_01_09_083419_AlterTableUsersAdd2FA.php @@ -0,0 +1,32 @@ +string('google_2fa_secret')->after('remember_token'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('google_2fa_secret'); + }); + } +} diff --git a/app/lang/en/dashboard.php b/app/lang/en/dashboard.php index c1c31aba..45963149 100644 --- a/app/lang/en/dashboard.php +++ b/app/lang/en/dashboard.php @@ -108,9 +108,10 @@ return [ // Login 'login' => [ - 'login' => 'Login', - 'logged_in' => "You're logged in.", - 'welcome' => 'Welcome Back!', + 'login' => 'Login', + 'logged_in' => 'You\'re logged in.', + 'welcome' => 'Welcome Back!', + 'two-factor' => 'Please enter your token.', ], // Sidebar footer diff --git a/app/lang/en/forms.php b/app/lang/en/forms.php index 705d2247..a7612b7a 100644 --- a/app/lang/en/forms.php +++ b/app/lang/en/forms.php @@ -4,19 +4,21 @@ return [ // Setup form fields 'setup' => [ - 'email' => 'Email', - 'username' => 'Username', - 'password' => 'Password', - 'site_name' => 'Site Name', - 'site_domain' => 'Site Domain', - 'site_timezone' => 'Select your timezone', - 'site_locale' => 'Select your language', + 'email' => 'Email', + 'username' => 'Username', + 'password' => 'Password', + 'site_name' => 'Site Name', + 'site_domain' => 'Site Domain', + 'site_timezone' => 'Select your timezone', + 'site_locale' => 'Select your language', + 'enable_google2fa' => 'Enable Google Two Factor Authentication', ], // Login form fields 'login' => [ 'email' => 'Email', 'password' => 'Password', + '2fauth' => 'Authentication Code', ], // Incidents form fields @@ -79,6 +81,9 @@ return [ 'password' => 'Password', 'api-key' => 'API Key', 'api-key-help' => 'Regenerating your API key will revoke all existing applications.', + '2fa' => [ + 'help' => 'Enabling two factor authentication increases security of your account. You will need to download Google Authenticator or a similar app on to your mobile device. When you login you will be asked to provide a token generated by the app.', + ], ], // Buttons diff --git a/app/lang/fr/dashboard.php b/app/lang/fr/dashboard.php index 74064660..a521b110 100644 --- a/app/lang/fr/dashboard.php +++ b/app/lang/fr/dashboard.php @@ -108,9 +108,10 @@ return [ // Login 'login' => [ - 'login' => 'Connexion', - 'logged_in' => "Vous êtes connecté.", - 'welcome' => 'Re-bonjour !', + 'login' => 'Connexion', + 'logged_in' => "Vous êtes connecté.", + 'welcome' => 'Re-bonjour !', + 'two-factor' => 'Please enter your token.', ], // Sidebar footer diff --git a/app/lang/fr/forms.php b/app/lang/fr/forms.php index 8c8fbdf9..3ed6b82f 100644 --- a/app/lang/fr/forms.php +++ b/app/lang/fr/forms.php @@ -4,19 +4,21 @@ return [ // Setup form fields 'setup' => [ - 'email' => 'Adresse email', - 'username' => 'Identifiant', - 'password' => 'Mot de passe', - 'site_name' => 'Nom du site', - 'site_domain' => 'Domaine du site', - 'site_timezone' => 'Sélectionnez votre fuseau horaire', - 'site_locale' => 'Sélectionnez votre langue', + 'email' => 'Adresse email', + 'username' => 'Identifiant', + 'password' => 'Mot de passe', + 'site_name' => 'Nom du site', + 'site_domain' => 'Domaine du site', + 'site_timezone' => 'Sélectionnez votre fuseau horaire', + 'site_locale' => 'Sélectionnez votre langue', + 'enable_google2fa' => 'Enable Google Two Factor Authentication', ], // Login form fields 'login' => [ 'email' => 'Adresse email', 'password' => 'Mot de passe', + '2fauth' => 'Authentication Code', ], // Incidents form fields @@ -79,6 +81,9 @@ return [ 'password' => 'Mot de passe', 'api-key' => 'Clé API', 'api-key-help' => 'Regénérer votre clé API révoquera toutes les applications existantes.', + '2fa' => [ + 'help' => 'Enabling two factor authentication increases security of your account. You will need to download Google Authenticator or a similar app on to your mobile device. When you login you will be asked to provide a token generated by the app.', + ], ], // Buttons diff --git a/app/lang/pt-BR/dashboard.php b/app/lang/pt-BR/dashboard.php index 82d22f97..6f474d50 100755 --- a/app/lang/pt-BR/dashboard.php +++ b/app/lang/pt-BR/dashboard.php @@ -1,6 +1,7 @@ 'Dashboard', // Incidents @@ -97,7 +98,7 @@ return [ 'stylesheet' => 'Folha de estilo', ], 'theme' => [ - 'theme' => ' Tema', + 'theme' => 'Tema', ], 'edit' => [ 'success' => 'Configurações salvas.', @@ -107,9 +108,10 @@ return [ // Login 'login' => [ - 'login' => 'Login', - 'logged_in' => "Você está logado.", - 'welcome' => 'Bem-vindo de volta!', + 'login' => 'Login', + 'logged_in' => "Você está logado.", + 'welcome' => 'Bem-vindo de volta!', + 'two-factor' => 'Please enter your token.', ], // Sidebar footer diff --git a/app/lang/pt-BR/forms.php b/app/lang/pt-BR/forms.php index 7b125e08..29db5137 100755 --- a/app/lang/pt-BR/forms.php +++ b/app/lang/pt-BR/forms.php @@ -3,19 +3,21 @@ return [ // Setup form fields 'setup' => [ - 'email' => 'Email', - 'username' => 'Usuário', - 'password' => 'Senha', - 'site_name' => 'Nome do site', - 'site_domain' => 'Domínio do site', - 'site_timezone' => 'Select your timezone', - 'site_locale' => 'Select your language', + 'email' => 'Email', + 'username' => 'Usuário', + 'password' => 'Senha', + 'site_name' => 'Nome do site', + 'site_domain' => 'Domínio do site', + 'site_timezone' => 'Select your timezone', + 'site_locale' => 'Select your language', + 'enable_google2fa' => 'Enable Google Two Factor Authentication', ], // Login form fields 'login' => [ 'email' => 'Email', 'password' => 'Senha', + '2fauth' => 'Authentication Code', ], // Incidents form fields @@ -78,6 +80,9 @@ return [ 'password' => 'Senha', 'api-key' => 'Chave da API', 'api-key-help' => 'Regenerar sua chave de API irá revogar todos os aplicativos existentes.', + '2fa' => [ + 'help' => 'Enabling two factor authentication increases security of your account. You will need to download Google Authenticator or a similar app on to your mobile device. When you login you will be asked to provide a token generated by the app.', + ], ], // Buttons diff --git a/app/routes/auth.php b/app/routes/auth.php index 1eeef9f1..2263566c 100644 --- a/app/routes/auth.php +++ b/app/routes/auth.php @@ -1,22 +1,33 @@ 'has_setting:app_name', 'namespace' => 'CachetHQ\Cachet\Http\Controllers'], function () { - // Login routes - Route::get('/auth/login', [ - 'before' => 'guest', - 'as' => 'login', - 'uses' => 'AuthController@showLogin', - ]); - Route::post('/auth/login', [ - 'before' => 'guest|csrf|login_throttling', - 'as' => 'logout', - 'uses' => 'AuthController@postLogin', - ]); -}); +Route::group(['prefix' => 'auth', 'namespace' => 'CachetHQ\Cachet\Http\Controllers'], function () { + Route::group(['before' => 'has_setting:app_name'], function () { + // Login routes + Route::get('login', [ + 'before' => 'guest', + 'as' => 'login', + 'uses' => 'AuthController@showLogin', + ]); -Route::group(['before' => 'auth', 'namespace' => 'CachetHQ\Cachet\Http\Controllers'], function () { - Route::get('/auth/logout', [ - 'as' => 'logout', - 'uses' => 'AuthController@logoutAction', - ]); + Route::post('login', [ + 'before' => 'guest|csrf|login_throttling', + 'as' => 'logout', + 'uses' => 'AuthController@postLogin', + ]); + + // Two factor authorization + Route::get('2fa', [ + 'as' => 'two-factor', + 'uses' => 'AuthController@showTwoFactorAuth', + ]); + + Route::post('2fa', 'AuthController@postTwoFactor'); + }); + + Route::group(['before' => 'auth'], function () { + Route::get('logout', [ + 'as' => 'logout', + 'uses' => 'AuthController@logoutAction', + ]); + }); }); diff --git a/app/views/auth/two-factor-auth.blade.php b/app/views/auth/two-factor-auth.blade.php new file mode 100644 index 00000000..95474428 --- /dev/null +++ b/app/views/auth/two-factor-auth.blade.php @@ -0,0 +1,31 @@ +@extends('layout.clean') + +@section('content') +