-
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 3 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, info}; | ||
|
||
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, info}; | ||
|
||
use crate::tcp_connection::ConnectionHandler; | ||
|
||
|
@@ -259,22 +259,23 @@ pub async fn serve(config: Config) -> Result<Server, anyhow::Error> { | |
// Initialize controller. | ||
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 | ||
|
@@ -291,7 +292,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(), | ||
}); | ||
|
||
|
@@ -311,7 +312,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); | ||
|
@@ -330,7 +331,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.
Very slight preference for this to be
mz_http_internal_user
because default suggests that it's a fallback and is regularly used on the external http connection.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 is actually only used on the external http connection as a fallback if there's no user authenticated. So maybe it should be
mz_http_default_external_user
?