web::login: add form-data CSP rules for localhost

This commit is contained in:
lafleur 2025-08-10 00:02:44 +02:00
commit a536bc4c97

View file

@ -24,10 +24,12 @@ pub struct OidcResponse {
impl IntoResponse for OidcResponse { impl IntoResponse for OidcResponse {
fn into_response(self) -> Response<Body> { fn into_response(self) -> Response<Body> {
let content_csp = match self.nonce { let csp_src = match self.nonce {
| Some(nonce) => &format!("default-src 'nonce-{nonce}'; form-action 'self';"), | Some(nonce) => &format!("default-src 'nonce-{nonce}';"),
| None => "default-src 'none'; form-action 'self';", | None => "default-src 'none';",
}; };
let csp_form_action = "form-action 'self' http://localhost http://127.0.0.1 http://[::1];";
let content_csp = format!("{csp_src} {csp_form_action}");
let content_type = match self.body { let content_type = match self.body {
| Some(OAuthRequestBody::Json(_)) => "application/json", | Some(OAuthRequestBody::Json(_)) => "application/json",
| _ => "text/html", | _ => "text/html",