Skip to content

fix(auth): reject invalid API keys instead of returning anonymous demo memory - #197

Open
jdotc1 wants to merge 4 commits into
himanshu748:mainfrom
jdotc1:security/reject-invalid-api-keys-20261122
Open

jdotc1 wants to merge 4 commits into
himanshu748:mainfrom
jdotc1:security/reject-invalid-api-keys-20261122

Conversation

@jdotc1

@jdotc1 jdotc1 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Closes #45.

Problem

When a caller supplies an unknown/revoked cf_live_ key or the key store is unavailable, identity resolution currently falls back to anonymous demo reads. A client can mistake those sample memories for its private data and does not see credential or database failures.

Changes

  • Unknown or revoked API key: 401 with a safe actionable message. Invalid supplied credentials no longer fall through to anonymous.
  • Missing/unreachable API-key store: 503 with a non-disclosing error; logs include the exception type only, never key material or connection details.
  • Requests with no Authorization header retain read-only demo behavior, and valid/admin credentials retain their scopes.
  • The console distinguishes a rejected saved API key from deliberate anonymous demo mode, and explains transient verification failures.
  • Add identity and REST read-path regressions for missing, valid, unknown, revoked, and unavailable keys. No demo pack is generated when credentials are supplied but rejected.

Validation

Tests added under backend/tests/test_identity.py and backend/tests/test_invalid_key_http.py; full pytest/CI and frontend build are pending. The hosted MCP tools share resolve_identity, so invalid credentials raise a tool error rather than returning demo memory.

@vercel

vercel Bot commented Nov 22, 2026

Copy link
Copy Markdown

@jdotc1 is attempting to deploy a commit to the himanshu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b55b74ce-db19-4c4b-995b-40225eeb3169
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@himanshu748 himanshu748 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please distinguish an explicitly empty Authorization header from an absent header. The final truthiness check currently lets an empty header return anonymous demo data, even though the new identity contract grants demo access only when the header is absent. Add a /pack regression covering both cases, and verify that an empty header returns 401 before recall.

This branch has not been deployed

No deployments
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.

Return 401 for an invalid or revoked API key instead of silently downgrading to anonymous

2 participants