Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .schema/pgdog.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@
},
"passthrough_auth": {
"description": "Toggle automatic creation of connection pools given the user name, database and password.\n\n_Default:_ `disabled`\n\nhttps://docs.pgdog.dev/configuration/pgdog.toml/general/#passthrough_auth",
"$ref": "#/$defs/PassthoughAuth",
"$ref": "#/$defs/PassthroughAuth",
"default": "disabled"
},
"pooler_mode": {
Expand Down Expand Up @@ -1232,7 +1232,7 @@
"tables"
]
},
"PassthoughAuth": {
"PassthroughAuth": {
"description": "toggle automatic creation of connection pools given the user name, database and password.\n\nSee [passthrough authentication](https://docs.pgdog.dev/features/authentication/#passthrough-authentication).\n\nhttps://docs.pgdog.dev/configuration/pgdog.toml/general/#passthrough_auth",
"oneOf": [
{
Expand Down
2 changes: 1 addition & 1 deletion pgdog-config/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{fmt::Display, str::FromStr};
/// https://docs.pgdog.dev/configuration/pgdog.toml/general/#passthrough_auth
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum PassthoughAuth {
pub enum PassthroughAuth {
/// Passthrough auth is disabled (default).
#[default]
Disabled,
Expand Down
12 changes: 6 additions & 6 deletions pgdog-config/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tracing::{error, info, warn};
use crate::sharding::ShardedSchema;
use crate::util::random_string;
use crate::{
system_catalogs, EnumeratedDatabase, Memory, OmnishardedTable, PassthoughAuth,
system_catalogs, EnumeratedDatabase, Memory, OmnishardedTable, PassthroughAuth,
PreparedStatements, QueryParserEngine, QueryParserLevel, ReadWriteSplit, RewriteMode, Role,
SystemCatalogsBehavior,
};
Expand Down Expand Up @@ -124,7 +124,7 @@ impl ConfigAndUsers {
return Ok(());
}

if self.config.general.passthrough_auth != PassthoughAuth::Disabled {
if self.config.general.passthrough_auth != PassthroughAuth::Disabled {
return Err(Error::ParseError(
"\"passthrough_auth\" must be \"disabled\" when any user has \"server_auth = \\\"rds_iam\\\"\"".into(),
));
Expand Down Expand Up @@ -490,12 +490,12 @@ impl Config {

// Warn about plain auth and TLS
match self.general.passthrough_auth {
PassthoughAuth::Enabled if !self.general.tls_client_required => {
PassthroughAuth::Enabled if !self.general.tls_client_required => {
warn!(
"consider setting \"tls_client_required\" while \"passthrough_auth\" is enabled to prevent clients from exposing plaintext passwords"
);
}
PassthoughAuth::EnabledPlain => {
PassthroughAuth::EnabledPlain => {
warn!(
"\"passthrough_auth\" is set to \"plain\", network traffic may expose plaintext passwords"
)
Expand Down Expand Up @@ -1264,7 +1264,7 @@ shard = 0
#[test]
fn test_rds_iam_rejects_passthrough_auth() {
let mut config = ConfigAndUsers::default();
config.config.general.passthrough_auth = PassthoughAuth::EnabledPlain;
config.config.general.passthrough_auth = PassthroughAuth::EnabledPlain;
config.config.general.tls_verify = TlsVerifyMode::VerifyFull;
config.users.users.push(crate::User {
name: "alice".into(),
Expand All @@ -1283,7 +1283,7 @@ shard = 0
fn test_rds_iam_rejects_tls_verify_disabled() {
let mut config = ConfigAndUsers::default();
config.config.general.tls_verify = TlsVerifyMode::Disabled;
config.config.general.passthrough_auth = PassthoughAuth::Disabled;
config.config.general.passthrough_auth = PassthroughAuth::Disabled;
config.users.users.push(crate::User {
name: "alice".into(),
database: "db".into(),
Expand Down
20 changes: 10 additions & 10 deletions pgdog-config/src/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
SystemCatalogsBehavior,
};

use super::auth::{AuthType, PassthoughAuth};
use super::auth::{AuthType, PassthroughAuth};
use super::database::{LoadBalancingStrategy, ReadWriteSplit, ReadWriteStrategy};
use super::networking::TlsVerifyMode;
use super::pooling::{PoolerMode, PreparedStatements};
Expand Down Expand Up @@ -317,7 +317,7 @@ pub struct General {
///
/// https://docs.pgdog.dev/configuration/pgdog.toml/general/#passthrough_auth
#[serde(default = "General::default_passthrough_auth")]
pub passthrough_auth: PassthoughAuth,
pub passthrough_auth: PassthroughAuth,

/// Maximum amount of time to allow for PgDog to create a connection to Postgres.
///
Expand Down Expand Up @@ -1094,17 +1094,17 @@ impl General {
Self::env_or_default("PGDOG_STATS_PERIOD", 15_000)
}

fn default_passthrough_auth() -> PassthoughAuth {
fn default_passthrough_auth() -> PassthroughAuth {
if let Ok(auth) = env::var("PGDOG_PASSTHROUGH_AUTH") {
// TODO: figure out why toml::from_str doesn't work.
match auth.as_str() {
"enabled" => PassthoughAuth::Enabled,
"disabled" => PassthoughAuth::Disabled,
"enabled_plain" => PassthoughAuth::EnabledPlain,
_ => PassthoughAuth::default(),
"enabled" => PassthroughAuth::Enabled,
"disabled" => PassthroughAuth::Disabled,
"enabled_plain" => PassthroughAuth::EnabledPlain,
_ => PassthroughAuth::default(),
}
} else {
PassthoughAuth::default()
PassthroughAuth::default()
}
}

Expand All @@ -1129,8 +1129,8 @@ impl General {
}

pub fn passthrough_auth(&self) -> bool {
self.tls().is_some() && self.passthrough_auth == PassthoughAuth::Enabled
|| self.passthrough_auth == PassthoughAuth::EnabledPlain
self.tls().is_some() && self.passthrough_auth == PassthroughAuth::Enabled
|| self.passthrough_auth == PassthroughAuth::EnabledPlain
}

/// Support for LISTEN/NOTIFY.
Expand Down
2 changes: 1 addition & 1 deletion pgdog-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod url;
pub mod users;
pub mod util;

pub use auth::{AuthType, PassthoughAuth};
pub use auth::{AuthType, PassthroughAuth};
pub use core::{Config, ConfigAndUsers};
pub use data_types::*;
pub use database::{
Expand Down
2 changes: 1 addition & 1 deletion pgdog/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use general::{General, LogFormat};
pub use memory::*;
pub use networking::{MultiTenant, Tcp, TlsVerifyMode};
pub use overrides::Overrides;
pub use pgdog_config::auth::{AuthType, PassthoughAuth};
pub use pgdog_config::auth::{AuthType, PassthroughAuth};
pub use pgdog_config::{LoadBalancingStrategy, ReadWriteSplit, ReadWriteStrategy};
pub use pooling::{ConnectionRecovery, PoolerMode, PreparedStatements};
pub use rewrite::{Rewrite, RewriteMode};
Expand Down
Loading