### Install filament-oidc with Composer Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Installs the filament-oidc plugin via Composer. Requires Filament v5. ```bash composer require jeffersongoncalves/filament-oidc ``` -------------------------------- ### Customise user provisioning with userAttributesUsing and resolveUserUsing Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Override the attribute mapping with `userAttributesUsing` and the full resolution closure with `resolveUserUsing`. The example maps attributes from the Socialite user and uses `updateOrCreate` to provision the local user. ```php FilamentOidcPlugin::make() ->userAttributesUsing(fn (\Laravel\Socialite\Two\User $oidcUser) => [ 'name' => $oidcUser->getName(), 'email' => $oidcUser->getEmail(), 'tenant_id' => $oidcUser->user['tenant'] ?? null, 'password' => bcrypt(\Illuminate\Support\Str::random(40)), ]) ->resolveUserUsing(function (\App\Models\User $template, \Laravel\Socialite\Two\User $oidcUser) { return \App\Models\User::query()->updateOrCreate( ['email' => $oidcUser->getEmail()], ['name' => $oidcUser->getName()], ); }); ``` -------------------------------- ### Register FilamentOidcPlugin per panel and list callback URLs Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Register the plugin once per panel. Each panel gets its own routes (`filament.{panel-id}.oidc.{redirect|callback|logout}`), its own callback URL, and may opt into a different guard or user model. The second block shows the per-panel callback URLs to register with your IdP. ```php // AdminPanelProvider $panel->plugin( FilamentOidcPlugin::make() ->guard('web') ->userModel(\App\Models\User::class) ); // CustomerPanelProvider $panel->plugin( FilamentOidcPlugin::make() ->guard('customer') ->userModel(\App\Models\Customer::class) ->autoCreateUsers(false) ); ``` ```text https://your-app.test/admin/oidc/callback https://your-app.test/customer/oidc/callback ``` -------------------------------- ### Publish configuration and translations Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Optionally publishes the configuration and translation files. ```bash php artisan vendor:publish --tag="filament-oidc-config" php artisan vendor:publish --tag="filament-oidc-translations" ``` -------------------------------- ### Publish and run migrations Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Publishes and runs the migration that creates the oidc_identities table. ```bash php artisan vendor:publish --tag="filament-oidc-migrations" php artisan migrate ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Run the test suite. ```bash composer test ``` -------------------------------- ### Enable IdP logout with FilamentOidcPlugin Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Enable IdP logout to redirect users to the issuer's end_session_endpoint after the local logout completes. ```php FilamentOidcPlugin::make()->logoutFromIdp(true); ``` -------------------------------- ### Register FilamentOidcPlugin in a panel Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Registers the FilamentOidcPlugin in a Filament panel, enabling OIDC login with the web guard and automatic user creation. ```php use JeffersonGoncalves\Filament\Oidc\FilamentOidcPlugin; public function panel(Panel $panel): Panel { return $panel ->id('admin') ->path('admin') ->login() ->plugin( FilamentOidcPlugin::make() ->guard('web') ->autoCreateUsers(true) ); } ``` -------------------------------- ### Configure OIDC environment variables Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Sets the required environment variables for the underlying laravel-oidc driver. The redirect URI is computed from the panel route, so OIDC_REDIRECT_URI is not needed. ```env OIDC_ISSUER_URL=https://idp.example.com OIDC_CLIENT_ID=your-client-id OIDC_CLIENT_SECRET=your-client-secret ``` -------------------------------- ### Add HasOidcIdentities trait to User model Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Add the `HasOidcIdentities` trait to expose the `oidcIdentities()` relation on your authenticatable model. The plugin stores every IdP/subject pair in the `oidc_identities` table and links it through a polymorphic relationship. ```php use JeffersonGoncalves\Filament\Oidc\Concerns\HasOidcIdentities; class User extends Authenticatable { use HasOidcIdentities; } ``` -------------------------------- ### Blade form for OIDC logout route Source: https://github.com/jeffersongoncalves/filament-oidc/blob/1.x/README.md Use the named route from your blade templates (e.g. inside a custom user menu). ```blade
``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.