Skip to content

Commit

Permalink
publication logic, clean up, and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykenedy committed Jan 20, 2018
1 parent 27cbb92 commit 66bd7c7
Show file tree
Hide file tree
Showing 15 changed files with 484 additions and 237 deletions.
98 changes: 93 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ Laravel 2-Step verification is a package to add 2-Step user authentication to an

Laravel 2-Step Authentication Verification for Laravel. Can be used in out the box with Laravel's authentication scaffolding or integrated into other projects.


### Features

| Laravel 2 Step Verification |
| Laravel 2 Step Verification Features |
| :------------ |
| XXX |
| Uses [Notification](https://laravel.com/docs/5.5/notifications) Class to send user code to users email |
| Can publish customizable views and assets |
| Lots of [configuration](#configuration) options |
| Uses Language [localization](https://laravel.com/docs/5.5/localization) files |
| Verificaton Page |
| Locked Page |

### Requirements
* [Laravel 5.3, 5.4, or 5.5+](https://laravel.com/docs/installation)
Expand All @@ -44,8 +48,92 @@ Laravel 2-Step Authentication Verification for Laravel. Can be used in out the b

2. Register the package

...
* Laravel 5.5 and up
Uses package auto discovery feature, no need to edit the `config/app.php` file.

* Laravel 5.4 and below
Register the package with laravel in `config/app.php` under `providers` with the following:

```php
'providers' => [
jeremykenedy\laravel2step\laravel2stepServiceProvider::class,
];
```

3. Publish the packages views, config file, assets, and language files by running the following from your projects root folder:

```bash
php artisan vendor:publish --tag=laravel2step
```

4. Optionally Update your `.env` file and associated settings (see [Environment File](#environment-file) section)

5. Run the migration to add the verifications codes table:

```php
php artisan migrate
```

* Note: If you want to specify a different table or connection make sure you update your `.env` file with the needed configuration variables.

6. Make sure your apps email is configured - this is usually done by configuring the Laravel out the box settings in the `.env` file.

### Configuration
Laravel 2-Step Verification can be configured in directly in `/config/laravel2step.php` or in the variables in your `.env` file.

##### Environment File
Here are the `.env` file variables available:

```bash
LARAVEL_2STEP_ENABLED=true
LARAVEL_2STEP_DATABASE_CONNECTION=mysql
LARAVEL_2STEP_DATABASE_TABLE=laravel2step
LARAVEL_2STEP_USER_MODEL=App\User
LARAVEL_2STEP_EMAIL_FROM=""
LARAVEL_2STEP_EMAIL_FROM_NAME="Laravel 2 Step Verification"
LARAVEL_2STEP_EMAIL_SUBJECT='Laravel 2 Step Verification'
LARAVEL_2STEP_EXCEEDED_COUNT=3
LARAVEL_2STEP_EXCEEDED_COUNTDOWN_MINUTES=1440
LARAVEL_2STEP_VERIFIED_LIFETIME_MINUTES=360
LARAVEL_2STEP_RESET_BUFFER_IN_SECONDS=300
LARAVEL_2STEP_CSS_ENABLED=true
```

### Usage
Laravel 2-Step Verification is enabled via middleware.
You can enable 2-Step Verification in your routes and controllers via the following middleware:

```php
twostep
```

Example to start recording page views using middlware in `web.php`:

```php
Route::group(['middleware' => ['auth', 'twostep']], function () {
Route::get('/', 'WelcomeController@welcome')->name('welcome');
});
```

### Routes
* ```/verification/needed```
* ```/verification/verify```
* ```/verification/resend```

### Screenshots
![Verification Page](...)
![Locked Page](...)
![Verification Email](...)

### File Tree

```
...
```

* Tree command can be installed using brew: `brew install tree`
* File tree generated using command `tree -a -I '.git|node_modules|vendor|storage|tests`

### Future
* Readme
Expand All @@ -67,5 +155,5 @@ Laravel 2-Step Authentication Verification for Laravel. Can be used in out the b
* Create Artisan command and job to prune said entries.

### License
Laravel-monitor is licensed under the MIT license. Enjoy!
Laravel 2-Step Verification is licensed under the MIT license. Enjoy!

27 changes: 15 additions & 12 deletions src/Laravel2stepServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function register()
}

/**
* Publish files for Laravel Monitor.
* Publish files for Laravel 2-Step Verification.
*
* @return void
*/
Expand All @@ -50,25 +50,28 @@ private function publishFiles()
$publishTag = 'laravel2step';

$this->publishes([
__DIR__.'/App/Mail/SendVerificationCode.php' => app_path('Mail/SendVerificationCode.php'),
__DIR__.'/config/laravel2step.php' => base_path('config/laravel2step.php'),
], $publishTag);

$this->publishes([
__DIR__.'/config/laravel2step.php' => base_path('config/laravel2step.php'),
__DIR__ . '/database/migrations/' => base_path('/database/migrations'),
], $publishTag);

$this->publishes([
__DIR__.'/public/css' => public_path('css/laravel2step'),
], $publishTag);

// $this->publishes([
// __DIR__.'/resources/views/emails/verification.blade.php' => resource_path('views/emails/verification.blade.php'),
// ], $publishTag);
$this->publishes([
__DIR__.'/resources/assets/scss' => resource_path('assets/scss/laravel2step'),
], $publishTag);

// $this->publishes([
// __DIR__.'/resources/views' => base_path('resources/views/vendor/laravel2step'),
// ], $publishTag);
$this->publishes([
__DIR__.'/resources/views' => resource_path('views/vendor/laravel2step'),
], $publishTag);

// $this->publishes([
// __DIR__.'/resources/lang' => base_path('resources/lang/vendor/laravel2step'),
// ], $publishTag);
$this->publishes([
__DIR__.'/resources/lang' => base_path('resources/lang/vendor/laravel2step'),
], $publishTag);

}
}
23 changes: 12 additions & 11 deletions src/app/Http/Controllers/TwoStepController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class TwoStepController extends Controller
{
use Laravel2StepTrait;

private $_user;
private $_twoStepAuth;
private $_authCount;
private $_authStatus;
private $_twoStepAuth;
private $_remainingAttempts;
private $_user;

/**
* Create a new controller instance.
Expand All @@ -40,6 +40,7 @@ public function __construct()
/**
* Set the User2Step Variables
*
* @return void
*/
private function setUser2StepData()
{
Expand Down Expand Up @@ -81,12 +82,12 @@ private function invalidCodeReturnData($errors = null)
/**
* Show the twostep verification form.
*
90
* @return \Illuminate\Http\Response
*/
public function showVerification()
{
$twoStepAuth = $this->_twoStepAuth;
$authStatus = $this->_authStatus;
$twoStepAuth = $this->_twoStepAuth;
$authStatus = $this->_authStatus;

if ($this->checkExceededTime($twoStepAuth->updated_at)) {
$this->resetExceededTime($twoStepAuth);
Expand Down Expand Up @@ -179,12 +180,12 @@ public function verify(Request $request)
}
}

/**
* Resend the validation code triggered by user
*
* @return \Illuminate\Http\Response
*
*/
/**
* Resend the validation code triggered by user
*
* @return \Illuminate\Http\Response
*
*/
public function resend()
{
$twoStepAuth = $this->_twoStepAuth;
Expand Down
4 changes: 2 additions & 2 deletions src/config/laravel2step.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

/*
|--------------------------------------------------------------------------
| Laravel Two Step Authentication Enabled
| Verification Authentication Enabled
|--------------------------------------------------------------------------
*/

'laravel2stepEnabled' => env('LARAVEL_2STEP_ENABLED', true),

/*
|--------------------------------------------------------------------------
| Laravel Logger Database Settings
| Verification Database Settings
|--------------------------------------------------------------------------
*/

Expand Down
142 changes: 142 additions & 0 deletions src/public/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
.invalid-shake {
-webkit-animation: kf_shake 0.4s 1 linear;
-moz-animation: kf_shake 0.4s 1 linear;
-o-animation: kf_shake 0.4s 1 linear;
}

@-webkit-keyframes kf_shake {
0% {
-webkit-transform: translate(40px);
}
20% {
-webkit-transform: translate(-40px);
}
40% {
-webkit-transform: translate(20px);
}
60% {
-webkit-transform: translate(-20px);
}
80% {
-webkit-transform: translate(8px);
}
100% {
-webkit-transform: translate(0px);
}
}
@-moz-keyframes kf_shake {
0% {
-moz-transform: translate(40px);
}
20% {
-moz-transform: translate(-40px);
}
40% {
-moz-transform: translate(20px);
}
60% {
-moz-transform: translate(-20px);
}
80% {
-moz-transform: translate(8px);
}
100% {
-moz-transform: translate(0px);
}
}
@-o-keyframes kf_shake {
0% {
-o-transform: translate(40px);
}
20% {
-o-transform: translate(-40px);
}
40% {
-o-transform: translate(20px);
}
60% {
-o-transform: translate(-20px);
}
80% {
-o-transform: translate(8px);
}
100% {
-o-origin-transform: translate(0px);
}
}
.modal .modal-header {
-webkit-border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-ms-border-radius: 5px 5px 0 0;
-o-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
}
.modal.modal-success .modal-header {
color: #ffffff;
background-color: #2ab27b;
}
.modal.modal-warning .modal-header {
color: #ffffff;
background-color: #cbb956;
}
.modal.modal-danger .modal-header {
color: #ffffff;
background-color: #bf5329;
}
.modal.modal-info .modal-header {
color: #ffffff;
background-color: #8eb4cb;
}
.modal.modal-primary .modal-header {
color: #ffffff;
background-color: #3097D1;
}

.two-step-verification .verification-exceeded-panel {
margin-top: 2.5em;
}
.two-step-verification .verification-exceeded-panel h4,
.two-step-verification .verification-exceeded-panel p {
margin: 0 0 2.5em 0;
}
.two-step-verification .verification-exceeded-panel .locked-icon {
font-size: 3.5em;
margin: 30px 0 0;
}
.two-step-verification #failed_login_alert {
display: none;
}
.two-step-verification #failed_login_alert .glyphicon {
font-size: 6em;
text-align: center;
display: block;
margin: .25em 0 .75em;
}
.two-step-verification .panel {
overflow: hidden;
}
.two-step-verification .verification-form-panel {
margin-top: 2.5em;
}
.two-step-verification .verification-form-panel .code-inputs {
margin-bottom: 3em;
}
.two-step-verification .verification-form-panel .submit-container {
margin-bottom: 2em;
}
.two-step-verification .verification-form-panel input {
font-size: 2em;
height: 90px;
}
@media (min-width: 500px) {
.two-step-verification .verification-form-panel input {
font-size: 3em;
height: 140px;
}
}
@media (min-width: 650px) {
.two-step-verification .verification-form-panel input {
font-size: 4em;
height: 180px;
}
}
1 change: 1 addition & 0 deletions src/public/css/app.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 66bd7c7

Please sign in to comment.