Blog Detail

02

Sep
Easily Add OAuth Login through Laravel Socialite to Filament cover image

arrow_back Easily Add OAuth Login through Laravel Socialite to Filament

Filament Socialite is an awesome Laravel package that adds OAuth login through Laravel Socialite to Filament.

Installation

You can install this package via composer:

composer require dutchcodingcompany/filament-socialite

You can publish and run the migrations with:

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

You can publish the config file with:

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

Usage

Add the buttons component to your login page, just above the /form closing tag:

    <x-filament-socialite::buttons />
</form>

You can publish the login page for vanilla Filament by running:

php artisan vendor:publish --tag="filament-views"

Which produces a login page at resources/views/vendor/filament/login.blade.php.

Filament Fortify

This component can also be added while using the Fortify plugin.

## in Service Provider file
public function boot()
{
    //...
    
    Filament::registerRenderHook(
        'filament-fortify.login.end',
        fn (): string => Blade::render('@livewire(\'filament-socialite.buttons\')'),
    );
}

Filament Breezy

This component can also be added while using the Breezy plugin.

You can publish the login page for Filament Breezy by running:

php artisan vendor:publish --tag="filament-breezy-views"

Which produces a login page at resources/views/vendor/filament-breezy/login.blade.php.

Events

There are a few events dispatched during the authentication process:

  • Login: When a user successfully logs in
  • Registered: When a user is successfully registered and logged in (when enabled in config)
  • UserNotAllowed: When a user tries to login with an email which domain is not on the allowlist
  • RegistrationNotEnabled: When a user tries to login with an unknown account and registration is not enabled
  • InvalidState: When trying to retrieve the oauth (socialite) user, an invalid state was encountered

For more details and documentation, Please visit Github.

Closing Note

If you are a business and want to leverage Laravel for your next PHP-based web application, CRM Software, E-commerce application, SAAS application, or any custom web application development for your custom requirements, you must discover an amazing team with experience in the Laravel framework. So Codebrisk is here to help you with your tailored requirements regarding Laravel Development. Please feel free to send us an email at rizwan@codebrisk.com or get in touch with us, our business person will get back to you.

Published at : 02-09-2022

Author : Rizwan Aslam
AUTHOR
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project