Skip to content

Commit

Permalink
NIST Password Rules (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Sep 12, 2019
1 parent 961e90a commit c35c5d5
Show file tree
Hide file tree
Showing 8 changed files with 973 additions and 154 deletions.
21 changes: 8 additions & 13 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;

class LoginController extends Controller
{
Expand Down Expand Up @@ -80,23 +81,17 @@ public function username()
// }

/**
* Validate the user login.
* Validate the user login request.
*
* @param Request $request
* @param \Illuminate\Http\Request $request
* @return void
*/
protected function validateLogin(Request $request)
{
$this->validate(
$request,
[
'identity' => 'required|string',
'password' => 'required|string',
],
[
'identity.required' => 'Username or email is required',
'password.required' => 'Password is required',
]
);
$request->validate([
'identity' => 'required|string',
'password' => PasswordRules::login(),
]);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;

class RegisterController extends Controller
{
Expand Down Expand Up @@ -62,7 +63,7 @@ protected function validator(array $data)
return Validator::make($data, [
'name' => ['required', 'string', 'max:50'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'password' => PasswordRules::register('email'),
]);
}

Expand Down
1 change: 1 addition & 0 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class Authenticate extends Middleware
{
/**
* @codeCoverageIgnore
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Rules\Auth\CurrentPassword;
use App\User;
use Illuminate\Foundation\Http\FormRequest;
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;

class UpdateUserPassword extends FormRequest
{
Expand All @@ -27,7 +28,7 @@ public function rules()
{
return [
'current-password' => [new CurrentPassword],
'new-password' => ['required', 'different:current-password', 'string', 'min:6', 'confirmed'],
'new-password' => PasswordRules::changePassword('current-password'),
];
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"geoip2/geoip2": "~2.0",
"hidehalo/nanoid-php": "^1.1",
"jenssegers/agent": "^2.6",
"langleyfoxall/laravel-nist-password-rules": "^4.1",
"laravel/framework": "^6.0",
"laravel/tinker": "^1.0",
"laravolt/avatar": "^3.0",
Expand Down
Loading

0 comments on commit c35c5d5

Please sign in to comment.