age: improve identity loading, add tests, tidy#1064
Merged
Conversation
hiddeco
commented
May 27, 2022
| f, err := os.Open(ageKeyFile) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, fmt.Errorf("failed to open %s file: %w", SopsAgeKeyFileEnv, err) |
Member
Author
There was a problem hiding this comment.
The other option would be to log any loading failure, and only error if identities == 0.
Contributor
There was a problem hiding this comment.
I think this way is preferable. A bit more defense around user mistakes, especially in automation using sops.
Closed
This adds improvements to identity loading, extensive test coverage and a general tidying of bits of code. The improvements are based on a fork of the age key source in the Flux project's kustomize-controller, which was built due to SOPS' limitations around identity management without relying on runtime environment variables. - It introduces a `ParsedIdentity` type which contains a slice of age identities, and can be applied to the `MasterKey`. When applied, further loading of identities from the runtime environment is skipped for `Decrypt` operations. This is most useful when working with SOPS as an SDK, in combination with e.g. a local key service server implementation. - The `Identity` field has been deprecated in the `MasterKey` struct. Presence of the field was misleading, as it is not actually used. - Any detected identity reference is now loaded, instead of it assuming a priority order. This makes more sense, as age is able to work with a set of loaded identities. If no environment variables are defined, the existence of the keys.txt in the user's config directory is required. - Decrypt logs have been added to match other key sources. - Extensive test coverage. Signed-off-by: Hidde Beydals <hello@hidde.co>
ajvb
approved these changes
Jun 6, 2022
| f, err := os.Open(ageKeyFile) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, fmt.Errorf("failed to open %s file: %w", SopsAgeKeyFileEnv, err) |
Contributor
There was a problem hiding this comment.
I think this way is preferable. A bit more defense around user mistakes, especially in automation using sops.
Contributor
|
This is awesome, thank you @hiddeco! |
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.
This adds improvements to identity loading, extensive test coverage
and a general tidying of bits of code. The improvements are based on a
fork of the age key source in the Flux project's kustomize-controller,
which was built due to SOPS' limitations around identity management
without relying on runtime environment variables.
ParsedIdentitytype which contains a slice of ageidentities, and can be applied to the
MasterKey. When applied,further loading of identities from the runtime environment is skipped
for
Decryptoperations. This is most useful when working with SOPSas an SDK, in combination with e.g. a local key service server
implementation.
Identityfield has been deprecated in theMasterKeystruct.Presence of the field was misleading, as it is not actually used.
a priority order. This makes more sense, as age is able to work with
a set of loaded identities. If no environment variables are defined,
the existence of the keys.txt in the user's config directory is
required.