Skip to content

Commit

Permalink
Clean fly.toml and fix session cookie settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMoolenaar committed Mar 11, 2024
1 parent bbaf887 commit bb44c0b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 34 deletions.
52 changes: 21 additions & 31 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,28 @@ kill_timeout = '5s'
[build]

[env]
PORT = '8080'

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[services]]
protocol = 'tcp'
internal_port = 8080

[[services.ports]]
port = 80
handlers = ['http']

[[services.ports]]
port = 443
handlers = ['tls', 'http']

[services.concurrency]
hard_limit = 25
soft_limit = 20

[[services.tcp_checks]]
interval = '15s'
timeout = '2s'
grace_period = '1s'
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[http_service.concurrency]
hard_limit = 250
soft_limit = 200

[[http_service.checks]]
interval = "20s"
grace_period = "5s"
method = "get"
path = "/"
protocol = "http"
timeout = "2s"

[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 256
cpu_kind = 'shared'
cpus = 1
memory_mb = 256
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ async fn main() {
.await
.expect("Could not run migrations");

// Setup session store
let session_store = PostgresStore::new(db_pool.clone());
session_store.migrate().await.expect("Could not migrate session store");
tokio::task::spawn(
session_store
.clone()
.continuously_delete_expired(Duration::from_secs(60)),
);

let session_layer = ServiceBuilder::new().layer(
SessionManagerLayer::new(session_store)
.with_secure(false)
.with_http_only(true)
.with_same_site(SameSite::Strict)
.with_same_site(SameSite::Lax)
.with_expiry(Expiry::OnInactivity(time::Duration::days(7))),
);

Expand Down
2 changes: 1 addition & 1 deletion templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="text-5xl font-bold mb-8">Login</h1>
<form hx-post="/login" hx-disabled-elt="find button" hx-target="#content" hx-target-401="#errors" class="mb-8" hx-on:htmx-before-send="let x = document.querySelector('#errors .alert'); x && x.remove()">
<div class="mb-4">
<label target="email" class="label">Email</label>
<input id="email" type="email" class="input input-bordered w-full max-w-xs" name="email" value="{{ values.email if values }}" required />
<input id="email" type="email" class="input input-bordered w-full max-w-xs" name="email" value="{{ values.email if values }}" required autofocus />
</div>
<div class="mb-4">
<label target="password" class="label">Password</label>
Expand Down

0 comments on commit bb44c0b

Please sign in to comment.