Add a body-based PUT /api/v1/secrets route so the secret name stays out of the URL

Open
#85 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, go, python

Research direction

Start with the existing route at server/orcaster_server/api/v1.py:1171-1204, its request model at server/orcaster_server/schemas/api_v1.py:415-421, and the CLI calls at orcaster/internal/api/client.go:417-422 and 458-465. Read the 422 handler at server/orcaster_server/main.py:699 and its tests, then trace the current route's validation and errors. Done means the new body route, CLI 405 fallback, tests, docs, and Unreleased changelog entry meet the listed acceptance criteria.

Written by the indexing model from the issue text.

Description

cli enhancement P3 server

Problem

PUT /api/v1/secrets/{name} is the only way to create or replace a secret through the API (server/orcaster_server/api/v1.py:1171-1204). The name travels in the URL path, and the worker scope in ?worker=. A proxy or CDN that logs paths stores the name before the server validates it. If a user pastes a token where the name goes, the token ends up in that log. The docs warn about this (orcaster/README.md:192-198, docs/user-manual.md:3896-3902), and the CLI only guards against known token prefixes.

The CLI builds the path route for orcaster secret set (orcaster/internal/api/client.go:417-422, orcaster/internal/api/client.go:458-465).

Proposed change

  1. Add PUT /api/v1/secrets with a JSON body {"name": "...", "value": "...", "worker": "..."}. worker is optional (UUID or name), as ?worker= is today. Use a new request model with extra="forbid" and the same validation as the path route: _validated_secret_name, owner check, keyring check and the same errors (worker_deleted, worker_not_found, task_secrets_unconfigured). The response is the same SecretItem.
  2. Keep PUT /api/v1/secrets/{name} and DELETE /api/v1/secrets/{name} unchanged.
  3. The 422 handler already hides the received input for every path under /api/v1/secrets (server/orcaster_server/main.py:699, server/orcaster_server/main.py:708-714). Add a test that confirms it for the new route.
  4. Move orcaster secret set to the body route. If the server answers 405 (an older server, where PUT /api/v1/secrets does not exist), fall back to the path route once.
  5. Update orcaster/README.md, docs/user-manual.md (the API section at docs/user-manual.md:3886-3902 and the route table at docs/user-manual.md:5580) and the docstring of SecretPutRequest (server/orcaster_server/schemas/api_v1.py:415-421).

Compatibility

  • The new route is additive. The path route keeps working, so existing scripts and older CLI binaries are not affected.
  • A new CLI against an older server falls back to the path route, so mixed versions keep working during an upgrade.
  • DELETE still takes the name in the path. That stays documented.

Acceptance criteria

  • PUT /api/v1/secrets with name, value and optional worker creates or replaces the secret and returns the same metadata as the path route (test).
  • The new route returns the same errors as the path route for a bad name, a non-owner PAT, missing keys, and an unknown or deleted worker (tests).
  • A 422 on the new route does not echo the value or the name (test).
  • orcaster secret set uses the body route, and falls back to the path route when the server answers 405 (Go test with a fake server).
  • PUT /api/v1/secrets/{name} keeps working unchanged (existing tests pass).
  • Existing clients keep working without changes.
  • orcaster/README.md and docs/user-manual.md describe both routes and recommend the body route.
  • CHANGELOG entry under Unreleased.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.