centivadev / filament-google-workspace-auth
Google Workspace auth for Filament users
Fund package maintenance!
centivadev
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 2
pkg:composer/centivadev/filament-google-workspace-auth
Requires
- php: ^8.2
- filament/filament: ^4.0 || ^5.0
- firebase/php-jwt: ^6.10
- spatie/laravel-package-tools: ^1.15.0
- spatie/laravel-permission: ^6.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^9.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2026-02-12 17:03:37 UTC
README
Google Workspace (OIDC) authentication for Filament v4/v5 using a dedicated FilamentUser model and Spatie roles/permissions.
Features
- 100% Google login (no username/password)
- Workspace domain restriction (
hd+ email domain) - Automatic user provisioning with avatar + last login timestamp
- Default roles:
super-admin,admin,guest - Filament resources to manage users/roles/permissions
- Separate guard and model to avoid conflicts with a future
Usermodel
Requirements
- PHP 8.2+
- Filament v4 or v5
- Laravel 11/12+
Installation
composer require centivadev/filament-google-workspace-auth
Publish config + migrations:
php artisan vendor:publish --tag="filament-google-workspace-auth-config" php artisan vendor:publish --tag="filament-google-workspace-auth-migrations"
Install Spatie permissions (migrations + config):
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="permission-migrations" php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="permission-config" php artisan migrate
Google Cloud Console Setup
- Create or select a Google Cloud Project
- Configure OAuth Consent Screen
- Type:
Internal(Workspace only) - Add your Workspace domain (
mydomain.com) - Add scopes:
openid,email,profile
- Type:
- Create OAuth Client ID
- Type:
Web application - Authorized redirect URI:
https://YOUR-FILAMENT-DOMAIN/auth/google/callback- Example:
https://admin.mydomain.com/auth/google/callback
- Type:
- Copy the Client ID and Client Secret into your
.env
FILAMENT_GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com FILAMENT_GOOGLE_CLIENT_SECRET=xxxx FILAMENT_GOOGLE_REDIRECT_URI=https://admin.mydomain.com/auth/google/callback FILAMENT_GOOGLE_HOSTED_DOMAIN=mydomain.com FILAMENT_GOOGLE_SUPER_ADMIN_EMAILS=admin@mydomain.com,cto@mydomain.com FILAMENT_GOOGLE_DEFAULT_ROLE=guest FILAMENT_GOOGLE_ROUTE_PREFIX=auth/google
Filament Panel Setup
Enable the plugin and remove password-based features from your panel provider:
use CentivaDev\FilamentGoogleWorkspaceAuth\FilamentGoogleWorkspaceAuthPlugin; return $panel ->login() ->plugins([ FilamentGoogleWorkspaceAuthPlugin::make(), ]);
Remove ->passwordReset() and ->emailVerification() from your panel provider to keep the login 100% Google.
FilamentUser model
Add the required traits and fields:
use CentivaDev\FilamentGoogleWorkspaceAuth\Concerns\HasFilamentGoogleWorkspaceUser; use Spatie\Permission\Traits\HasRoles; class FilamentUser extends Authenticatable implements FilamentUserContract, HasAvatar, HasName { use HasFilamentGoogleWorkspaceUser; use HasRoles; protected $fillable = [ 'name', 'email', 'google_sub', 'avatar_url', 'last_login_at', 'banned_at', 'is_active', ]; protected $casts = [ 'last_login_at' => 'datetime', 'banned_at' => 'datetime', 'is_active' => 'boolean', ]; }
Make sure the filament guard exists in config/auth.php and that filament-users provider uses the FilamentUser model.
Configuration
The published config file lives at:
config/filament-google-workspace-auth.php
Key options:
hosted_domainto restrict Workspace domainallowed_emailsto restrict to specific emailssuper_admin_emailsto auto-assignsuper-admindefault_roleto auto-assignguestguardto match your Filament guard (default:filament)routes.prefixto align with your Filament path (example:auth/googlefor a root‑domain panel)
Admin UI
The plugin registers three resources (configurable):
- Filament Users
- Roles
- Permissions
They are grouped under the navigation group configured in resources.navigation_group.
Notes
- This package does not use Socialite.
- All auth is OIDC with PKCE.
- If you want to disable auto-provisioning, set
FILAMENT_GOOGLE_AUTO_PROVISION=false.
Testing
composer test