From a15d9707252e7b4e3e4b5b8e617f89cd72bd828f Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Thu, 13 May 2021 19:32:29 +0200 Subject: [PATCH] Move the JWTClaims to the model --- model/src/lib.rs | 9 +++++++++ src/infra/tcp_server.rs | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/model/src/lib.rs b/model/src/lib.rs index b66b30b..408b198 100644 --- a/model/src/lib.rs +++ b/model/src/lib.rs @@ -1,4 +1,6 @@ use serde::{Deserialize, Serialize}; +use chrono::prelude::*; +use std::collections::HashSet; #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] pub struct BindRequest { @@ -36,3 +38,10 @@ pub struct Group { pub display_name: String, pub users: Vec, } + +#[derive(Clone, Serialize, Deserialize)] +pub struct JWTClaims { + pub exp: DateTime, + pub user: String, + pub groups: HashSet, +} diff --git a/src/infra/tcp_server.rs b/src/infra/tcp_server.rs index 67e6f33..0f01155 100644 --- a/src/infra/tcp_server.rs +++ b/src/infra/tcp_server.rs @@ -18,7 +18,6 @@ use futures_util::TryFutureExt; use hmac::{Hmac, NewMac}; use jwt::{SignWithKey, VerifyWithKey}; use log::*; -use serde::{Deserialize, Serialize}; use sha2::Sha512; use std::collections::HashSet; use std::path::PathBuf; @@ -27,13 +26,6 @@ use time::ext::NumericalDuration; type Token = jwt::Token; type SignedToken = Token; -#[derive(Serialize, Deserialize)] -struct JWTClaims { - exp: DateTime, - user: String, - groups: HashSet, -} - async fn index(req: HttpRequest) -> actix_web::Result { let mut path = PathBuf::new(); path.push("app");