cable8mm/laravel-social-auth
Adds social login (OAuth) support to Laravel applications, letting users sign in with providers such as Google, Facebook, or GitHub. Provides a simple integration layer for configuring providers and handling social authentication flows.
Install the package and publish its assets:
composer require cable8mm/laravel-social-auth
php artisan vendor:publish --tag=social-auth-config
php artisan vendor:publish --tag=social-auth-migrations
php artisan migrate
Start in the published config file (config/social-auth.php or the package's equivalent). This is the single source of truth for enabled providers, credentials, scopes, redirect behaviour, and route registration. Read it top to bottom before touching any controller — most "why isn't this working" questions are answered there.
Read .replworks/TECH_STACK.md (renamed from FRAMEWORK.md in v1.3.0) and the docs under .replworks/. The docs were reorganised this release; if you're following older blog posts or the v1.2.x README, cross-check against these files first, because several config keys and unused code paths were removed in PR #43.
Add the provider credentials to .env. For OAuth providers you need a client ID/secret; for GitHub App (new in v1.3.0) you need the App ID, client ID, client secret, and private key, plus a webhook secret if you want deauthorisation callbacks:
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_APP_ID=
GITHUB_APP_PRIVATE_KEY= # or a path, depending on config
GITHUB_WEBHOOK_SECRET=
First use case: drop a "Continue with GitHub" link on your login page pointing at the package's redirect route (check php artisan route:list | grep -i social for the exact names). The flow is redirect → provider consent → callback → package resolves the provider user → your handler maps it to an Authenticatable. You should not need to write a controller for the happy path; the package ships one.
Provider configuration, not provider code. Each provider is a config block (driver, credentials, scopes, mapping). Adding a provider is normally a config entry plus env vars, not a new class. Resist subclassing the driver until you've confirmed the package has no extension hook for what you need.
Separate the two flows. The package distinguishes login (create-or-find a user) from connect (attach a social identity to an already-authenticated user). In v1.3.0 the connect intent is bound to the issued state value rather than a global/session-wide key (PR #44). This means:
auth middleware.Auth::check() alone.Handle the callback in one place. Point every provider at a single callback action and switch on the resolved provider. Two things to do there:
provider, provider_user_id, tokens, expiry) via the package's model/table.provider_user_id first, then fall back to email, and make the email-collision decision explicit (auto-link vs. reject vs. prompt). Do not leave this to chance; it is the single most common source of account-takeover bugs in social auth.Consent and post-consent redirects. v1.3.0 keeps the sign-up start page as the post-consent redirect (PR #39). If you add a consent screen of your own (terms, marketing opt-in), the user should land back on the page they came from, not the dashboard. Verify this still holds after any route or middleware changes on your side; a redirect()->intended() in your own code can silently override it.
Webhooks and deauthorisation. GitHub App login (PR #38) and Naver disconnect/revoke (PR #45) bring webhook/callback endpoints into play. Register them in the config, exclude them from CSRF (VerifyCsrfToken $except, or the package's route group if it handles this), and verify signatures using the configured secret. Wire them to mark the social account revoked rather than deleting the user — users expect their local account to survive an unlink from the provider side.
Kakao unlink (PR #41). Treat Kakao's unlink as a first-class event: your "disconnect this provider" action should call the package's revoke path so the token is actually invalidated at Kakao, not just deleted locally. Otherwise re-login can resurrect a stale link.
Testing. Use Socialite's fake/stub mechanism to drive the callback and assert on your user-resolution rules: existing identity, new email, existing email, revoked token. The security-relevant logic lives in that mapping, so it deserves tests independent of the package.
GITHUB_CLIENT_ID/GITHUB_CLIENT_SECRET and just work — check which config keys the App driver reads, and confirm the App is installed on the relevant account/org. "Bad credentials" during token exchange usually means App ID vs. client ID confusion.SESSION_DOMAIN not covering the callback host, SameSite=Strict on the session cookie, a proxy terminating TLS and rewriting the scheme, or multiple app servers without a shared session store. Symptom: intermittent "invalid state" on production only.php artisan config:cache after any config/social-auth.php change. Several config keys were removed in PR #43; if you copied the old file into your app, you may be carrying dead keys that no longer do anything — diff against the freshly published config.route:list and the middleware stack before assuming a signature failure..replworks/ is now the reference (and TECH_STACK.md replaces FRAMEWORK.md). Update internal onboarding links; broken doc links after an upgrade are a support-ticket generator.How can I help you explore Laravel packages today?