Can finalize Matrix authentication
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user