| 1 |
|
| 2 |
|
| 3 |
mod account; |
| 4 |
mod acknowledge; |
| 5 |
mod links; |
| 6 |
mod password; |
| 7 |
|
| 8 |
use axum::routing::get; |
| 9 |
use tower_governor::GovernorLayer; |
| 10 |
|
| 11 |
use crate::{ |
| 12 |
AppState, constants, |
| 13 |
csrf::{CsrfRouter, post_csrf_skip, with_csrf, with_csrf_skip}, |
| 14 |
helpers::rate_limiter_ms, |
| 15 |
}; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
pub(super) fn email_action_routes(limits: constants::RateLimits) -> CsrfRouter<AppState> { |
| 42 |
let auth_rate_limit = rate_limiter_ms(limits.auth_ms, limits.auth_burst); |
| 43 |
|
| 44 |
CsrfRouter::new() |
| 45 |
.route( |
| 46 |
"/forgot-password", |
| 47 |
with_csrf(get(password::forgot_password_page).post(password::forgot_password_handler)), |
| 48 |
) |
| 49 |
.route( |
| 50 |
"/reset-password", |
| 51 |
with_csrf_skip( |
| 52 |
"signed link: user/expires/sig HMAC re-validated in handler", |
| 53 |
get(password::reset_password_page).post(password::reset_password_handler), |
| 54 |
), |
| 55 |
) |
| 56 |
.route_get("/verify-email", get(links::verify_email_handler)) |
| 57 |
.route_get("/login-link", get(links::login_link_handler)) |
| 58 |
.route( |
| 59 |
"/confirm-delete", |
| 60 |
with_csrf_skip( |
| 61 |
"signed link: user/expires/sig HMAC re-validated in handler", |
| 62 |
get(account::confirm_delete_page).post(account::confirm_delete_handler), |
| 63 |
), |
| 64 |
) |
| 65 |
.route( |
| 66 |
"/unsubscribe", |
| 67 |
with_csrf_skip( |
| 68 |
"signed link: sig HMAC verified in handler", |
| 69 |
get(account::unsubscribe_page).post(account::unsubscribe_handler), |
| 70 |
), |
| 71 |
) |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
.route( |
| 77 |
"/unsubscribe/list", |
| 78 |
post_csrf_skip( |
| 79 |
"signed link: sig HMAC verified in handler", |
| 80 |
account::preferences_toggle, |
| 81 |
), |
| 82 |
) |
| 83 |
.route( |
| 84 |
"/unsubscribe/all", |
| 85 |
post_csrf_skip( |
| 86 |
"signed link: sig HMAC verified in handler", |
| 87 |
account::preferences_unsubscribe_all, |
| 88 |
), |
| 89 |
) |
| 90 |
.route( |
| 91 |
"/acknowledge/{token}", |
| 92 |
with_csrf_skip( |
| 93 |
"signed link: the token is an HMAC over the signing secret", |
| 94 |
get(acknowledge::acknowledge_page).post(acknowledge::acknowledge_handler), |
| 95 |
), |
| 96 |
) |
| 97 |
.layer(GovernorLayer::new(auth_rate_limit)) |
| 98 |
} |
| 99 |
|