-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(crypto/keyring): add Linux's keyctl support #21653
Merged
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
99206ed
keyring: new keyctl backend
f1d40b0
update godoc
alessio 590c8cb
allow user to set scope
alessio 88b166d
refactor: remove viper as a direct dependency (#21635)
kocubinski 846e9a8
chore: sync changelog with latest releases (#21658)
alessio 98405b1
refactor(server/v2): kill viper from server components (#21663)
julienrbrt 22a4a87
build: don't reinstall golangci-lint if already installed (#21662)
alessio dbeb3f6
fix linter warning
alessio 900a7a1
Merge branch 'main' into keyring-backend-keyctl
alessio 434b5f2
add tests
alessio a47948a
Merge branch 'main' into keyring-backend-keyctl
alessio fedc20a
fix linter warnings
alessio 7205ee9
Merge branch 'main' into keyring-backend-keyctl
alessio 88f9500
Merge branch 'main' into keyring-backend-keyctl
alessio e3e7c26
Merge branch 'main' into keyring-backend-keyctl
tac0turtle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package keyring | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/99designs/keyring" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
) | ||
|
||
// Linux-only backend options. | ||
const BackendKeyctl = "keyctl" | ||
|
||
func newKeyctlBackendConfig(appName, _ string, _ io.Reader) keyring.Config { | ||
return keyring.Config{ | ||
AllowedBackends: []keyring.BackendType{keyring.KeyCtlBackend}, | ||
ServiceName: appName, | ||
KeyCtlScope: "user", | ||
KeyCtlPerm: 0x3f3f0000, | ||
} | ||
} | ||
|
||
// New creates a new instance of a keyring. | ||
// Keyring options can be applied when generating the new instance. | ||
// Available backends are "os", "file", "kwallet", "memory", "pass", "test", "keyctl". | ||
func New( | ||
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option, | ||
) (Keyring, error) { | ||
|
||
if backend != BackendKeyctl { | ||
return newKeyringGeneric(appName, backend, rootDir, userInput, cdc, opts...) | ||
} | ||
|
||
db, err := keyring.Open(newKeyctlBackendConfig(appName, "", userInput)) | ||
if err != nil { | ||
return nil, fmt.Errorf("couldn't open keyring for %q: %w", appName, err) | ||
} | ||
|
||
return newKeystore(db, cdc, backend, opts...), nil | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build !linux | ||
// +build !linux | ||
|
||
package keyring | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
) | ||
|
||
func New( | ||
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option, | ||
) (Keyring, error) { | ||
return newKeyringGeneric(appName, backend, rootDir, userInput, cdc, opts...) | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a clarification on which are the granted permissions here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am doing more work to provide users with sensible perms/scope options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default,
user
andsession
keyring give access to the owner (i.e. the creator) only