-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add option to customize admin schema for PostgreSQL auto user provisioning #43338
Conversation
return nil | ||
} | ||
|
||
if db.GetProtocol() != defaults.ProtocolPostgres || (db.GetType() != types.DatabaseTypeSelfHosted && !db.IsRDS() && !db.IsRedshift()) { |
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.
if db.GetProtocol() != defaults.ProtocolPostgres || (db.GetType() != types.DatabaseTypeSelfHosted && !db.IsRDS() && !db.IsRedshift()) { | |
if db.GetProtocol() != defaults.ProtocolPostgres { |
} | ||
conn, err := e.pgxConnect(ctx, sessionCtx.WithUserAndDatabase(sessionCtx.Database.GetAdminUser().Name, loginDatabase)) | ||
|
||
conn, err := e.pgxConnect(ctx, sessionCtx.WithUserAndDatabase(sessionCtx.Database.GetAdminUser().Name, loginDatabase), loginSchema) |
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.
conn, err := e.pgxConnect(ctx, sessionCtx.WithUserAndDatabase(sessionCtx.Database.GetAdminUser().Name, loginDatabase), loginSchema) | |
conn, err := e.pgxConnect(ctx, sessionCtx.WithUserAndDatabase(sessionCtx.Database.GetAdminUser().Name, loginDatabase).WithStartupParams(runtimeParams)) |
What do you think if we update the sessionCtx with runtime params needed for admin instead of changing pgxConnect
} | ||
|
||
if sessionCtx.Database.GetAdminUser().DefaultSchema != "" { | ||
loginSchema = sessionCtx.Database.GetAdminUser().DefaultSchema |
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.
Could we log this schema the above log
Could you share the documentation change as well? Thanks! |
superseded by #44255 |
Closes #37609.
This PR adds a new option,
default_schema
, to customize the PostgreSQL schema where the procedures will be stored. When establishing a connection, we provide thesearch_path
option. This option ensures the procedures are created on the schema and correctly found when called. This option works for both PostgreSQL and RedShift instances.In addition, this option requires validation to prevent users from setting it to
pg_temp
(a per-session schema). This is necessary because procedures are only created once during the Teleport database session, so they are expected to be on the database when the session ends. Also,pg_temp
doesn't support creating procedures on RedShift, returning an error like "ERROR: no schema has been selected to create in".Changelog: Add an option (
admin_user.default_schema
) to customize the default PostgreSQL schema admin users use when managing auto-provisioned users.