Can finalize Matrix authentication

This commit is contained in:
2025-11-05 19:32:11 +01:00
parent 37fad9ff55
commit 1eaec9d319
13 changed files with 180 additions and 18 deletions

View File

@@ -11,6 +11,8 @@ use anyhow::Context;
use bytes::Bytes;
use jwt_simple::common::VerificationOptions;
use jwt_simple::prelude::{Duration, HS256Key, MACLike};
use jwt_simple::reexports::serde_json;
use serde::de::DeserializeOwned;
use sha2::{Digest, Sha256};
use std::fmt::Display;
use std::net::IpAddr;
@@ -32,6 +34,16 @@ pub struct AuthExtractor {
pub payload: Option<Vec<u8>>,
}
impl AuthExtractor {
pub fn decode_json_body<E: DeserializeOwned + Send>(&self) -> anyhow::Result<E> {
let payload = self
.payload
.as_ref()
.context("Failed to decode request as json: missing payload!")?;
serde_json::from_slice(payload).context("Failed to decode request json!")
}
}
#[derive(Debug, Eq, PartialEq)]
pub struct MatrixJWTKID {
pub user_email: UserEmail,