File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use axum:: { Json , Router , extract:: State , routing:: post} ;
2- use axum_extra:: extract:: { PrivateCookieJar , cookie:: Cookie } ;
2+ use axum_extra:: extract:: {
3+ PrivateCookieJar ,
4+ cookie:: { Cookie , SameSite } ,
5+ } ;
36use time:: OffsetDateTime ;
47
58use super :: register_mfa:: router as register_mfa_router;
@@ -56,7 +59,14 @@ async fn start_enrollment_process(
5659 ) ;
5760 // set session cookie
5861 let cookie = Cookie :: build ( ( ENROLLMENT_COOKIE_NAME , token) )
59- . expires ( OffsetDateTime :: from_unix_timestamp ( response. deadline_timestamp ) . unwrap ( ) ) ;
62+ . expires (
63+ OffsetDateTime :: from_unix_timestamp ( response. deadline_timestamp ) . map_err ( |_| {
64+ ApiError :: Unexpected ( "Invalid enrollment deadline timestamp" . into ( ) )
65+ } ) ?,
66+ )
67+ . http_only ( true )
68+ . same_site ( SameSite :: Strict )
69+ . path ( "/api/v1/enrollment" ) ;
6070
6171 Ok ( ( private_cookies. add ( cookie) , Json ( response) ) )
6272 } else {
Original file line number Diff line number Diff line change 11use axum:: { Json , Router , extract:: State , routing:: post} ;
2- use axum_extra:: extract:: { PrivateCookieJar , cookie:: Cookie } ;
2+ use axum_extra:: extract:: {
3+ PrivateCookieJar ,
4+ cookie:: { Cookie , SameSite } ,
5+ } ;
36use time:: OffsetDateTime ;
47
58use crate :: {
@@ -65,7 +68,14 @@ async fn start_password_reset(
6568 if let core_response:: Payload :: PasswordResetStart ( response) = payload {
6669 // set session cookie
6770 let cookie = Cookie :: build ( ( PASSWORD_RESET_COOKIE_NAME , token) )
68- . expires ( OffsetDateTime :: from_unix_timestamp ( response. deadline_timestamp ) . unwrap ( ) ) ;
71+ . expires (
72+ OffsetDateTime :: from_unix_timestamp ( response. deadline_timestamp ) . map_err ( |_| {
73+ ApiError :: Unexpected ( "Invalid password reset deadline timestamp" . into ( ) )
74+ } ) ?,
75+ )
76+ . http_only ( true )
77+ . same_site ( SameSite :: Strict )
78+ . path ( "/api/v1/password-reset" ) ;
6979
7080 info ! ( "Started password reset process" ) ;
7181 Ok ( ( private_cookies. add ( cookie) , Json ( response) ) )
You can’t perform that action at this time.
0 commit comments