Security Advanced Auth - v1.0.0
SocialAuthManager (363 lines) handles OAuth-based social login. 8 providers ship out of the box.
Endpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /auth/social/{provider}/redirect |
Begin OAuth flow |
| GET | /auth/social/{provider}/callback |
OAuth callback |
| POST | /auth/social/{provider}/unlink |
Unlink (requires auth) |
Shipped providers
apple— Sign in with Applefacebook— Facebook Logingithub— GitHubgoogle— Googlelinkedin— LinkedInmicrosoft— Microsoft / Azure AD personaloidc(GenericOidcProvider) — any OIDC provider- (Custom — extend
AbstractOAuth2ProviderorAbstractOidcProvider)
Registering a provider
use ArtisanPackUI\SecurityAdvancedAuth\Authentication\Social\SocialAuthManager;
// In a service provider's boot()
app( SocialAuthManager::class )->registerProvider( 'google', [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect_uri' => route('security-advanced-auth.social.callback', ['provider' => 'google']),
'scopes' => ['openid', 'email', 'profile'],
] );
Repeat per provider. Only registered providers respond to the callback routes — unregistered providers throw RuntimeException.
Linking flow
The bundled SocialAuthController::callback():
- Validates the OAuth
stateparameter (CSRF). - Exchanges the
codefor an access token. - Fetches the user info from the provider.
- If
email_domainsis configured and the user's email domain isn't on the list, rejects. - Either:
- Logs in an existing user (if a
SocialIdentitymatches the provider's user ID), or - Creates a new user and links a fresh
SocialIdentity.
- Logs in an existing user (if a
- Redirects to
config('artisanpack.security-advanced-auth.social.redirect_after_login').
Linking to an existing account
For "connect Google" flows on an existing user's settings page, the SocialAccountsManager Livewire component handles the UX. Internally:
$socialUser = $manager->callback( $provider, $code, $state );
$manager->linkIdentity( $user, $socialUser, $tokens );
Unlinking
The Livewire component handles unlinking, or call directly:
$manager->unlinkIdentity( $user, $provider );
Refuses to unlink the user's only authentication method — they'd be locked out.
Email domain restriction
To restrict social login to users from specific domains (e.g. only @mycompany.com):
'social' => [
'allowed_email_domains' => ['mycompany.com', 'subsidiary.com'],
],
null (default) allows any domain.
Token refresh
$manager->refreshTokens( $socialIdentity );
For providers that issue refresh tokens (Google, Microsoft, Facebook), this refreshes the access token using the stored refresh token.
Custom providers
Implement SocialProviderInterface (or extend AbstractOAuth2Provider / AbstractOidcProvider) and register your class — see Custom social providers.
Social Authentication