PHPackages                             dutchcodingcompany/filament-socialite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dutchcodingcompany/filament-socialite

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dutchcodingcompany/filament-socialite
=====================================

Social login for Filament through Laravel Socialite

3.2.0(2mo ago)213914.9k—0.9%55[1 issues](https://github.com/DutchCodingCompany/filament-socialite/issues)[1 PRs](https://github.com/DutchCodingCompany/filament-socialite/pulls)9MITPHPPHP ^8.2CI passing

Since Apr 8Pushed 1mo ago10 watchersCompare

[ Source](https://github.com/DutchCodingCompany/filament-socialite)[ Packagist](https://packagist.org/packages/dutchcodingcompany/filament-socialite)[ Docs](https://github.com/dutchcodingcompany/filament-socialite)[ RSS](/packages/dutchcodingcompany-filament-socialite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (43)Used By (9)

  ![](https://camo.githubusercontent.com/8160012743615ccc44dbd70e8d23465cdb3f0f11bd36df22ed3aa860ea751a1a/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f46696c616d656e74253230536f6369616c6974652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d4475746368436f64696e67436f6d70616e7925324666696c616d656e742d736f6369616c697465267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4164642b4f417574682b6c6f67696e2b7468726f7567682b4c61726176656c2b536f6369616c6974652b746f2b46696c616d656e742e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d757365722d67726f7570)Social login for Filament through Laravel Socialite
===================================================

[](#social-login-for-filament-through-laravel-socialite)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4b67633c3ce9b35f5edff9956ea6d01066723006f87a3ecf90a5a5da08f82bce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6475746368636f64696e67636f6d70616e792f66696c616d656e742d736f6369616c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dutchcodingcompany/filament-socialite)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c36dc71e24bb91c37297949fa11b35a40642c7ce263685696af45be78d4b286c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6475746368636f64696e67636f6d70616e792f66696c616d656e742d736f6369616c6974652f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/dutchcodingcompany/filament-socialite/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4cbf7ddd176cf66a7ab1e07c4e128a1e6ef55fd19f03e1f090e107db679d6760/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6475746368636f64696e67636f6d70616e792f66696c616d656e742d736f6369616c6974652f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/dutchcodingcompany/filament-socialite/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/eee43ab5af365508fa07cfec0cf33a2162e59d8b6f8c2d536f2c67b6e46c4874/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6475746368636f64696e67636f6d70616e792f66696c616d656e742d736f6369616c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dutchcodingcompany/filament-socialite)

Add OAuth2 login through Laravel Socialite to Filament. OAuth1 (eg. Twitter) is not supported at this time.

Installation
------------

[](#installation)

Filament versionPackage versionReadme[^5.0.0](https://github.com/filamentphp/filament/tree/5.x)^3.1[Link](https://github.com/DutchCodingCompany/filament-socialite/blob/main/README.md)[^4.0.0](https://github.com/filamentphp/filament/tree/4.x)3.x.x[Link](https://github.com/DutchCodingCompany/filament-socialite/blob/main/README.md)[^3.2.44](https://github.com/filamentphp/filament/releases/tag/v3.2.44) (if using [SPA mode](https://filamentphp.com/docs/3.x/panels/configuration#spa-mode))2.x.x[Link](https://github.com/DutchCodingCompany/filament-socialite/blob/2.x/README.md)[^3.2.44](https://github.com/filamentphp/filament/releases/tag/v3.2.44) (if using [SPA mode](https://filamentphp.com/docs/3.x/panels/configuration#spa-mode))^1.3.13.x1.x.x[Link](https://github.com/DutchCodingCompany/filament-socialite/blob/1.x/README.md)2.x0.x.xInstall the package via composer:

```
composer require dutchcodingcompany/filament-socialite
```

Publish and migrate the migration file:

```
php artisan vendor:publish --tag="filament-socialite-migrations"
php artisan migrate
```

Other configuration files include:

```
php artisan vendor:publish --tag="filament-socialite-config"
php artisan vendor:publish --tag="filament-socialite-views"
php artisan vendor:publish --tag="filament-socialite-translations"
```

You need to register the plugin in the Filament panel provider (the default filename is `app/Providers/Filament/AdminPanelProvider.php`). The following options are available:

```
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use DutchCodingCompany\FilamentSocialite\Provider;
use Filament\Support\Colors;
use Laravel\Socialite\Contracts\User as SocialiteUserContract;
use Illuminate\Contracts\Auth\Authenticatable;

// ...
->plugin(
    FilamentSocialitePlugin::make()
        // (required) Add providers corresponding with providers in `config/services.php`.
        ->providers([
            // Create a provider 'gitlab' corresponding to the Socialite driver with the same name.
            Provider::make('gitlab')
                ->label('GitLab')
                ->icon('fab-gitlab')
                ->color(Color::hex('#2f2a6b'))
                ->outlined(false)
                ->stateless(false)
                ->scopes(['...'])
                ->with(['...']),
        ])
        // (optional) Override the panel slug to be used in the oauth routes. Defaults to the panel's configured path.
        ->slug('admin')
        // (optional) Enable/disable registration of new (socialite-) users.
        ->registration(true)
        // (optional) Enable/disable registration of new (socialite-) users using a callback.
        // In this example, a login flow can only continue if there exists a user (Authenticatable) already.
        ->registration(fn (string $provider, SocialiteUserContract $oauthUser, ?Authenticatable $user) => (bool) $user)
        // (optional) Change the associated model class.
        ->userModelClass(\App\Models\User::class)
        // (optional) Change the associated socialite class (see below).
        ->socialiteUserModelClass(\App\Models\SocialiteUser::class)
);
```

This package automatically adds 2 routes per panel to make the OAuth flow possible: a redirector and a callback. When setting up your **external OAuth app configuration**, enter the following callback URL (in this case for the Filament panel with ID `admin` and the `github` provider):

```
https://example.com/admin/oauth/callback/github

```

A multi-panel callback route is available as well that does not contain the panel ID in the url. Instead, it determines the panel ID from an encrypted `state` input (`...?state=abcd1234`). This allows you to create a single OAuth application for multiple Filament panels that use the same callback URL. Note that this only works for *stateful* OAuth apps:

```
https://example.com/oauth/callback/github

```

If in doubt, run `php artisan route:list` to see which routes are available to you.

### Icons

[](#icons)

You can specify a custom icon for each of your login providers. You can add Font Awesome brand icons made available through [Blade Font Awesome](https://github.com/owenvoke/blade-fontawesome) by running:

```
composer require owenvoke/blade-fontawesome
```

### Registration flow

[](#registration-flow)

This package supports account creation for users. However, to support this flow it is important that the `password`attribute on your `User` model is nullable. For example, by adding the following to your users table migration. Or you could opt for customizing the user creation, see below.

```
$table->string('password')->nullable();
```

### Domain Allow list

[](#domain-allow-list)

This package supports the option to limit the users that can login with the OAuth login to users of a certain domain. This can be used to setup SSO for internal use.

```
->plugin(
    FilamentSocialitePlugin::make()
        // ...
        ->registration(true)
        ->domainAllowList(['localhost'])
);
```

### Changing how an Authenticatable user is created or retrieved

[](#changing-how-an-authenticatable-user-is-created-or-retrieved)

You can use the `createUserUsing` and `resolveUserUsing` methods to change how a user is created or retrieved.

```
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use Laravel\Socialite\Contracts\User as SocialiteUserContract;

->plugin(
    FilamentSocialitePlugin::make()
        // ...
        ->createUserUsing(function (string $provider, SocialiteUserContract $oauthUser, FilamentSocialitePlugin $plugin) {
            // Logic to create a new user.
        })
        ->resolveUserUsing(function (string $provider, SocialiteUserContract $oauthUser, FilamentSocialitePlugin $plugin) {
            // Logic to retrieve an existing user.
        })
        ...
);
```

### Change how a Socialite user is created or retrieved

[](#change-how-a-socialite-user-is-created-or-retrieved)

In your plugin options in your Filament panel, add the following method:

```
// app/Providers/Filament/AdminPanelProvider.php
->plugins([
    FilamentSocialitePlugin::make()
        // ...
        ->socialiteUserModelClass(\App\Models\SocialiteUser::class)
```

This class should at the minimum implement the [`FilamentSocialiteUser`](/src/Models/Contracts/FilamentSocialiteUser.php) interface, like so:

```
namespace App\Models;

use DutchCodingCompany\FilamentSocialite\Models\Contracts\FilamentSocialiteUser as FilamentSocialiteUserContract;
use Illuminate\Contracts\Auth\Authenticatable;
use Laravel\Socialite\Contracts\User as SocialiteUserContract;

class SocialiteUser implements FilamentSocialiteUserContract
{
    public function getUser(): Authenticatable
    {
        //
    }

    public static function findForProvider(string $provider, SocialiteUserContract $oauthUser): ?self
    {
        //
    }

    public static function createForProvider(
        string $provider,
        SocialiteUserContract $oauthUser,
        Authenticatable $user
    ): self {
        //
    }
}
```

### Check if the user is authorized to use the application

[](#check-if-the-user-is-authorized-to-use-the-application)

You can use the `authorizeUserUsing` method to check if the user is authorized to use the application. **Note:** by [default](/src/Traits/Callbacks.php#L145) this method check if the user's email domain is in the domain allow list.

```
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use Laravel\Socialite\Contracts\User as SocialiteUserContract;

->plugin(
    FilamentSocialitePlugin::make()
        // ...
        ->authorizeUserUsing(function (FilamentSocialitePlugin $plugin, SocialiteUserContract $oauthUser) {
            // Logic to authorize the user.
            return FilamentSocialitePlugin::checkDomainAllowList($plugin, $oauthUser);
        })
        // ...
);
```

### Change login redirect

[](#change-login-redirect)

When your panel has [multi-tenancy](https://filamentphp.com/docs/4.x/users/tenancy) enabled, after logging in, the user will be redirected to their [default tenant](https://filamentphp.com/docs/4.x/users/tenancy#setting-the-default-tenant). If you want to change this behavior, you can call the 'redirectAfterLoginUsing' method on the `FilamentSocialitePlugin`.

```
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use DutchCodingCompany\FilamentSocialite\Models\Contracts\FilamentSocialiteUser as FilamentSocialiteUserContract;
use DutchCodingCompany\FilamentSocialite\Models\SocialiteUser;

FilamentSocialitePlugin::make()
    ->redirectAfterLoginUsing(function (string $provider, FilamentSocialiteUserContract $socialiteUser, FilamentSocialitePlugin $plugin) {
        // Change the redirect behaviour here.
    });
```

Events
------

[](#events)

There are a few events dispatched during the authentication process:

- `InvalidState(InvalidStateException $exception)`: When trying to retrieve the oauth (socialite) user, an invalid state was encountered
- `Login(FilamentSocialiteUserContract $socialiteUser)`: When a user successfully logs in
- `Registered(string $provider, SocialiteUserContract $oauthUser, FilamentSocialiteUserContract $socialiteUser)`: When a user and socialite user is successfully registered and logged in (when enabled in config)
- `RegistrationNotEnabled(string $provider, SocialiteUserContract $oauthUser, ?Auhthenticatable $user)`: When a user tries to login with an unknown account and registration is not enabled
- `SocialiteUserConnected(string $provider, SocialiteUserContract $oauthUser, FilamentSocialiteUserContract $socialiteUser)`: When a socialite user is created for an existing user
- `UserNotAllowed(SocialiteUserContract $oauthUser)`: When a user tries to login with an email which domain is not on the allowlist

Scopes
------

[](#scopes)

Scopes can be added to the provider on the panel, for example:

```
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use DutchCodingCompany\FilamentSocialite\Provider;

FilamentSocialitePlugin::make()
    ->providers([
        Provider::make('github')
            ->label('Github')
            ->icon('fab-github')
            ->scopes([
                // Add scopes here.
                'read:user',
                'public_repo',
            ]),
    ]),
```

Optional parameters
-------------------

[](#optional-parameters)

You can add [optional parameters](https://laravel.com/docs/10.x/socialite#optional-parameters) to the request by adding a `with` key to the provider on the panel, for example:

```
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use DutchCodingCompany\FilamentSocialite\Provider;

FilamentSocialitePlugin::make()
    ->providers([
        Provider::make('github')
            ->label('Github')
            ->icon('fab-github')
            ->with([
                // Add scopes here.
                // Add optional parameters here.
                'hd' => 'example.com',
            ]),
    ]),
```

Visibility
----------

[](#visibility)

You can set the visibility of a provider, if it is not visible, buttons will not be rendered. All functionality will still be enabled.

```
use DutchCodingCompany\FilamentSocialite\FilamentSocialitePlugin;
use DutchCodingCompany\FilamentSocialite\Provider;

FilamentSocialitePlugin::make()
    ->providers([
        Provider::make('github')
            ->visible(fn () => true),
    ]),
```

Stateless Authentication
------------------------

[](#stateless-authentication)

You can add `stateless` parameters to the provider configuration in the config/services.php config file, for example:

```
'apple' => [
    'client_id' => '...',
    'client_secret' => '...',
    'stateless'=>true,
]
```

**Note:** you cannot use the `state` parameter, as it is used to determine from which Filament panel the user came from.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity59

Moderate usage in the ecosystem

Community38

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Recently: every ~61 days

Total

41

Last Release

61d ago

Major Versions

0.2.6 → 1.0.02023-12-05

1.x-dev → 2.0.02024-06-04

2.4.0 → 3.0.0-alpha12025-06-05

PHP version history (3 changes)0.1.0PHP ^8.0

1.0.0PHP ^8.1

3.0.0-alpha1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/253e8fe87efe50428e19537de8f0753d21cdb8dae3a271ad27ef805b9ab0d292?d=identicon)[marcoboers](/maintainers/marcoboers)

![](https://avatars.githubusercontent.com/u/100052?v=4)[Tom Janssen](/maintainers/dododedodonl)[@dododedodonl](https://github.com/dododedodonl)

---

Top Contributors

[![bert-w](https://avatars.githubusercontent.com/u/10498595?v=4)](https://github.com/bert-w "bert-w (111 commits)")[![dododedodonl](https://avatars.githubusercontent.com/u/100052?v=4)](https://github.com/dododedodonl "dododedodonl (92 commits)")[![bramr94](https://avatars.githubusercontent.com/u/24361182?v=4)](https://github.com/bramr94 "bramr94 (66 commits)")[![marcoboers](https://avatars.githubusercontent.com/u/3316595?v=4)](https://github.com/marcoboers "marcoboers (51 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (21 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")[![emmadesilva](https://avatars.githubusercontent.com/u/95144705?v=4)](https://github.com/emmadesilva "emmadesilva (6 commits)")[![bjorn-dcc](https://avatars.githubusercontent.com/u/106660058?v=4)](https://github.com/bjorn-dcc "bjorn-dcc (6 commits)")[![erikgaal](https://avatars.githubusercontent.com/u/1234268?v=4)](https://github.com/erikgaal "erikgaal (5 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![oyepez003](https://avatars.githubusercontent.com/u/1541517?v=4)](https://github.com/oyepez003 "oyepez003 (3 commits)")[![juliangums](https://avatars.githubusercontent.com/u/22907521?v=4)](https://github.com/juliangums "juliangums (3 commits)")[![petecoop](https://avatars.githubusercontent.com/u/1655361?v=4)](https://github.com/petecoop "petecoop (3 commits)")[![LittleHans8](https://avatars.githubusercontent.com/u/15800501?v=4)](https://github.com/LittleHans8 "LittleHans8 (2 commits)")[![wychoong](https://avatars.githubusercontent.com/u/67364036?v=4)](https://github.com/wychoong "wychoong (1 commits)")[![chrillep](https://avatars.githubusercontent.com/u/1267931?v=4)](https://github.com/chrillep "chrillep (1 commits)")[![kykurniawan](https://avatars.githubusercontent.com/u/55426692?v=4)](https://github.com/kykurniawan "kykurniawan (1 commits)")[![phh](https://avatars.githubusercontent.com/u/1304003?v=4)](https://github.com/phh "phh (1 commits)")[![phh-lk](https://avatars.githubusercontent.com/u/183471390?v=4)](https://github.com/phh-lk "phh-lk (1 commits)")[![shaqaruden](https://avatars.githubusercontent.com/u/5414897?v=4)](https://github.com/shaqaruden "shaqaruden (1 commits)")

---

Tags

laraveldutchcodingcompanyfilament-socialite

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dutchcodingcompany-filament-socialite/health.svg)

```
[![Health](https://phpackages.com/badges/dutchcodingcompany-filament-socialite/health.svg)](https://phpackages.com/packages/dutchcodingcompany-filament-socialite)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[andrewdwallo/filament-companies

A comprehensive Laravel authentication and authorization system designed for Filament, focusing on multi-tenant company management.

34450.0k2](/packages/andrewdwallo-filament-companies)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
