Skip to content
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

Merged
merged 5 commits into from
Jun 26, 2024
Merged

Conversation

Tener
Copy link
Contributor

@Tener Tener commented Jun 21, 2024

This change decouples lib/srv/db/Auth from lib/srv/db/Session, making it possible to use an Auth instance without an active user session. Auth used to depend on various fields from Session, 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 implements func Close() error. The ownership of the only resource, the CloudClients 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 of CloudClients 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.

Copy link

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 changelog: followed by the changelog entries for the PR.

@Tener Tener added the no-changelog Indicates that a PR does not require a changelog entry label Jun 21, 2024
@Tener
Copy link
Contributor Author

Tener commented Jun 21, 2024

I've dropped the SessionAuth wrapper in favour of updating the affected code directly, per feedback from @greedy52 . This makes the PR larger, but I think is a net gain longer term maintenance wise.

lib/srv/db/common/auth.go Show resolved Hide resolved
lib/srv/db/common/auth.go Outdated Show resolved Hide resolved
lib/srv/db/common/auth.go Outdated Show resolved Hide resolved
lib/srv/db/common/auth.go Outdated Show resolved Hide resolved
@Tener Tener requested a review from greedy52 June 24, 2024 19:10
@Tener Tener added this pull request to the merge queue Jun 26, 2024
Merged via the queue into master with commit 18b6b7f Jun 26, 2024
36 checks passed
@Tener Tener deleted the tener/db-auth-refactor branch June 26, 2024 06:22
@public-teleport-github-review-bot

@Tener See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Create PR
branch/v16 Create PR

// 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)
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 database-access Database access related issues and PRs no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants