Skip to content

Conversation

@kevalyq
Copy link
Contributor

@kevalyq kevalyq commented Nov 16, 2025

πŸ“‹ Overview

Implements the complete OpenAPI 3.1 specification for Secret Management API (CRUD + Sharing), unblocking Frontend development for file upload integration and PWA features.

✨ What This PR Does

Secret CRUD Endpoints (5 total)

  • GET /v1/secrets - List user's secrets with pagination
  • POST /v1/secrets - Create new secret with encrypted fields
  • GET /v1/secrets/{id} - View secret details
  • PATCH /v1/secrets/{id} - Update secret (version auto-incremented)
  • DELETE /v1/secrets/{id} - Soft delete secret

Secret Sharing Endpoints (3 total)

  • GET /v1/secrets/{id}/shares - List all shares for a secret
  • POST /v1/secrets/{id}/shares - Grant read/write/admin access
  • DELETE /v1/secrets/{id}/shares/{shareId} - Revoke access

πŸ”‘ Key Features Documented

Schemas

  • Secret: Encrypted fields (title, username, password, url, notes), tags, expiration, versioning
  • SecretShare: User/role sharing with permission hierarchy

Permission Hierarchy

admin β†’ Can do everything (view, update, delete) - but not grant shares (owner only)
write β†’ View + update secret + upload attachments
read  β†’ View secret + download attachments (read-only)

XOR Constraint

Share with user OR role (not both):

// Valid: Share with user
{"user_id": "uuid", "permission": "read"}

// Valid: Share with role
{"role_id": 5, "permission": "write"}

// Invalid: Both user_id AND role_id (422 error)

Validation Rules

  • title: Required, max 255 chars
  • username, password, url, notes: Optional, with max lengths
  • tags: Array of strings (max 50 chars each)
  • expires_at: Must be future date
  • permission: Enum (read, write, admin)

Error Responses

  • 400: Bad Request (invalid parameters)
  • 401: Unauthorized (missing/invalid token)
  • 403: Forbidden (insufficient permissions)
  • 404: Not Found (secret doesn't exist)
  • 422: Validation Error (with detailed field errors)

πŸ“¦ Files Changed

  • docs/openapi.yaml - Added 8 new endpoints + 2 schemas (~593 lines)
  • CHANGELOG.md - Documented new API specification

βœ… Quality Gates

  • βœ… OpenAPI Validation: Valid with Redocly CLI (2 warnings - cosmetic only)
  • βœ… Prettier: Code formatted
  • βœ… Markdownlint: All docs pass
  • βœ… REUSE 3.3: Compliant (41/41 files)
  • βœ… Domain Policy: secpal.app/secpal.dev only
  • βœ… Preflight: All checks passed (593 changed lines)

🎯 Unblocks

Frontend Issues (can now start):

Backend PRs (already merged, this documents them):

πŸ”— Related

🚫 Breaking Changes

None - These are all new endpoints. Existing API endpoints unchanged.

πŸ“ Checklist

  • OpenAPI 3.1 spec valid (Redocly)
  • CHANGELOG.md updated
  • All quality gates passing
  • REUSE compliant
  • Conventional commit format
  • Self-review completed

Estimated Impact: Unblocks 3 Frontend issues + documents 2 merged Backend PRs
Spec Coverage: 8 endpoints, 2 schemas, 5 error types, permission hierarchy, XOR constraint

- Add 5 Secret CRUD endpoints (list, create, view, update, delete)
- Add 3 Secret Sharing endpoints (list shares, grant, revoke)
- Define Secret schema with encrypted fields (title, username, password, url, notes)
- Define SecretShare schema with permission hierarchy (read/write/admin)
- Document XOR constraint (user OR role, not both)
- Add validation rules (field lengths, required fields, enums)
- Add comprehensive error responses (400, 401, 403, 404, 422)
- Support pagination for list endpoints
- Require JWT Bearer authentication

Implements OpenAPI spec for SecPal/api PRs #183, #185 (Phase 3)
Part of: SecPal/api#173 (Secret Management System Epic)

BREAKING CHANGE: none (new endpoints only)

Signed-off-by: Holger Schmermbeck <holger@secpal.app>
Copilot AI review requested due to automatic review settings November 16, 2025 20:55
@github-actions
Copy link

πŸ’‘ Tip: Consider Using Draft PRs

Benefits of opening PRs as drafts initially:

  • πŸ’° Saves CI runtime and Copilot review credits
  • 🎯 Automatically sets linked issues to "🚧 In Progress" status
  • πŸš€ Mark "Ready for review" when done to trigger full CI pipeline

How to convert:

  1. Click "Still in progress? Convert to draft" in the sidebar, OR
  2. Use gh pr ready when ready for review

This is just a friendly reminder - feel free to continue as is! 😊

Copilot finished reviewing on behalf of kevalyq November 16, 2025 21:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a complete OpenAPI 3.1 specification for the Secret Management API, providing 8 new endpoints for CRUD operations and sharing functionality. The specification documents encrypted secret storage with fields for credentials, tags, versioning, and expiration, along with a permission-based sharing system supporting user and role-based access control.

Key additions include:

  • 5 Secret CRUD endpoints with encrypted field support and versioning
  • 3 Secret Sharing endpoints with XOR constraint (user OR role) and permission hierarchy (read/write/admin)
  • Comprehensive validation rules, error responses, and detailed examples for all endpoints

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
docs/openapi.yaml Adds Secret and SecretShare schemas with complete CRUD and sharing endpoint definitions, including authentication, pagination, validation rules, and error responses (400, 401, 403, 404, 422)
CHANGELOG.md Documents the addition of Secret Management API specification with details on endpoints, schemas, validation rules, XOR constraints, and permission hierarchy

- Fix CHANGELOG path params: {id}β†’{secret}, {shareId}β†’{share}
- Change terminology: (plaintext)β†’(decrypted) for consistency with SecretAttachment
- Clarify pagination policy: offset-based for most endpoints, cursor-based for large datasets
- Add 500 InternalServerError response to all 8 Secret endpoints (Checklist 3: Error Coverage)

Addresses all 4 Copilot review comments:
1. βœ… CHANGELOG path mismatch (comment #2532229630)
2. βœ… Missing 500 responses (comment #2532229636)
3. βœ… Terminology consistency (comment #2532229639)
4. βœ… Pagination policy clarity (comment #2532229643)
@kevalyq kevalyq added the large-pr-approved Approved large PR (boilerplate/templates that cannot be split) label Nov 16, 2025
@kevalyq kevalyq merged commit 1ea2457 into main Nov 16, 2025
16 of 17 checks passed
@kevalyq kevalyq deleted the feat/secret-management-api-spec branch November 16, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

large-pr-approved Approved large PR (boilerplate/templates that cannot be split)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants