Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIST Password Rules #432

Merged
merged 19 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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