BLOG-45 fix: percent encode the database password
All checks were successful
Frontend CI / build (push) Successful in 1m16s
All checks were successful
Frontend CI / build (push) Successful in 1m16s
This commit is contained in:
parent
23c312a9db
commit
77459ebd71
1
backend/Cargo.lock
generated
1
backend/Cargo.lock
generated
@ -1789,6 +1789,7 @@ dependencies = [
|
|||||||
"actix-web",
|
"actix-web",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
"percent-encoding",
|
||||||
"post",
|
"post",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
]
|
]
|
||||||
|
@ -14,6 +14,7 @@ dotenv = "0.15.0"
|
|||||||
env_logger = "0.11.8"
|
env_logger = "0.11.8"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
|
percent-encoding = "2.3.1"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
sqlx = { version = "0.8.5", features = [
|
sqlx = { version = "0.8.5", features = [
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -7,6 +7,7 @@ edition.workspace = true
|
|||||||
actix-web.workspace = true
|
actix-web.workspace = true
|
||||||
dotenv.workspace = true
|
dotenv.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
|
percent-encoding.workspace = true
|
||||||
sqlx.workspace = true
|
sqlx.workspace = true
|
||||||
|
|
||||||
post.workspace = true
|
post.workspace = true
|
||||||
|
@ -34,9 +34,13 @@ async fn init_database() -> Pool<Postgres> {
|
|||||||
let user = env::var("DATABASE_USER").unwrap_or_else(|_| "postgres".to_string());
|
let user = env::var("DATABASE_USER").unwrap_or_else(|_| "postgres".to_string());
|
||||||
let password = env::var("DATABASE_PASSWORD").unwrap_or_else(|_| "".to_string());
|
let password = env::var("DATABASE_PASSWORD").unwrap_or_else(|_| "".to_string());
|
||||||
let dbname = env::var("DATABASE_NAME").unwrap_or_else(|_| "postgres".to_string());
|
let dbname = env::var("DATABASE_NAME").unwrap_or_else(|_| "postgres".to_string());
|
||||||
|
|
||||||
|
let encoded_password =
|
||||||
|
percent_encoding::utf8_percent_encode(&password, percent_encoding::NON_ALPHANUMERIC)
|
||||||
|
.to_string();
|
||||||
let database_url = format!(
|
let database_url = format!(
|
||||||
"postgres://{}:{}@{}:{}/{}",
|
"postgres://{}:{}@{}:{}/{}",
|
||||||
user, password, host, port, dbname
|
user, encoded_password, host, port, dbname
|
||||||
);
|
);
|
||||||
|
|
||||||
let db_pool = PgPoolOptions::new()
|
let db_pool = PgPoolOptions::new()
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
const { postInfo }: { postInfo: PostInfoViewModel } = $props();
|
const { postInfo }: { postInfo: PostInfoViewModel } = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-y-4 pt-9 md:pt-20">
|
<div class="flex flex-col pt-9 md:pt-20">
|
||||||
<div class="flex flex-row gap-2">
|
<div class="mb-6 flex flex-row gap-2">
|
||||||
{#each postInfo.labels as label (label.id)}
|
{#each postInfo.labels as label (label.id)}
|
||||||
<Label {label} />
|
<Label {label} />
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { page } from '$app/state';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="mx-auto flex min-h-content-height max-w-screen-xl flex-col items-center justify-center px-4 md:px-6"
|
class="mx-auto flex min-h-content-height max-w-screen-xl flex-col items-center justify-center px-4 md:px-6"
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user