Download the PHP package ikechukwukalu/sanctumauthstarter without Composer
On this page you can find all versions of the php package ikechukwukalu/sanctumauthstarter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ikechukwukalu/sanctumauthstarter
More information about ikechukwukalu/sanctumauthstarter
Files in ikechukwukalu/sanctumauthstarter
Package sanctumauthstarter
Short Description Laravel sanctum auth starter
License MIT
Informations about the package sanctumauthstarter
SANCTUM AUTH STARTER
This is a very flexible and customisable laravel package (boilerplate) that utilises laravel/ui and laravel-sanctum to create Basic Authetication classes and other helpful functionalities to give you a quick start when building REST APIs using Laravel. The following functionalities are made available:
- User registration
- User login
- Auto login after registration
- Login throttling
- Login 2FA
- Social media login
- Forgot password
- Email verification
- Resend email verification
- Reset password
- Change password
- Edit user profile
- Notifications
- Welcome notification
- Email verification
- Login notification
- Password change notification
- Generate documentation
- Helper CI/CD files for GitHub
REQUIREMENTS
- PHP 8+
- Laravel 9+
STEPS TO INSTALL
php artisan ui bootstrapnpm install --save-dev laravel-echo pusher-js- Uncomment
use Illuminate\Contracts\Auth\MustVerifyEmail;inUsermodel class - Add
two_factorcolumns to thefillableandhiddenarrays within theUsermodel class. At the end theUsershould look similar to this:
GENERATE AUTH CONTROLLERS, REQUESTS, SERVICES AND ROUTES
You can run php artisan sas:setup to generate them at once. You can also call generate them separately:
php artisan sas:controllersphp artisan sas:routesphp artisan sas:tests
PUBLISH MIGRATIONS AND CONFIG
php artisan vendor:publish --tag=sas-migrationsphp artisan vendor:publish --tag=sas-config
WEBSOCKETS AND QUEUES
This package utilizes laravel beyondcode/laravel-websockets to pass access_token to the client after authentication. First, you must setup your laravel app for broadcasts. In order to do that run the following:
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="migrations"php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="config"- Set
REDIS_CLIENT=predisandBROADCAST_DRIVER=pusherwithin your.envfile. - Your
laravel-echoconfig should look similar to this:
You will need a queue worker for the notifications and other events.
- Set
QUEUE_CONNECTION=rediswithin your.envfile. - Uncomment
App\Providers\BroadcastServiceProvider::classinconfig\app.php -
Your
.envshould look similar to this -
For SSL using apache. The snippet below should be placed within the
virtualhostSSL config. - Run
php artisan config:clear,php artisan migrate,php artisan websockets:serveandphp artisan queue:work php artisan servenpm install && npm run dev
WEBVIEW LOGINS
- Social media login
- Two-factor login
Social Media Login
Add the following to your config/services.php file.
-
Navigate to
auth/socialiteto view a sample Google sign-up/sign-in page to view the generatedaccess_tokenafter sign up. Uncomment the route within theweb.php. Below is the script that is called within the viewresources/views/vendor/sanctumauthstarter/socialite/auth.blade.php. - After a successful authentication, this view is displayed
resources/views/vendor/sanctumauthstarter/socialite/callback.blade.phpand it contains the following script:
Two-factor Login
This package utilizes Laragear/TwoFactor to power 2fa login and beyondcode/laravel-websockets to pass access_token to the client after authentication.
2fa authentication has been implemented for both password login and social media login.
php artisan vendor:publish --provider="Laragear\TwoFactor\TwoFactorServiceProvider"php artisan migrate-
Replace the form in
resources/views/vendor/two-factor/login.blade.phpwith the code below: -
Call
api/create-two-factorto create 2fa. -
Call
api/confirm-two-factorto confirm 2fa and get recovery codes. - Call
api/disable-two-factorto disable 2fa,api/current-recovery-codesto retrieve current recovery codes andapi/new-recovery-codesto generate new recovery codes which replaces the previous batch.
Two factor enabled for password login
When 2fa has been enabled and a user attempts to login, a payload would be returned that contains a user_uuid and a twofactor_url.
The user_uuid is used to create a laravel-echo channel that would listen to a laravel broadcast. Navigate to auth/twofactor/{email}/{uuid} to view the generated access_token after uncommenting the route within the web.php. This view resources/views/vendor/sanctumauthstarter/twofactor/auth.blade.php contains a sample javascript that works it out.
Two factor enabled for social media login
When 2fa has been enabled a 2fa page will pop up over your browser.
DOCUMENTATION
To generate documentation:
composer require --dev knuckleswtf/scribephp artisan vendor:publish --tag=scribe-config- Change
'prefixes' => ['api/*']to'prefixes' => ['*']if you want to see the docs for APIs for theweb.phpas well. php artisan scribe:generate
Visit your newly generated docs:
- If you're using
statictype, find thedocs/index.htmlfile in yourpublic/folder and open it in your browser. - If you're using
laraveltype, start your app (php artisan serve), then visit/docs.
example_languages:
For each endpoint, an example request is shown in each of the languages specified in this array. Currently, only bash (curl), javascript(Fetch), php (Guzzle) and python (requests) are included. You can add extra languages, but you must also create the corresponding Blade view (see Adding more example languages).
Default: ["bash", "javascript"]
Please visit scribe for more details.
TESTS
It's recommended that you run the tests before you start adding your custom models and controllers.
Make sure to keep your database/factories/UserFactory.php Class updated with your users table so that the Tests can continue to run successfully.
Passwords
The passwords created within the database/factories/UserFactory.php Class must match the validation below:
Running Tests
php artisan test
RECOMMENED PACKAGES
PUBLISH VIEWS
php artisan vendor:publish --tag=sas-views
PUBLISH LANG
php artisan vendor:publish --tag=sas-lang
PUBLISH LARAVEL EMAIL NOTIFICATIONS BLADE
php artisan vendor:publish --tag=laravel-notifications
PUBLISH GITHUB WORKFLOWS
php artisan vendor:publish --tag=github
LICENSE
The SAS package is an open-sourced software licensed under the MIT license.
All versions of sanctumauthstarter with dependencies
doctrine/dbal Version ^3.5
hisorange/browser-detect Version ^4.5
illuminate/auth Version ^9.0|^10.0
illuminate/bus Version ^9.0|^10.0
illuminate/broadcasting Version ^9.0|^10.0
illuminate/contracts Version ^9.0|^10.0
illuminate/database Version ^9.0|^10.0
illuminate/events Version ^9.0|^10.0
illuminate/http Version ^9.0|^10.0
illuminate/notifications Version ^9.0|^10.0
illuminate/queue Version ^9.0|^10.0
illuminate/routing Version ^9.0|^10.0
illuminate/support Version ^9.0|^10.0
illuminate/validation Version ^9.0|^10.0
illuminate/view Version ^9.0|^10.0
laravel/sanctum Version ^3.0
laravel/socialite Version ^5.5
laragear/two-factor Version ^1.2
laravel/ui Version ^4.0
nesbot/carbon Version ^2.67
php Version ^8.0
predis/predis Version ^2.1
pusher/pusher-php-server Version ^7.2
stevebauman/location Version ^6.6
symfony/console Version ^6.0
symfony/finder Version ^6.0