Skip to content

Harden OAuth and session handling#4

Open
ragokan wants to merge 4 commits into
thecodearcher:masterfrom
ragokan:fix-auth-hardening
Open

Harden OAuth and session handling#4
ragokan wants to merge 4 commits into
thecodearcher:masterfrom
ragokan:fix-auth-hardening

Conversation

@ragokan

@ragokan ragokan commented Jun 2, 2026

Copy link
Copy Markdown

Summary

  • verify OpenID Connect ID tokens before mapping profile claims for Google, Apple, LinkedIn, Microsoft, Twitch, and generic providers
  • handle Microsoft shared-tenant issuer discovery safely, and only mark Microsoft email verified when email_verified or verified email arrays prove it
  • reject OAuth profiles with unverified provider emails and prevent implicit linking into local accounts whose email is still unverified
  • align non-OIDC email verification with provider proof: GitHub /user/emails, Discord verified, Facebook/Spotify unverified by default
  • harden default IP/origin handling, refresh-token reuse paths, GORM empty mutations, and unchecked crypto random reads

Verification notes

Tests

  • for d in $(find . -name go.mod -not -path './examples/*' -exec dirname {} \; | sort); do (cd "$d" && go test -race -count=1 ./...); done
  • golangci-lint run --new-from-rev upstream/master ./...
  • golangci-lint run ./... passes in changed provider modules: oauth-microsoft, oauth-generic, oauth-github, oauth-discord, oauth-facebook, oauth-spotify
  • root golangci-lint run ./... still reports existing goconst and cookie gosec baseline warnings present on upstream master

@ragokan ragokan force-pushed the fix-auth-hardening branch from 4478b0f to 3633bf8 Compare June 2, 2026 09:46
@ragokan

ragokan commented Jun 2, 2026

Copy link
Copy Markdown
Author

Hey, I really like where this package is headed. I came from the Node world using Better Auth and was looking for something similar in Go, so Limen felt like the kind of lightweight auth package I wanted to use.

While trying it out, I ran into a few small OAuth/OIDC edge cases around ID-token verification, email verification, and account linking. They are not huge issues, but they matter for production auth flows, so I wanted to send a patch instead of just leaving notes.

I tried to keep the changes focused and added tests around the risky paths. Happy to adjust anything to better fit the project’s direction.

@thecodearcher

Copy link
Copy Markdown
Owner

Hey @ragokan , Thanks for opening this PR. I appreciate you taking the time to contribute to Limen.

I’ll take a proper look at it later and leave any feedback or questions directly on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants