ronasit / laravel-clerk
Package provides auth guard to auth user via the Clerk
0.0.2-beta
2024-12-05 07:55 UTC
Requires
- php: ^8.3
- laravel/framework: ^11
- lcobucci/jwt: ^5.3
This package is auto-updated.
Last update: 2024-12-12 00:16:01 UTC
README
Introduction
This package offers an authentication guard to seamlessly integrate Clerk authentication into your Laravel project.
Installation
- Use Composer to install the package:
composer require ronasit/laravel-clerk
- Publish the package configuration:
php artisan vendor:publish --provider=RonasIT\\Clerk\\Providers\\ClerkServiceProvider
- Add a new
clerk
guard within theguards
array in yourconfig/auth.php
file:
return [ 'defaults' => [ 'guard' => 'clerk', 'passwords' => 'users', ], 'guards' => [ 'clerk' => [ 'driver' => 'clerk_session', 'provider' => 'users', ], // Other guards... ],
- Populate the necessary configuration options in
config/clerk.php
.
Usage
By default, your app returns the User class with just the external_id property, which holds the user's ID in Clerk.
To customize this behavior, you'll need to create your own UserRepository that implements the UserRepositoryContract. Then, rebind it in one of the service providers:
use RonasIT\Clerk\Contracts\ClerkUserRepositoryContract; use App\Support\Clerk\MyAwesomeUserRepository; class AppServiceProvider extends ServiceProvider { public function register(): void { $this->app->bind(ClerkUserRepositoryContract::class, MyAwesomeUserRepository::class); } }