feat(oidc): support access token in body for user info post#769
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #769 +/- ##
==========================================
+ Coverage 19.14% 19.91% +0.77%
==========================================
Files 50 50
Lines 3918 3941 +23
==========================================
+ Hits 750 785 +35
+ Misses 3095 3085 -10
+ Partials 73 71 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8b85239 to
2e383ae
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughUserinfo handler now conditionally parses the Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant API as OIDC Userinfo Handler
participant Store as Token Store / DB
Client->>API: GET/POST /api/oidc/userinfo (Authorization header?)
alt Authorization header present
API->>API: parse Authorization
alt malformed or non-Bearer
API-->>Client: 401 { "error":"invalid_request" or "invalid_grant" }
else valid Bearer token
API->>Store: lookup access token
Store-->>API: token record
API-->>Client: 200 userinfo / 401 error
end
else No Authorization header
alt POST & content-type form-url-encoded
Client->>API: form body containing access_token
API->>Store: lookup access token
Store-->>API: token record
API-->>Client: 200 userinfo / 401 error
else POST with wrong content-type or non-POST
API-->>Client: 400 or 401 { "error":"invalid_request" }
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/controller/oidc_controller.go`:
- Around line 403-404: The content-type check in the OIDC userinfo POST handler
uses c.GetHeader("Content-Type") which fails when parameters like charset are
present; replace that check with Gin's c.ContentType() (e.g. change the
condition currently using c.GetHeader("Content-Type") in the handler to
c.ContentType() != "application/x-www-form-urlencoded") so Content-Type
parameters are ignored while keeping the existing warning log
(tlog.App.Warn().Msg(...)) and behavior otherwise.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3fe1e48c-389f-45e2-9a8b-f24aaee12d04
📒 Files selected for processing (2)
internal/controller/oidc_controller.gointernal/controller/oidc_controller_test.go
2e383ae to
dd448c9
Compare
Rycochet
left a comment
There was a problem hiding this comment.
Looks good - I'd like the test order to be tweaked slightly (including the 2 tests already touching userinfo) - "Bearer", "Bearer ", "Bearer invalid-access-token", etc - sort of in an escalating order of what they're testing - but not important (and that test file is getting somewhat long 😅)
dd448c9 to
3cc72bc
Compare
|
@Rycochet tests have been re-ordered to a more sensible order (IMO). Hopefully you agree 🙂 |
Add support for access token in body for post request to /userinfo
resolves warning (soft failure) in oidc suite:
Before:

After:

Summary by CodeRabbit
New Features
Bug Fixes
Tests