Skip to content

Commit 0764170

Browse files
committed
feat: implement JWT-based authentication and authorization module with token generation, validation, and cookie management.
1 parent bc6d4b4 commit 0764170

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

backend/src/auth.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use chrono::{Duration, Utc};
3333
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
3434
use once_cell::sync::Lazy;
3535
use serde::{Deserialize, Serialize};
36-
use std::collections::HashSet;
3736
use std::env;
37+
use time::{Duration as TimeDuration, OffsetDateTime};
3838

3939
use crate::db::{self, DbPool};
4040

@@ -302,7 +302,7 @@ pub fn build_auth_cookie(token: &str) -> Cookie<'static> {
302302
.path("/")
303303
.http_only(true)
304304
.same_site(SameSite::Lax)
305-
.max_age(cookie::time::Duration::seconds(AUTH_COOKIE_TTL_SECONDS));
305+
.max_age(TimeDuration::seconds(AUTH_COOKIE_TTL_SECONDS));
306306

307307
// Add Secure flag in production (HTTPS only)
308308
if cookies_should_be_secure() {
@@ -332,7 +332,7 @@ pub fn build_cookie_removal() -> Cookie<'static> {
332332
.http_only(true)
333333
.same_site(SameSite::Lax)
334334
.expires(OffsetDateTime::UNIX_EPOCH)
335-
.max_age(cookie::time::Duration::seconds(0));
335+
.max_age(TimeDuration::seconds(0));
336336

337337
// Match security settings of auth cookie
338338
if cookies_should_be_secure() {

0 commit comments

Comments
 (0)