Skip to content

feat: add identity user parameter and use that for mtls#996

Merged
levkk merged 5 commits into
mainfrom
levkk-user-identity
May 21, 2026
Merged

feat: add identity user parameter and use that for mtls#996
levkk merged 5 commits into
mainfrom
levkk-user-identity

Conversation

@levkk
Copy link
Copy Markdown
Collaborator

@levkk levkk commented May 21, 2026

[[users]]
identity = "pgdog.dev"
user = "prod"
database = "prod"
server_auth = "rds_iam"

Instead of matching on user, match on identity, allowing multiple users with the same identity.

@levkk levkk requested a review from sgrif May 21, 2026 22:24
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 23.52941% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/backend/databases.rs 0.00% 5 Missing ⚠️
pgdog-config/src/users.rs 20.00% 4 Missing ⚠️
pgdog/src/backend/pool/cluster.rs 50.00% 3 Missing ⚠️
pgdog/src/frontend/client/mod.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@sgrif sgrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits

Comment thread pgdog-config/src/users.rs
for database in databases {
if min_pool_size > 0 {
if min_pool_size > 0
&& user.server_password.is_none()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the line below feel related enough to justify encapsulating in a method

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I don't even know if it's right though yet, I just added this to make the warning go away. Need to 🤔 🤔 🤔 🤔 🤔

Comment thread pgdog/src/backend/pool/cluster.rs Outdated
Comment thread pgdog/src/backend/databases.rs Outdated

/// Get the user TLS identity.
pub fn identity(&self, user: impl ToUser) -> Option<&str> {
if let Some(cluster) = self.databases.get(&user.to_user()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't figure out how to do a multi line selection on mobile but I'd write this as self.databases.get(&user.to_user()).and_then(|cluster| cluster.identity())

Comment thread pgdog/src/frontend/client/mod.rs Outdated
stream.tls_cn() == Some(user)
let identity = databases::databases()
.identity((user, database))
.map(|s| s.to_string());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we cloning this only to immediately go back to a reference on the next line?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's coming from a global ArcSwap and we don't want to keep a reference to that while we check because of its fast path/slow path optimization that scares me.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also because borrow checker said so

@blacksmith-sh
Copy link
Copy Markdown
Contributor

blacksmith-sh Bot commented May 21, 2026

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
TestReloadWithAutoRole View Logs

Fix in Cursor

@sgrif
Copy link
Copy Markdown
Contributor

sgrif commented May 21, 2026 via email

Co-authored-by: Sage Griffin <sage@sagetheprogrammer.com>
@levkk
Copy link
Copy Markdown
Collaborator Author

levkk commented May 21, 2026

Also feels like code that justifies a unit test imo

If I can figure out how to write one for this. TLS is ...like the worst.

@levkk levkk merged commit 5cc5d3d into main May 21, 2026
6 checks passed
@levkk levkk deleted the levkk-user-identity branch May 21, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants