このパッケージはLaravelにおいて,よりセキュアな認証を追加するパッケージです。
composer require ikepu-tp/laravel-secure-auth
php artisan migrate
php artisan vendor:publish --tags=SecureAuth-config
必要に応じて設定内容を変更してください。
キー項目 | 説明 |
---|---|
expires_minitues | トークンの期限(分) |
token_digits | トークンの桁数 |
loginCallback | ログイン処理の関数 |
login_history | ログイン履歴を記録するか否か |
login_email | ログイン時のメール送信 |
Important
設定ファイルのloginCallback
でログイン処理関数の設定を行なってください。
/**
* Handle an incoming authentication request.
*/
public function store(LoginRequest $request): RedirectResponse
{
$user = User::query()
->where("email", $request->validated("email"))
->first();
if (!$user || !Hash::check($request->validated("password"), $user->password)) throw new UnauthorizedException();
return \ikepu_tp\SecureAuth\app\Http\Services\TfaService::make($user, $request->validated("remember", false));
}
Important
ログイン処理中にログインイベントを発行してください。
public function login(User $user)
{
session()->regenerate();
event(new \ikepu_tp\SecureAuth\app\Events\LoginEvent($user));
\Illuminate\Support\Facades\Auth::guard($guard)->login($user, $remember);
}
貢献をお待ちしています!
Issue: バグの報告や新機能の提案等 Pull Requests: バグの修正や新機能等の提案
See LICENSE.