From 651adbe3c8601bc40151797a763fca8ebdaaee34 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Mon, 30 Aug 2021 09:54:45 +0200 Subject: [PATCH] model: Inline the BindRequest in the backend --- model/src/lib.rs | 6 ------ src/domain/handler.rs | 12 +++++++++++- src/domain/sql_opaque_handler.rs | 7 +++++-- src/infra/auth_service.rs | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/model/src/lib.rs b/model/src/lib.rs index fe1b067..3125629 100644 --- a/model/src/lib.rs +++ b/model/src/lib.rs @@ -5,12 +5,6 @@ use std::collections::HashSet; pub mod opaque; -#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] -pub struct BindRequest { - pub name: String, - pub password: String, -} - /// The messages for the 3-step OPAQUE login process. pub mod login { use super::*; diff --git a/src/domain/handler.rs b/src/domain/handler.rs index 953949d..bab3de2 100644 --- a/src/domain/handler.rs +++ b/src/domain/handler.rs @@ -1,8 +1,18 @@ use super::error::*; use async_trait::async_trait; +use serde::{Deserialize, Serialize}; use std::collections::HashSet; -pub use lldap_model::*; +pub use lldap_model::{ + AddUserToGroupRequest, CreateGroupRequest, CreateUserRequest, DeleteUserRequest, Group, + ListUsersRequest, RequestFilter, User, UserDetailsRequest, +}; + +#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] +pub struct BindRequest { + pub name: String, + pub password: String, +} #[async_trait] pub trait LoginHandler: Clone + Send { diff --git a/src/domain/sql_opaque_handler.rs b/src/domain/sql_opaque_handler.rs index d5d23ca..8117c96 100644 --- a/src/domain/sql_opaque_handler.rs +++ b/src/domain/sql_opaque_handler.rs @@ -1,9 +1,12 @@ use super::{ - error::*, handler::LoginHandler, opaque_handler::*, sql_backend_handler::SqlBackendHandler, + error::*, + handler::{BindRequest, LoginHandler}, + opaque_handler::*, + sql_backend_handler::SqlBackendHandler, sql_tables::*, }; use async_trait::async_trait; -use lldap_model::{opaque, BindRequest}; +use lldap_model::opaque; use log::*; use sea_query::{Expr, Iden, Query}; use sqlx::Row; diff --git a/src/infra/auth_service.rs b/src/infra/auth_service.rs index b5ab3d3..aadf77b 100644 --- a/src/infra/auth_service.rs +++ b/src/infra/auth_service.rs @@ -1,7 +1,7 @@ use crate::{ domain::{ error::DomainError, - handler::{BackendHandler, LoginHandler}, + handler::{BackendHandler, BindRequest, LoginHandler}, opaque_handler::OpaqueHandler, }, infra::{ @@ -23,7 +23,7 @@ use futures::future::{ok, Ready}; use futures_util::{FutureExt, TryFutureExt}; use hmac::Hmac; use jwt::{SignWithKey, VerifyWithKey}; -use lldap_model::{login, registration, BindRequest, JWTClaims}; +use lldap_model::{login, registration, JWTClaims}; use log::*; use sha2::Sha512; use std::collections::{hash_map::DefaultHasher, HashSet};