Skip to content

Fix embed-key endpoint to use username/slug routing pattern#155

Merged
Yashb404 merged 3 commits intofix/keysfrom
copilot/fix-private-keys-access-denied
Feb 16, 2026
Merged

Fix embed-key endpoint to use username/slug routing pattern#155
Yashb404 merged 3 commits intofix/keysfrom
copilot/fix-private-keys-access-denied

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 16, 2026

The embed-key endpoint used /api/project/:slug/embed-key instead of following the application's standard username/slug pattern, causing routing ambiguity when multiple users have identically-named projects.

Changes

  • Route: /api/project/:slug/embed-key/api/project/:username/:slug/embed-key
  • Handler signature: Path(slug)Path((username, slug))
  • SQL query: Match on both owner_username and slug with case-insensitive comparison
  • Client calls: Include username in embed-key fetch URL (2 locations)

Example

Before:

// Ambiguous - which user's "my-tool" project?
GET /api/project/my-tool/embed-key
WHERE LOWER(slug) = LOWER($1)

After:

// Unambiguous project identification
GET /api/project/johndoe/my-tool/embed-key
WHERE LOWER(owner_username) = LOWER($1) AND LOWER(slug) = LOWER($2)

Route Structure

/api/project/:username/:slug              → project access (with security checks)
/api/project/:username/:slug/embed-key    → private key retrieval (owner-only)
/api/project/:slug/whitelist              → whitelist management (owner-only, session-based)
/api/project/:slug                        → project deletion (owner-only, session-based)

Note: Whitelist and delete endpoints remain slug-only as they verify ownership via session user.id.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix private keys feature access denied issue Fix route ordering conflict causing 403 on embed-key endpoint Feb 16, 2026
Copilot AI requested a review from Yashb404 February 16, 2026 19:02
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Copilot AI changed the title Fix route ordering conflict causing 403 on embed-key endpoint Fix embed-key endpoint to use username/slug pattern Feb 16, 2026
Copilot AI changed the title Fix embed-key endpoint to use username/slug pattern Fix embed-key endpoint to use username/slug routing pattern Feb 16, 2026
@Yashb404 Yashb404 marked this pull request as ready for review February 16, 2026 19:24
@Yashb404 Yashb404 merged commit 28ae56d into fix/keys Feb 16, 2026
1 check passed
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.

2 participants