-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Use the role name in the db username #2812
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e39ff35
Pass the role name into the username created by the database backend
8f5a8f9
Fix tests
12d05e7
Fix unix time stamp to string conversion
328786e
Add test for RandomAlphaNumericOfLen function
ae07499
Lowercase the cassandra password
0017c15
Upate docs to add more references to running custom plugins
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ import ( | |
// Database is the interface that all database objects must implement. | ||
type Database interface { | ||
Type() (string, error) | ||
CreateUser(statements Statements, usernamePrefix string, expiration time.Time) (username string, password string, err error) | ||
CreateUser(statements Statements, usernameConfig UsernameConfig, expiration time.Time) (username string, password string, err error) | ||
RenewUser(statements Statements, username string, expiration time.Time) error | ||
RevokeUser(statements Statements, username string) error | ||
|
||
|
@@ -29,6 +29,13 @@ type Statements struct { | |
RenewStatements string `json:"renew_statements" mapstructure:"renew_statements" structs:"renew_statements"` | ||
} | ||
|
||
// UsernameConfig is used to configure prefixes for the username to be | ||
// generated. | ||
type UsernameConfig struct { | ||
DisplayName string | ||
RoleName string | ||
} | ||
|
||
// PluginFactory is used to build plugin database types. It wraps the database | ||
// object in a logging and metrics middleware. | ||
func PluginFactory(pluginName string, sys pluginutil.LookRunnerUtil, logger log.Logger) (Database, error) { | ||
|
@@ -89,7 +96,7 @@ func PluginFactory(pluginName string, sys pluginutil.LookRunnerUtil, logger log. | |
// This prevents users from executing bad plugins or executing a plugin | ||
// directory. It is a UX feature, not a security feature. | ||
var handshakeConfig = plugin.HandshakeConfig{ | ||
ProtocolVersion: 1, | ||
ProtocolVersion: 2, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bumping this means all existing plugins will need to recompile and probably update their code. |
||
MagicCookieKey: "VAULT_DATABASE_PLUGIN", | ||
MagicCookieValue: "926a0820-aea2-be28-51d6-83cdf00e8edb", | ||
} | ||
|
@@ -117,7 +124,7 @@ type InitializeRequest struct { | |
|
||
type CreateUserRequest struct { | ||
Statements Statements | ||
UsernamePrefix string | ||
UsernameConfig UsernameConfig | ||
Expiration time.Time | ||
} | ||
|
||
|
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
What would be a case where
DisplayName
andRoleName
are different?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.
Display names are tied to tokens- the vault user who created the cred. Role name is the name of the database role that created the cred
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 see, so the role name (and unix timestamp) is now included as part of the username for more verbosity as to who and when the token was created?
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.
Correct!