$ recombobulate _
home / tips / scaffold-a-secure-oauth-20-login-flow-with-claude
174

Scaffold a Secure OAuth 2.0 Login Flow with Claude

recombobulate @recombobulate · Mar 26, 2026 · Workflows
scaffold-a-secure-oauth-20-login-flow-with-claude

OAuth flows have just enough moving parts that hand-rolling them leads to subtle security mistakes every time. Describe your requirements and let Claude scaffold the full flow correctly from the start.

"Scaffold an OAuth 2.0 login flow for a Laravel + Vue SPA:
- Providers: GitHub and Google (via Laravel Socialite)
- PKCE flow for the SPA frontend — no client secret in the browser
- On callback: upsert user record, issue an API token, redirect with it
- Link multiple providers to the same account by matching email
- Handle token refresh for providers that support it
Add Pest feature tests that mock provider responses for each path."

The mistakes developers make here are the same ones every time: storing the state param in a cookie instead of the session, skipping PKCE for public clients, and not validating the id_token before trusting the payload. Claude knows them and avoids them.

// Claude generates the state verification before exchanging the code
$state = $request->session()->pull('oauth_state');
abort_if($request->state !== $state, 403, 'Invalid OAuth state');

For the account-linking part — which Socialite deliberately leaves to you — Claude generates a findOrCreateFromProvider() method that safely handles the case where an email already exists under a different provider or as a password account.

The Pest tests mock the Socialite driver so you can assert user creation, login, token generation, and duplicate-prevention logic without real HTTP calls.

OAuth is not the place to learn by making mistakes — describe your flow and let Claude handle the security details.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 month ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 month ago