-
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
Database Access: decouple Auth from Session #43344
Conversation
… share CloudClients instance, update tests.
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
I've dropped the |
// GetTLSConfig builds the client TLS configuration for the session. | ||
GetTLSConfig(ctx context.Context, sessionCtx *Session) (*tls.Config, error) | ||
GetTLSConfig(ctx context.Context, certExpiry time.Time, database types.Database, databaseUser string) (*tls.Config, error) |
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.
This signature change (and possibly others) broke the e/ build.
This change decouples
lib/srv/db/Auth
fromlib/srv/db/Session
, making it possible to use anAuth
instance without an active user session.Auth
used to depend on various fields fromSession
, yet in practice very few fields were actually used. The updated interface is explicit about the data requirements, which improves the clarity.The updated interface no longer accepts session ID, but instead makes it possible to clone
Auth
with overridden logger instance. This is used to inject session id and database name fields in a consistent fashion.The cloning is made easier by the fact that
Auth
no longer owns any resources: it no longer implementsfunc Close() error
. The ownership of the only resource, theCloudClients
field, was moved.Auth
will no longer initialise an instance of that type on startup, expecting to be passed a copy instead. This change also means improved sharing ofCloudClients
instance along with the associated benefits.The tests are updated accordingly.
While this change presents no immediate benefit, it will ultimately allow for periodic connections to databases for the purpose of healthchecks as well as pulling in database schema information.