mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
add cookie expiration
This commit is contained in:
committed by
Aiden McClelland
parent
281dde2462
commit
e1c123c4e3
@@ -26,6 +26,19 @@ pub fn parse_metadata(_: &str, _: &ArgMatches<'_>) -> Result<Value, Error> {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn gen_pwd() {
|
||||||
|
println!(
|
||||||
|
"{:?}",
|
||||||
|
argon2::hash_encoded(
|
||||||
|
b"testing1234",
|
||||||
|
&rand::random::<[u8; 16]>()[..],
|
||||||
|
&argon2::Config::default()
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[command(display(display_none), metadata(authenticated = false))]
|
#[command(display(display_none), metadata(authenticated = false))]
|
||||||
pub async fn login(
|
pub async fn login(
|
||||||
#[context] ctx: EitherContext,
|
#[context] ctx: EitherContext,
|
||||||
@@ -69,8 +82,11 @@ pub async fn login(
|
|||||||
.await?;
|
.await?;
|
||||||
res.headers.insert(
|
res.headers.insert(
|
||||||
"set-cookie",
|
"set-cookie",
|
||||||
HeaderValue::from_str(&format!("session={}; HttpOnly; SameSite=Strict", token))
|
HeaderValue::from_str(&format!(
|
||||||
.with_kind(crate::ErrorKind::Unknown)?, // Should be impossible, but don't want to panic
|
"session={}; HttpOnly; SameSite=Strict; Expires=Fri, 31 Dec 9999 23:59:59 GMT;",
|
||||||
|
token
|
||||||
|
))
|
||||||
|
.with_kind(crate::ErrorKind::Unknown)?, // Should be impossible, but don't want to panic
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user