Better datastores security
Localhost only exposed ports and stronger password for Postgres local environment instance
This commit is contained in:
2
.env
2
.env
@@ -1 +1 @@
|
||||
DATABASE_URL="postgres://postgres:password@localhost:5432/newsletter"
|
||||
DATABASE_URL="postgres://postgres:Jq09NF6Y8ZXJS4jd9c8U@localhost:5432/newsletter"
|
||||
|
||||
@@ -7,7 +7,7 @@ database:
|
||||
port: 5432
|
||||
database_name: "newsletter"
|
||||
username: "postgres"
|
||||
password: "password"
|
||||
password: "Jq09NF6Y8ZXJS4jd9c8U"
|
||||
require_ssl: false
|
||||
email_client:
|
||||
authorization_token: "secret-token"
|
||||
|
||||
@@ -14,7 +14,7 @@ if ! [ -x "$(command -v sqlx)" ]; then
|
||||
fi
|
||||
|
||||
DB_USER="${POSTGRES_USER:=postgres}"
|
||||
DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
|
||||
DB_PASSWORD="${POSTGRES_PASSWORD:=Jq09NF6Y8ZXJS4jd9c8U}"
|
||||
DB_NAME="${POSTGRES_DB:=newsletter}"
|
||||
DB_PORT="${POSTGRES_PORT:=5432}"
|
||||
DB_HOST="${POSTGRES_HOST:=localhost}"
|
||||
@@ -24,7 +24,7 @@ if [[ -z "${SKIP_DOCKER}" ]]; then
|
||||
-e POSTGRES_USER=${DB_USER} \
|
||||
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
|
||||
-e POSTGRES_DB=${DB_NAME} \
|
||||
-p "${DB_PORT}":5432 \
|
||||
-p "127.0.0.1:${DB_PORT}":5432 \
|
||||
-d postgres \
|
||||
postgres -N 1000
|
||||
fi
|
||||
|
||||
@@ -10,7 +10,7 @@ if [[ -n $RUNNING_CONTAINER ]]; then
|
||||
fi
|
||||
|
||||
docker run \
|
||||
-p "6379:6379" \
|
||||
-p "127.0.0.1:6379:6379" \
|
||||
-d \
|
||||
--name "redis_$(date '+%s')" \
|
||||
redis
|
||||
|
||||
@@ -142,28 +142,3 @@ fn validate_form(form: &BodyData) -> Result<(), &'static str> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// struct ConfirmedSubscriber {
|
||||
// name: String,
|
||||
// email: SubscriberEmail,
|
||||
// }
|
||||
|
||||
// #[tracing::instrument(name = "Get confirmed subscribers", skip(connection_pool))]
|
||||
// async fn get_confirmed_subscribers(
|
||||
// connection_pool: &PgPool,
|
||||
// ) -> Result<Vec<Result<ConfirmedSubscriber, anyhow::Error>>, anyhow::Error> {
|
||||
// let rows = sqlx::query!("SELECT name, email FROM subscriptions WHERE status = 'confirmed'")
|
||||
// .fetch_all(connection_pool)
|
||||
// .await?;
|
||||
// let confirmed_subscribers = rows
|
||||
// .into_iter()
|
||||
// .map(|r| match SubscriberEmail::parse(r.email) {
|
||||
// Ok(email) => Ok(ConfirmedSubscriber {
|
||||
// name: r.name,
|
||||
// email,
|
||||
// }),
|
||||
// Err(e) => Err(anyhow::anyhow!(e)),
|
||||
// })
|
||||
// .collect();
|
||||
// Ok(confirmed_subscribers)
|
||||
// }
|
||||
|
||||
@@ -40,7 +40,6 @@ impl Application {
|
||||
"{}:{}",
|
||||
configuration.application.host, configuration.application.port
|
||||
);
|
||||
// let listener = TcpListener::bind(address).await?;
|
||||
let connection_pool =
|
||||
PgPoolOptions::new().connect_lazy_with(configuration.database.with_db());
|
||||
let email_client = EmailClient::build(configuration.email_client).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user