cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.61k stars 262 forks source link

devenv does not use authentication to validate cache existance #1204

Closed vetsin closed 1 week ago

vetsin commented 2 weeks ago

Describe the bug

Devenv does not seem to auth to check cache existance. https://github.com/cachix/devenv/blob/main/devenv/src/command.rs#L280 does not appear to use or pass the auth token to the API, which https://app.cachix.org/api/v1/#/default/get_api_v1_cache__name_ appears to need if it is to return a 200 for a private cache. The API endpoint does return 200 if auth'd via cookie. Manually hitting the api with Authorization: Bearer <thetoken> returns the correct results. I can cachix use private just fine with the same env.

To reproduce

Use the following devenv.nix, with "private" being something you know exists but is private

{ ... }:{
   cachix.pull = [ "private" ]
}

Ensure you have your CACHIX_AUTH_TOKEN in env, then devenv test:

$ devenv test 
• Overriding .devenv to .devenv.iU9FZs9vRRDY
• Building tests ...
✖ Cache private does not exist or you don't have a CACHIX_AUTH_TOKEN configured.
✖ To create a cache, go to https://app.cachix.org/.
• Failed to get cachix caches due to evaluation error

error:
       error: interrupted by the user

Version

On both devenv 1.0.5 (x86_64-linux) and devenv 1.0.5 (aarch64-darwin)

vetsin commented 1 week ago

Fixed by #1209