Skip to content

Conversation

@bobbyiliev
Copy link
Contributor

@bobbyiliev bobbyiliev commented Nov 6, 2025

Motivation

Enables SCRAM authentication for SQL connections in self-managed deployments. HTTP listeners automatically fall back to Password authentication when SASL is configured, as SASL is only supported for the PostgreSQL wire
protocol.

As suggested by Justin, we might want to refactor this as we introduce additional authentication modes like SSO and JWT etc.

Tips for reviewer

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

Copy link
Contributor

@doy-materialize doy-materialize left a comment

Choose a reason for hiding this comment

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

overall looks reasonable, just a couple questions about the tests

if self.value == "Password" and version <= MzVersion.parse_mz("v0.147.6"):
if (
self.value == "Password" or self.value == "Sasl"
) and version <= MzVersion.parse_mz("v0.147.6"):
Copy link
Contributor

Choose a reason for hiding this comment

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

presumably we'll need a different version check for sasl vs password, since sasl was only supported later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm yes, good point, let me try to track down when this was introduced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as far as I can tell this was introduced in v0.147.16: https://github.com/MaterializeInc/release/issues/302

6875
if version >= MzVersion.parse_mz("v0.147.0") and self.value == "Password"
if version >= MzVersion.parse_mz("v0.147.0")
and (self.value == "Password" or self.value == "Sasl")
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@bobbyiliev bobbyiliev force-pushed the orchestratord-scram-auth branch 4 times, most recently from 5531f5f to 96856ee Compare November 6, 2025 20:23
Comment on lines 1633 to 1636
let authenticator_kind = mz.spec.authenticator_kind;
let auth_kind = mz.spec.authenticator_kind;
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: why shorten?

base: BaseListenerConfig {
addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0,0,0,0)), config.environmentd_http_port),
authenticator_kind,
authenticator_kind: http_auth,
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT (style) - I think this could be fewer changes and just as clean.

// SASL authentication is only supported for SQL (PostgreSQL wire protocol).
// HTTP listeners must use Password authentication when SASL is enabled.
// This is validated at environmentd startup via ListenerConfig::validate().
authenticator_kind: if authenticator_kind == AuthenticatorKind::Sasl {
   AuthenticatorKind::Password 
} else {
    authenticator_kind
}

This is fine for now, but I think it would be rather confusing if we introduce SSO/JWT auth.... we may want to allow users to set http and pgwire authenticator kinds separately, but that would require us to more or less completely change how this logic works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion! Thanks Justin!

Comment on lines 1697 to 1699
if matches!(
auth_kind,
AuthenticatorKind::Password | AuthenticatorKind::Sasl
) {
Copy link
Member

Choose a reason for hiding this comment

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

If we are checking this a bunch perhaps at some point we could add a fn authenticated(&self) -> bool to AuthenticatorKind, but fine for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good call! Especially once we start adding SSO/JWT auth, having something like authenticated() will probably make things cleaner. Worth keeping in mind.

@bobbyiliev bobbyiliev force-pushed the orchestratord-scram-auth branch from 96856ee to b15bf4f Compare November 8, 2025 16:48
@bobbyiliev bobbyiliev force-pushed the orchestratord-scram-auth branch from b15bf4f to ba6e97a Compare November 8, 2025 17:00
@bobbyiliev bobbyiliev marked this pull request as ready for review November 8, 2025 17:38
@bobbyiliev bobbyiliev requested review from a team as code owners November 8, 2025 17:38
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.

4 participants