-
Notifications
You must be signed in to change notification settings - Fork 468
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
adapter: Prevent login to mz_system externally #14093
Changes from 13 commits
1c8a30c
330430e
8c30970
80826de
4230a90
48848ec
53935c6
d05f40f
9eff207
799d2c0
e087c15
eb23b31
dbf4f15
a1e5ace
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ use tokio::net::TcpListener; | |
use tokio::sync::oneshot; | ||
use tokio_stream::wrappers::TcpListenerStream; | ||
use tower_http::cors::AllowOrigin; | ||
use tracing::error; | ||
|
||
use mz_adapter::catalog::storage::BootstrapArgs; | ||
use mz_adapter::catalog::{ClusterReplicaSizeMap, StorageHostSizeMap}; | ||
|
@@ -39,7 +40,6 @@ use mz_ore::tracing::OpenTelemetryEnableCallback; | |
use mz_persist_client::usage::StorageUsageClient; | ||
use mz_secrets::SecretsController; | ||
use mz_storage::types::connections::ConnectionContext; | ||
use tracing::error; | ||
|
||
use crate::tcp_connection::ConnectionHandler; | ||
|
||
|
@@ -250,22 +250,23 @@ pub async fn serve(config: Config) -> Result<Server, anyhow::Error> { | |
let controller = mz_controller::Controller::new(config.controller).await; | ||
|
||
// Initialize adapter. | ||
let (adapter_handle, adapter_client) = mz_adapter::serve(mz_adapter::Config { | ||
dataflow_client: controller, | ||
storage: adapter_storage, | ||
unsafe_mode: config.unsafe_mode, | ||
build_info: &BUILD_INFO, | ||
metrics_registry: config.metrics_registry.clone(), | ||
now: config.now, | ||
secrets_controller: config.secrets_controller, | ||
cluster_replica_sizes: config.cluster_replica_sizes, | ||
storage_host_sizes: config.storage_host_sizes, | ||
default_storage_host_size: config.default_storage_host_size, | ||
availability_zones: config.availability_zones, | ||
connection_context: config.connection_context, | ||
storage_usage_client, | ||
}) | ||
.await?; | ||
let (adapter_handle, external_adapter_client, internal_adapter_client) = | ||
mz_adapter::serve(mz_adapter::Config { | ||
dataflow_client: controller, | ||
storage: adapter_storage, | ||
unsafe_mode: config.unsafe_mode, | ||
build_info: &BUILD_INFO, | ||
metrics_registry: config.metrics_registry.clone(), | ||
now: config.now, | ||
secrets_controller: config.secrets_controller, | ||
cluster_replica_sizes: config.cluster_replica_sizes, | ||
storage_host_sizes: config.storage_host_sizes, | ||
default_storage_host_size: config.default_storage_host_size, | ||
availability_zones: config.availability_zones, | ||
connection_context: config.connection_context, | ||
storage_usage_client, | ||
}) | ||
.await?; | ||
|
||
// TODO(benesch): replace both `TCPListenerStream`s below with | ||
// `<type>_listener.incoming()` if that is | ||
|
@@ -282,7 +283,7 @@ pub async fn serve(config: Config) -> Result<Server, anyhow::Error> { | |
task::spawn(|| "pgwire_server", { | ||
let pgwire_server = mz_pgwire::Server::new(mz_pgwire::Config { | ||
tls: pgwire_tls, | ||
adapter_client: adapter_client.clone(), | ||
adapter_client: external_adapter_client.clone(), | ||
frontegg: config.frontegg.clone(), | ||
}); | ||
|
||
|
@@ -302,7 +303,7 @@ pub async fn serve(config: Config) -> Result<Server, anyhow::Error> { | |
task::spawn(|| "internal_pgwire_server", { | ||
let internal_pgwire_server = mz_pgwire::Server::new(mz_pgwire::Config { | ||
tls: None, | ||
adapter_client: adapter_client.clone(), | ||
adapter_client: internal_adapter_client, | ||
frontegg: None, | ||
}); | ||
let mut incoming = TcpListenerStream::new(internal_sql_listener); | ||
|
@@ -321,7 +322,7 @@ pub async fn serve(config: Config) -> Result<Server, anyhow::Error> { | |
let http_server = http::Server::new(http::Config { | ||
tls: http_tls, | ||
frontegg: config.frontegg, | ||
adapter_client, | ||
adapter_client: external_adapter_client, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does the internal http server get its internal adapter client? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit perplexing to me. The internal http port uses the
The external http port uses the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, good point! We should move that internal catalog API to the internal HTTP server. |
||
allowed_origin: config.cors_allowed_origin, | ||
}); | ||
let mut incoming = TcpListenerStream::new(http_listener); | ||
|
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.
I think this should start with
mz_
because that's guaranteed to be a protected username suffix.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.
I don't think this is possible because the way this works is that
anonymous_http_user
doesn't exist unless someone tries to use the HTTP API with a username. Then we will createanonymous_http_user
on the spot as a user Role. However we don't allow any user roles to be created with the prefixmz_
because it's a reserved prefix.