gnd: Restrict deploy key config permissions - #6697
Open
erayack wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. What & Why
gnd authstores deploy keys in~/.graph-cli.json. Before this change:gnd createandgnd remove, causing those mutation requests to proceed without authentication.On Unix, auth config writes now create files with mode
0600and explicitly restrict existing files before modifying their contents. Home-directory lookup is fallible rather than panicking, and create/remove propagate stored-key lookup errors instead of converting them into anonymous requests.2. Implementation and Behavior
Permission handling remains within
gnd/src/commands/auth.rs:0600, truncate, then write compact JSON.fs::writebehavior.Authentication resolution now consistently:
--access-tokenwhen supplied.Ok(None)as a legitimate unauthenticated configuration.GraphNodeClient.gnd deployalready propagated stored-key lookup errors and is unchanged. Existing config location, JSON format, node URL normalization, map merge behavior, CLI flags, and public APIs remain unchanged.3. Review Guide
Suggested review order:
gnd/src/commands/auth.rs0600.gnd/src/commands/create.rsgnd/src/commands/remove.rsgnd/src/commands/auth.rsOk(None), and explicit-token precedence.Reviewer checklist
0600.Ok(None)remains a valid unauthenticated result.4. Risk and Non-Goals
The main risk is filesystem behavior across platforms. Unix behavior is covered directly; non-Unix continues using the previous implementation.
No atomic-write, locking, symlink-policy, directory-creation, credential-format, schema, CLI flag, or broader authentication-policy changes are intended.
5. Validation
just formatjust lintjust check --releasecargo test -p gnd commands::auth— 9 passedcargo test -p gnd --lib— 273 passedThe full workspace
just test-unitrun requires the externally managed test configuration and services and was not available locally.