From 1e78048d7927c57d2a41cca622d22b1aeaa74225 Mon Sep 17 00:00:00 2001 From: Michael Darko Date: Mon, 22 Nov 2021 19:05:20 +0000 Subject: [PATCH] :alien: updated auth config --- config/auth copy.php | 161 ------------------------------------------- config/auth.php | 27 ++++++++ 2 files changed, 27 insertions(+), 161 deletions(-) delete mode 100644 config/auth copy.php diff --git a/config/auth copy.php b/config/auth copy.php deleted file mode 100644 index 3c2ee5d..0000000 --- a/config/auth copy.php +++ /dev/null @@ -1,161 +0,0 @@ - true, - - /* - |-------------------------------------------------------------------------- - | Encode password - |-------------------------------------------------------------------------- - | - | Password encode is run when leaf wants to encode passwords on register - | This exact method is used by default in Leaf, so you can set it to null - | if you want to. - | - | You can set your own implementation instead of Password::hash - | - */ - "PASSWORD_ENCODE" => function ($password) { - return Password::hash($password); - }, - - /* - |-------------------------------------------------------------------------- - | Verify Password - |-------------------------------------------------------------------------- - | - | This function is run to verify the password. This implementation is done - | by default, so you can set it to null, and it will still work fine. - | - | You can add your own implementation instead of Password::verify - | - */ - "PASSWORD_VERIFY" => function ($password, $hashedPassword) { - return Password::verify($password, $hashedPassword); - }, - - /* - |-------------------------------------------------------------------------- - | Password Key - |-------------------------------------------------------------------------- - | - | The default password key. Leaf will expect this key to hold passwords - | in your database. - | - */ - "PASSWORD_KEY" => "password", - - /* - |-------------------------------------------------------------------------- - | Hide id - |-------------------------------------------------------------------------- - | - | Hide id field from user object returned in login, register and update - | - */ - "HIDE_ID" => true, - - /* - |-------------------------------------------------------------------------- - | Hide password - |-------------------------------------------------------------------------- - | - | Hide password from user object returned in login, register and update - | - */ - "HIDE_PASSWORD" => true, - - /* - |-------------------------------------------------------------------------- - | Login params error - |-------------------------------------------------------------------------- - | - | Error to show when the login params aren't found in db - | - */ - "LOGIN_PARAMS_ERROR" => "Username not registered!", - - /* - |-------------------------------------------------------------------------- - | Password error - |-------------------------------------------------------------------------- - | - | Error to show when the login password is wrong - | - */ - "LOGIN_PASSWORD_ERROR" => "Password is incorrect!", - - /* - |-------------------------------------------------------------------------- - | Use session [EXPERIMENTAL] - |-------------------------------------------------------------------------- - | - | Use session based authentication instead of the default JWT based auth. - | - | If you encounter any problems using any new auth session features, - | revert to the default auth and manage sessions manually. - | Don't forget to open an issue. - | - */ - "USE_SESSION" => false, - - /* - |-------------------------------------------------------------------------- - | Session on register - |-------------------------------------------------------------------------- - | - | If true, a session will be created on a successful registration, else - | you it'll be created on login rather. - | - */ - "SESSION_ON_REGISTER" => false, - - /* - |-------------------------------------------------------------------------- - | Login page route - |-------------------------------------------------------------------------- - */ - "GUARD_LOGIN" => "/auth/login", - - /* - |-------------------------------------------------------------------------- - | Register page route - |-------------------------------------------------------------------------- - */ - "GUARD_REGISTER" => "/auth/register", - - /* - |-------------------------------------------------------------------------- - | Logout route - |-------------------------------------------------------------------------- - */ - "GUARD_LOGOUT" => "/auth/logout", - - /* - |-------------------------------------------------------------------------- - | Home page route - |-------------------------------------------------------------------------- - */ - "GUARD_HOME" => "/home", - - /* - |-------------------------------------------------------------------------- - | JWT + Session - |-------------------------------------------------------------------------- - | - | Add an auth token to the auth session? - | - */ - "SAVE_SESSION_JWT" => false, -]; diff --git a/config/auth.php b/config/auth.php index 3c2ee5d..315e6ee 100644 --- a/config/auth.php +++ b/config/auth.php @@ -135,6 +135,13 @@ */ "GUARD_REGISTER" => "/auth/register", + /* + |-------------------------------------------------------------------------- + | Logout route + |-------------------------------------------------------------------------- + */ + "GUARD_HOME" => "/home", + /* |-------------------------------------------------------------------------- | Logout route @@ -158,4 +165,24 @@ | */ "SAVE_SESSION_JWT" => false, + + /* + |-------------------------------------------------------------------------- + | JWT Token Secret + |-------------------------------------------------------------------------- + | + | Secret string to encode JWT + | + */ + "TOKEN_SECRET" => "@_leaf$0Secret!", + + /* + |-------------------------------------------------------------------------- + | JWT Lifetime + |-------------------------------------------------------------------------- + | + | How long should JWT be valid for? + | + */ + "TOKEN_LIFETIME" => 60 * 60 * 24 * 365 ];