Fix sessions persisting across server restart

Need a non-random session secret.
This commit is contained in:
Tyler Hallada 2023-10-07 00:54:15 -04:00
parent 609f6d3d9f
commit d5c5185351
3 changed files with 4 additions and 1 deletions

View File

@ -67,6 +67,7 @@ builds
SMTP_USER=user
SMTP_PASSWORD=password
EMAIL_FROM="crawlnicle <no-reply@mail.crawlnicle.com>"
SESSION_SECRET=64-bytes-of-secret
```
1. Run `just migrate` (or `sqlx migrate run`) which will run all the database

View File

@ -30,4 +30,6 @@ pub struct Config {
pub smtp_password: String,
#[clap(long, env)]
pub email_from: Mailbox,
#[clap(long, env)]
pub session_secret: String,
}

View File

@ -67,7 +67,7 @@ async fn main() -> Result<()> {
let domain_locks = DomainLocks::new();
let client = Client::builder().user_agent(USER_AGENT).build()?;
let secret = rand::thread_rng().gen::<[u8; 64]>();
let secret = config.session_secret.as_bytes();
let pool = PgPoolOptions::new()
.max_connections(config.database_max_connections)