-
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
PostgreSQL - Add username customization #10766
Conversation
This pull request is being automatically deployed with Vercel (learn more). vault-storybook – ./ui🔍 Inspect: https://vercel.com/hashicorp/vault-storybook/bp51xa2n2 [Deployment for 3b2f71f canceled] |
|
||
_, err = p.usernameProducer.Generate(dbplugin.UsernameMetadata{}) | ||
if err != nil { | ||
return dbplugin.InitializeResponse{}, fmt.Errorf("invalid username template - did you reference a field that isn't available? : %w", err) |
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.
Nit: does the error returned here tell you which field evaluated was invalid? I feel that "invalid username template: %w"
might be sufficient here if so.
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.
Example errors:
Input: foo-{{random 5}}-{{.FooBar}}
unable to apply template: template: template:1:19: executing "template" at <.FooBar>: can't evaluate field FooBar in type dbplugin.UsernameMetadata
Input: foo-{{random 5}}-{{FooBar}}
unable to parse template: template: template:1: function "FooBar" not defined
I'll look to see if the error that's returned is structured in any meaningful way so we can make this a bit nicer to users who aren't familiar with these errors.
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.
Unfortunately the errors coming back from the template library (the Go one, not the one in Vault) are not structured in a useful way here. I will remove this message and put a note in the docs about common error messages.
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.
LGTM
Adds the ability to customize username generation for dynamic users in PostgreSQL.
Uses the new field
username_template
with the go template language.Docs PR will come after all other updates for username customization are complete for this release.