feat: let the server supply OCR provider tokens with RM_CLAUDE_CODE_OAUTH_TOKEN and RM_ANTHROPIC_API_KEY #19

Merged
jfro merged 1 commit from env-ocr-credentials into main 2026-10-16 14:04:15 +00:00
Owner

Lets the server supply the token for every user's OCR provider (and so chat and suggestions, which reuse it) from the environment, instead of each user saving one in Settings.

  • RM_CLAUDE_CODE_OAUTH_TOKEN (Claude Code) and RM_ANTHROPIC_API_KEY (Claude API), read in config/runtime.exs. They're prefixed so a plain CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_API_KEY doesn't end up in the server's environment for claude and other tools to pick up.
  • The server's token wins. While one is set for a provider, Settings shows "The token is set by the server, with RM_…" instead of the token field. Model, active provider and auto-transcribe stay per user.
  • It's never saved: OCR.get_provider/2, active_provider/1, save_provider/3 and activate_provider/2 fill it in on the loaded config only, and the changeset doesn't cast a credential while it's set.
  • A token saved earlier is kept and applies again if the variable is removed.
  • Migration: ocr_providers.credential becomes nullable, for providers set up with a server token. If the variable is later removed, that provider isn't ready (active_provider/1 and the new get_ready_provider/2 return nil, so jobs and chat treat it as not set up) until a token is saved in Settings.
  • README and runtime.exs note that the token applies to all users, so a setup-token should only be used on an instance that's just yours.

Tests: server credential cases in ocr_test.exs and the settings LiveView (including that the claude CLI gets the server's token). Full suite 657 passed; --warnings-as-errors (test and prod) and format --check-formatted are clean.

Lets the server supply the token for every user's OCR provider (and so chat and suggestions, which reuse it) from the environment, instead of each user saving one in Settings. - `RM_CLAUDE_CODE_OAUTH_TOKEN` (Claude Code) and `RM_ANTHROPIC_API_KEY` (Claude API), read in `config/runtime.exs`. They're prefixed so a plain `CLAUDE_CODE_OAUTH_TOKEN` / `ANTHROPIC_API_KEY` doesn't end up in the server's environment for `claude` and other tools to pick up. - **The server's token wins.** While one is set for a provider, Settings shows "The token is set by the server, with `RM_…`" instead of the token field. Model, active provider and auto-transcribe stay per user. - It's never saved: `OCR.get_provider/2`, `active_provider/1`, `save_provider/3` and `activate_provider/2` fill it in on the loaded config only, and the changeset doesn't cast a credential while it's set. - A token saved earlier is kept and applies again if the variable is removed. - Migration: `ocr_providers.credential` becomes nullable, for providers set up with a server token. If the variable is later removed, that provider isn't ready (`active_provider/1` and the new `get_ready_provider/2` return nil, so jobs and chat treat it as not set up) until a token is saved in Settings. - README and `runtime.exs` note that the token applies to all users, so a `setup-token` should only be used on an instance that's just yours. Tests: server credential cases in `ocr_test.exs` and the settings LiveView (including that the `claude` CLI gets the server's token). Full suite 657 passed; `--warnings-as-errors` (test and prod) and `format --check-formatted` are clean.
jfro merged commit 7755fd3ef9 into main 2026-10-16 14:04:15 +00:00
jfro deleted branch env-ocr-credentials 2026-10-16 14:04:15 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!19
No description provided.