Move the JWTClaims to the model

This commit is contained in:
Valentin Tolmer 2021-05-13 19:32:29 +02:00
parent b49a03fd87
commit a15d970725
2 changed files with 9 additions and 8 deletions

View File

@ -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<String>,
}
#[derive(Clone, Serialize, Deserialize)]
pub struct JWTClaims {
pub exp: DateTime<Utc>,
pub user: String,
pub groups: HashSet<String>,
}

View File

@ -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<S> = jwt::Token<jwt::Header, JWTClaims, S>;
type SignedToken = Token<jwt::token::Signed>;
#[derive(Serialize, Deserialize)]
struct JWTClaims {
exp: DateTime<Utc>,
user: String,
groups: HashSet<String>,
}
async fn index(req: HttpRequest) -> actix_web::Result<NamedFile> {
let mut path = PathBuf::new();
path.push("app");