Skip to content
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

Automatically export creators key to the store #2159

Merged
merged 2 commits into from
Mar 16, 2022

Conversation

dominikschulz
Copy link
Member

@dominikschulz dominikschulz commented Mar 15, 2022

Fixes #1919

This will also automatically try to import a public key from the store if none is found. This makes it very convenient to add new recipients, but on the other hand this is might open a small attack vector if someone manages to inject their public key into the git repo and getting an existing member to add it to the recipients. But then on the other hand I wonder how carefully people examine imported GPG keys anyway.

RELEASE_NOTES=[ENHANCEMENT] Automatically export creators key to the
store. Change default for AutoImport to false.

Signed-off-by: Dominik Schulz dominik.schulz@gauner.org

Fixes gopasspw#1919

RELEASE_NOTES=[ENHANCEMENT] Automatically export creators key to the
store.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
@dominikschulz dominikschulz added ux User experience / User Interface related security labels Mar 15, 2022
@dominikschulz dominikschulz added this to the 1.14.0 milestone Mar 15, 2022
Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
@@ -120,7 +120,7 @@ func (s *Action) clone(ctx context.Context, repo, mount, path string) error {

// make sure the parent directory exists.
if parentPath := filepath.Dir(path); !fsutil.IsDir(parentPath) {
if err := os.MkdirAll(parentPath, 0700); err != nil {
if err := os.MkdirAll(parentPath, 0o700); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that 0700 is already octal and the way we are used to see permission in the unix world.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a gofumpt change. I don't have a strong opinion on this, but since we don't have strong community of "style reviewers" here I'd prefer to rely on automation as much as possible, i.e. follow the conventions that the tools suggest.

internal/config/config.go Show resolved Hide resolved
Comment on lines +203 to +217
var exported bool
if sub, err := s.Store.GetSubStore(mount); err == nil {
debug.Log("exporting public keys: %v", idSet.Elements())
exported, err = sub.ExportMissingPublicKeys(ctx, idSet.Elements())
if err != nil {
debug.Log("failed to export missing public keys: %w", err)
}
} else {
debug.Log("failed to get sub store: %s", err)
}

out.Noticef(ctx, "Please ask the owner of the password store to add one of your keys: %s", strings.Join(idSet.Elements(), ", "))
if exported {
out.Noticef(ctx, "The missing keys were exported to the password store. Run `gopass sync` to push them.")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice addition, especially for usage with age.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I did never test this with age. It should work, but ... 🤔

@dominikschulz dominikschulz merged commit c47cb8f into gopasspw:master Mar 16, 2022
@dominikschulz dominikschulz deleted the fix/issue-1919 branch March 16, 2022 14:37
kpitt pushed a commit to kpitt/gopass that referenced this pull request Jul 21, 2022
* Automatically export creators key to the store

Fixes gopasspw#1919

RELEASE_NOTES=[ENHANCEMENT] Automatically export creators key to the
store.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix config tests

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security ux User experience / User Interface related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically add creators gpg key to recipients
2 participants