feat: add magic link auth provider with code exchange#2649
Conversation
213613f to
7aca666
Compare
|
This is the related PR in |
01f959e to
3798613
Compare
Custom OmniAuth strategy that delegates authentication to the auth app (auth.codebar.io) via OAuth 2.1 / OIDC with PKCE.
Tests for CSRF detection, missing code, PKCE, token exchange failures, JWT verification, success path, and User-Agent header.
59892fc to
b4caba6
Compare
|
I have deployed both PRs for I also reviewed the PRs against OWASP top 10 for 2025, and fixed the few minor things that surfaced. This unfortunately meant that I had to make some changes since I originally marked this as ready for review. I chose to rewrite the git history, in order to make the PRs easier to follow ... i.e. without any side quests. They should read fairly linearly now. Testing on Heroku To verify the OAuth 2.1 flow end-to-end: Flow A: Sign in with GitHub
Flow B: Sign in with Magic Link
If something goes wrongCheck the staging app logs: heroku logs --tail -a codebar-stagingOAuth errors from the planner side show as (codebar) Authentication failure! <error_type>. The auth |
This adds an integration with our new auth app (auth.codebar.io), which allows users to sign up with a magic link as well as GitHub.
Initially, this will not be available through the UI, but on a new url: https://codebar.io/auth/codebar instead of https://codebar.io/auth/github
This allows us to iron out any kinks there might be, before we start relying on it.
Summary
Adds a custom OmniAuth strategy (
:codebar) that delegates authentication to a separate auth app. The auth app becomes an identity provider — users authenticate via magic link or GitHub OAuth on the auth app, which issues a one-time code exchanged server-to-server for a signed JWT.Commits
chore: add jwt gem for OIDC token verificationjwtgem dependency for JWKS verificationfeat: add codebar OmniAuth strategy with PKCE code exchangespec: cover codebar OmniAuth strategy callback phase pathsKey Design Decisions
User-Agent: Ruby(Net::HTTP default). All outgoing HTTP requests useCodebar Planner/1.0.:githuband:codebarproviders coexist — existing auth controller unchanged.return fail!: All error paths usereturn fail!(...)instead offail!(...); returnso the Rack response propagates correctly.Files
Gemfile/Gemfile.lock— Addedjwtgemconfig/application.rb— Excludeomniauthfrom autoload pathsconfig/initializers/omniauth.rb— Register:codebarprovider withauth_urlandaudiencelib/omniauth/strategies/codebar.rb— Custom OmniAuth strategy (request_phase, callback_phase, PKCE code exchange, JWT verification with JWKS, custom User-Agent)spec/lib/omniauth/strategies/codebar_spec.rb— 14 tests covering all callback phase pathsTesting
14 strategy tests + full existing suite (1061 examples, 0 failures).