Skip to content

feat: allow credentials via environment variables for headless deployments - #37

Open
lekker-solutions wants to merge 1 commit into
milldr:mainfrom
lekker-solutions:feat/env-var-credentials
Open

feat: allow credentials via environment variables for headless deployments#37
lekker-solutions wants to merge 1 commit into
milldr:mainfrom
lekker-solutions:feat/env-var-credentials

Conversation

@lekker-solutions

Copy link
Copy Markdown

Summary

Enables running crono in headless environments (containers, VMs, CI) without an interactive crono login. All credentials can now be injected as environment variables at provision time.

Changes

  • src/credentials.tsgetCredential() now checks environment variables before falling back to the keychain / encrypted-file store:
    • KERNEL_API_KEY → Kernel.sh API key
    • CRONO_CRONOMETER_USERNAME → Cronometer email
    • CRONO_CRONOMETER_PASSWORD → Cronometer password
  • src/kernel/client.ts — removed the client-specific KERNEL_API_KEY env check; centralized in getCredential()
  • src/cronometer/export.ts — missing-credentials error now points to env vars for headless setups
  • README.md — documented env-based auth with a docker run example
  • tests/credentials.test.ts — tests for env resolution, precedence over stored credentials, and fallback

Env vars take precedence over stored credentials, matching the behavior kernel/client.ts already had for KERNEL_API_KEY.

Container usage

docker run -e KERNEL_API_KEY=sk-...            -e CRONO_CRONOMETER_USERNAME=you@example.com            -e CRONO_CRONOMETER_PASSWORD=secret            your-image crono quick-add -p 30 -c 100

No config file or keychain required. Backend defaults to Kernel (remote browser, no display needed); the existing CRONO_GWT_PERMUTATION/CRONO_GWT_HEADER overrides continue to work.

Testing

  • npm test — 224 passing (14 in credentials, 3 new)
  • npm run build clean

…ments

Resolve all credentials from env vars before falling back to the
keychain/encrypted-file store, so containers and CI can authenticate
without an interactive `crono login`:

- KERNEL_API_KEY
- CRONO_CRONOMETER_USERNAME
- CRONO_CRONOMETER_PASSWORD

Env vars take precedence over stored credentials. Centralizes the
previously kernel-client-specific KERNEL_API_KEY check into
getCredential(), updates the export error message to point at env
vars, and documents the headless flow in the README.
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.

1 participant