-
-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibly broken API key management for backends #627
Comments
Good find, probably the cause for https://github.com/NixOS/nixops/issues/490 EC2 backend avoids this by storing API token in |
I've written in https://github.com/NixOS/nixops/issues/490#issuecomment-381434938 what I think is the issue. The solution appears easy: Whenever making API requests, always check what's the correct, current API key by inspecting machine definition and environment variables. I don't know why the API key is stored in the state (sqlite DB) at all. It seems unnecessary and the root cause of this problem. |
Also related: #925 |
Hmm, that doesn't seem to be easily possible because Is there any reason not to make the contents of the .nix files visible to all functions, including e.g. |
One possible reason might be that this requires evaluating the nix expressions, which can take very long (minutes if you have many servers), and that we don't want Is it possible to lazily evaluate only the |
Also as written in https://github.com/NixOS/nixops/issues/490#issuecomment-381434938, the Hetzner backend has a special case for updating the keys in |
While looking into an issue with the DigitalOcean backend (#628), I ran into a second issue that's more abstract in nature; for the authentication token to be available within the
<DigitalOceanState>.destroy()
call, it needs to be persisted in theauth_token
state property. However, if the authentication token is ever rotated inbetween thecreate
anddestroy
calls for a given machine, thedestroy
call will fail because theauth_token
in the state file is no longer valid.This can be worked around by overriding the active auth token using the
DIGITAL_OCEAN_AUTH_TOKEN
environment variable; but this is a usability stink, and not really a proper solution.I'm not very familiar with NixOps - all I've described above and in my other issue is stuff that I've inferred from reading the codebase for a few hours, and I don't even have my first working deployment yet - but perhaps there's a better mechanism for accessing/maintaining auth tokens, that can be controlled outside of individual machines? Environment variables are a bit awkward for this purpose, as they can't be easily integrated into the network specification.
I'd imagine that the same issue applies to the Hetzner backend, and probably others as well. If no such mechanism exists yet, I'd perhaps suggest having "backend key management" - that is, something like the following:
This would allow credential rotation without breaking
destroy
for currently existing machines. It wouldn't affect SSH key management; this suggestion is purely for things like API credentials.(I may be entirely wrong about this issue; like I said, my experience with NixOps so far is very limited. Feedback is very welcome!)
The text was updated successfully, but these errors were encountered: