filament/filament
v3.2.0
v11.9
No response
8.2
I'm facing an issue while integrating Auth0 with FilamentPHP in my Laravel application. I've followed the Auth0 Laravel documentation to set up authentication. However, when attempting to access the Filament admin panel (/admin route), I'm caught in a redirect loop between the /admin and /login routes.
The user should be authenticated via Auth0 and redirected to the FilamentPHP admin panel.
Steps to Reproduce:
Set up a Laravel project with FilamentPHP.
Follow the Auth0 Laravel guide to integrate Auth0.
Attempt to access the FilamentPHP admin panel.
auth.php (Laravel Configuration):
'guards' => [
'auth0' => [
'driver' => 'session',
'provider' => 'auth0-provider',
],
],
'providers' => [
'auth0-provider' => [
'driver' => 'auth0.provider',
// 'model' => env('AUTH_MODEL', App\Models\User::class),
'repository' => \App\Repositories\UserRepository::class,
],
],
UserRepository.php:
<?php
namespace App\Repositories;
use App\Models\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Auth0\Laravel\{UserRepositoryAbstract, UserRepositoryContract};
final class UserRepository extends UserRepositoryAbstract implements UserRepositoryContract
{
public function fromAccessToken(array $user): ?Authenticatable
{
return User::where('auth0', $user['sub'])->firstOrFail();
}
public function fromSession(array $user): ?Authenticatable
{
$userdb = User::where('email', $user['email'])->firstOrFail();
if($userdb != null && $userdb->auth0 == null) {
$userdb->auth0 = $user['sub'] ?? '';
$userdb->save();
}
return $userdb;
}
}
AdminPanelProvider.php:
<?php
namespace App\Providers\Filament;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
...
// ->login(Login::class)
->authMiddleware([
Authenticate::class,
])
->authGuard('auth0');
}
}
https://github.com/abdulmlik/FilamentPHP-auth0
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too