fixup! fix OidcResponse: reimplement IntoResponse

This commit is contained in:
Jade Ellis 2025-05-11 20:59:03 +01:00
parent 71201c780a
commit bb9e8af4e0
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
3 changed files with 8 additions and 15 deletions

View file

@ -23,7 +23,8 @@
# See the docs for reverse proxying and delegation: # See the docs for reverse proxying and delegation:
# https://continuwuity.org/deploying/generic.html#setting-up-the-reverse-proxy # https://continuwuity.org/deploying/generic.html#setting-up-the-reverse-proxy
# #
# Also see the `[global.auth]` and `[global.well_known]` config sections at the very bottom. # Also see the `[global.auth]` and `[global.well_known]` config sections
# at the very bottom.
# #
# Examples of delegation: # Examples of delegation:
# - https://puppygock.gay/.well-known/matrix/server # - https://puppygock.gay/.well-known/matrix/server

View file

@ -2,10 +2,7 @@ use std::str::FromStr;
use askama::Template; use askama::Template;
use axum::http::StatusCode; use axum::http::StatusCode;
use oxide_auth::{ use oxide_auth::{endpoint::QueryParameter, frontends::simple::request::Body};
endpoint::QueryParameter,
frontends::simple::request::Body,
};
use url::Url; use url::Url;
use super::{AuthorizationQuery, LoginPageTemplate, OidcRequest, OidcResponse}; use super::{AuthorizationQuery, LoginPageTemplate, OidcRequest, OidcResponse};

View file

@ -25,8 +25,8 @@ 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 content_csp = match self.nonce {
| Some(nonce) => &format!("default-src 'nonce-{}'; form-action 'self';", nonce), | Some(nonce) => &format!("default-src 'nonce-{nonce}'; form-action 'self';"),
| None => "default-src 'none'; form-action 'self';" | None => "default-src 'none'; form-action 'self';",
}; };
let content_type = match self.body { let content_type = match self.body {
| Some(OAuthRequestBody::Json(_)) => "application/json", | Some(OAuthRequestBody::Json(_)) => "application/json",
@ -40,14 +40,9 @@ impl IntoResponse for OidcResponse {
response = response.header(header::LOCATION, location.as_str()); response = response.header(header::LOCATION, location.as_str());
} }
// Transform from OAuthRequestBody to String. // Transform from OAuthRequestBody to String.
let body_content = self let body_content = self.body.map(|b| b.as_str().to_owned()).unwrap_or_default();
.body
.map(|b| b.as_str().to_string())
.unwrap_or_default();
response response.body(body_content.into()).unwrap()
.body(body_content.into())
.unwrap()
} }
} }