🔒 Fix missing authentication on card API endpoint#380
Conversation
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Warning Review limit reached
More reviews will be available in 10 minutes and 17 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ 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.
Code Review
This pull request introduces authentication checks to the GET /api/card/[username] API route using getAuthenticatedUser, returning a 401 Unauthorized response if the user is not authenticated. It also adds corresponding unit tests to verify this behavior and updates existing tests to mock a successful authentication. Additionally, the Edge runtime configuration was removed from the route. Feedback indicates that a temporary test execution artifact (test-results/.last-run.json) was accidentally committed and should be removed and added to .gitignore.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| { | ||
| "status": "failed", | ||
| "failedTests": [] | ||
| } No newline at end of file |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@greptile review |
|
@greptile review |
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
|
Closing because the branch keeps re-applying a stale bot commit after fixes and after updating from main. The current diff is no longer the reviewed card API auth/cache fix; it reintroduces test-results/.last-run.json and unrelated files, so it is not safe to merge as-is. |
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
🎯 What: Added authentication checks to the
src/app/api/card/[username]/route.tsAPI endpoint.🛡️ Solution: Integrated the existing
getAuthenticatedUser()utility to protect the route. If a user is not authenticated, the route now correctly returns a 401 Unauthorized status with a rendered error card image. Modified the route to remove the unsupported Edge runtime declaration (since authentication checks require Node APIs here) and updated the corresponding test suite.PR created automatically by Jules for task 11135183214603674343 started by @is0692vs
Greptile Summary
このPRは
/api/card/[username]エンドポイントにgetAuthenticatedUser()を使ったセッション認証を追加し、Edge ランタイム宣言を削除、キャッシュヘッダーをpublicからprivateに変更し、401・429 レスポンスにno-storeを適用する変更です。getServerSessionベースの認証を追加し、未認証時に 401 エラーカードを返すよう変更。キャッシュ設定も認証済みコンテキストに合わせてprivateに統一。ReadmeCardUrlSection.tsxがこのエンドポイントの URL を README 埋め込み用に生成しており、セッション認証はクッキーなしのリクエスト(GitHub 画像プロキシ等)に対して機能しないため、埋め込みユースケースが破壊される可能性がある。beforeEachセットアップを追加し、変更内容を適切にカバーしている。Confidence Score: 4/5
認証追加自体は正しく実装されているが、
ReadmeCardUrlSection.tsxが README 埋め込み用 URL を生成するコンポーネントとして存在しており、セッション認証はその用途と根本的に相容れない。セッションクッキーに依存する認証が、README 埋め込み(GitHub 画像プロキシ経由)という既存ユースケースを完全に破壊する。
ReadmeCardUrlSectionコンポーネントが実際にこのエンドポイントへの埋め込み URL を生成しており、このコンポーネントが利用されている限り、ユーザーが生成した README カードは全て壊れた画像として表示されることになる。src/app/api/card/[username]/route.ts— 認証方式がエンドポイントの埋め込みユースケースと整合しているかを要確認。Important Files Changed
/test-resultsを追加し、テスト出力ファイルのコミットを防ぐ修正。Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant Browser as ブラウザ(ログイン済み) participant External as 外部クライアント(GitHub画像プロキシ等) participant Route as /api/card/[username] participant Auth as getAuthenticatedUser() participant Fetcher as fetchCardData() Browser->>Route: GET(セッションクッキーあり) Route->>Auth: getServerSession() Auth-->>Route: "{ username, token }" Route->>Fetcher: fetchCardData(username) Fetcher-->>Route: CardData Route-->>Browser: "200 カード画像(private, max-age=1800)" External->>Route: GET(クッキーなし) Route->>Auth: getServerSession() Auth-->>Route: null Route-->>External: 401 エラーカード(no-store) Note over External,Route: README埋め込みが破壊される%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant Browser as ブラウザ(ログイン済み) participant External as 外部クライアント(GitHub画像プロキシ等) participant Route as /api/card/[username] participant Auth as getAuthenticatedUser() participant Fetcher as fetchCardData() Browser->>Route: GET(セッションクッキーあり) Route->>Auth: getServerSession() Auth-->>Route: "{ username, token }" Route->>Fetcher: fetchCardData(username) Fetcher-->>Route: CardData Route-->>Browser: "200 カード画像(private, max-age=1800)" External->>Route: GET(クッキーなし) Route->>Auth: getServerSession() Auth-->>Route: null Route-->>External: 401 エラーカード(no-store) Note over External,Route: README埋め込みが破壊されるReviews (3): Last reviewed commit: "Merge branch 'main' into jules-111351832..." | Re-trigger Greptile