mirror of
https://github.com/lldap/lldap.git
synced 2026-03-31 15:07:48 +01:00
server: flatten remaining files
This commit is contained in:
committed by
nitnelave
parent
d38a2cd08b
commit
3556e41612
@@ -88,7 +88,7 @@ impl User {
|
||||
query_path = "queries/create_user.graphql",
|
||||
response_derives = "Debug",
|
||||
variables_derives = "Debug,Clone",
|
||||
custom_scalars_module = "crate::infra::graphql"
|
||||
custom_scalars_module = "crate::graphql"
|
||||
)]
|
||||
struct CreateUser;
|
||||
|
||||
@@ -100,7 +100,7 @@ pub type CreateUserInput = create_user::CreateUserInput;
|
||||
query_path = "queries/create_group.graphql",
|
||||
response_derives = "Debug",
|
||||
variables_derives = "Debug,Clone",
|
||||
custom_scalars_module = "crate::infra::graphql"
|
||||
custom_scalars_module = "crate::graphql"
|
||||
)]
|
||||
struct CreateGroup;
|
||||
|
||||
@@ -109,7 +109,7 @@ struct CreateGroup;
|
||||
schema_path = "../schema.graphql",
|
||||
query_path = "queries/list_users.graphql",
|
||||
response_derives = "Debug",
|
||||
custom_scalars_module = "crate::infra::graphql"
|
||||
custom_scalars_module = "crate::graphql"
|
||||
)]
|
||||
struct ListUsers;
|
||||
|
||||
@@ -118,7 +118,7 @@ struct ListUsers;
|
||||
schema_path = "../schema.graphql",
|
||||
query_path = "queries/list_groups.graphql",
|
||||
response_derives = "Debug",
|
||||
custom_scalars_module = "crate::infra::graphql"
|
||||
custom_scalars_module = "crate::graphql"
|
||||
)]
|
||||
struct ListGroups;
|
||||
|
||||
@@ -364,7 +364,7 @@ pub fn get_lldap_groups(graphql_client: &GraphQLClient) -> Result<Vec<LldapGroup
|
||||
query_path = "queries/add_user_to_group.graphql",
|
||||
response_derives = "Debug",
|
||||
variables_derives = "Debug,Clone",
|
||||
custom_scalars_module = "crate::infra::graphql"
|
||||
custom_scalars_module = "crate::graphql"
|
||||
)]
|
||||
struct AddUserToGroup;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::{
|
||||
use crate::{
|
||||
tcp_backend_handler::*,
|
||||
tcp_server::{AppState, TcpError, TcpResult, error_to_http_response},
|
||||
};
|
||||
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
use strum::{EnumString, IntoStaticStr};
|
||||
use url::Url;
|
||||
|
||||
use crate::infra::database_string::DatabaseUrl;
|
||||
use crate::database_string::DatabaseUrl;
|
||||
|
||||
// Can be deserialized from either a boolean or a string, to facilitate migration.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Default, EnumString, IntoStaticStr)]
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::{
|
||||
use crate::{
|
||||
cli::{
|
||||
GeneralConfigOpts, LdapsOpts, RunOpts, SmtpEncryption, SmtpOpts, TestEmailOpts,
|
||||
TrueFalseAlways,
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::{auth_service::check_if_token_is_valid, tcp_server::AppState};
|
||||
use crate::{auth_service::check_if_token_is_valid, tcp_server::AppState};
|
||||
use actix_web::FromRequest;
|
||||
use actix_web::HttpMessage;
|
||||
use actix_web::{Error, HttpRequest, HttpResponse, error::JsonPayloadError, web};
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::{configuration::LdapsOptions, ldap_server::read_certificates};
|
||||
use crate::{configuration::LdapsOptions, ldap_server::read_certificates};
|
||||
use anyhow::{Context, Result, anyhow, bail, ensure};
|
||||
use futures_util::SinkExt;
|
||||
use ldap3_proto::{
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::configuration::{Configuration, LdapsOptions};
|
||||
use crate::configuration::{Configuration, LdapsOptions};
|
||||
use actix_rt::net::TcpStream;
|
||||
use actix_server::ServerBuilder;
|
||||
use actix_service::{ServiceFactoryExt, fn_service};
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::configuration::Configuration;
|
||||
use crate::configuration::Configuration;
|
||||
use actix_web::{
|
||||
Error,
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::{cli::SmtpEncryption, configuration::MailOptions};
|
||||
use crate::{cli::SmtpEncryption, configuration::MailOptions};
|
||||
use anyhow::{Ok, Result, anyhow};
|
||||
use lettre::{
|
||||
AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor, message::Mailbox,
|
||||
+31
-20
@@ -3,12 +3,26 @@
|
||||
// TODO: Remove next line when it stops warning about async functions.
|
||||
#![allow(clippy::blocks_in_conditions)]
|
||||
|
||||
use crate::infra::{
|
||||
cli::*,
|
||||
mod auth_service;
|
||||
mod cli;
|
||||
mod configuration;
|
||||
mod database_string;
|
||||
mod db_cleaner;
|
||||
mod graphql_server;
|
||||
mod healthcheck;
|
||||
mod jwt_sql_tables;
|
||||
mod ldap_server;
|
||||
mod logging;
|
||||
mod mail;
|
||||
mod sql_tcp_backend_handler;
|
||||
mod tcp_backend_handler;
|
||||
mod tcp_server;
|
||||
|
||||
use crate::{
|
||||
cli::{Command, RunOpts, TestEmailOpts},
|
||||
configuration::{Configuration, compare_private_key_hashes},
|
||||
database_string::DatabaseUrl,
|
||||
db_cleaner::Scheduler,
|
||||
healthcheck, mail,
|
||||
};
|
||||
use actix::Actor;
|
||||
use actix_server::ServerBuilder;
|
||||
@@ -28,8 +42,6 @@ use lldap_domain_handlers::handler::{
|
||||
UserListerBackendHandler, UserRequestFilter,
|
||||
};
|
||||
|
||||
mod infra;
|
||||
|
||||
const ADMIN_PASSWORD_MISSING_ERROR: &str = "The LDAP admin password must be initialized. \
|
||||
Either set the `ldap_user_pass` config value or the `LLDAP_LDAP_USER_PASS` environment variable. \
|
||||
A minimum of 8 characters is recommended.";
|
||||
@@ -107,7 +119,7 @@ async fn setup_sql_tables(database_url: &DatabaseUrl) -> Result<DatabaseConnecti
|
||||
sql_tables::init_table(&sql_pool)
|
||||
.await
|
||||
.context("while creating base tables")?;
|
||||
infra::jwt_sql_tables::init_table(&sql_pool)
|
||||
jwt_sql_tables::init_table(&sql_pool)
|
||||
.await
|
||||
.context("while creating jwt tables")?;
|
||||
Ok(sql_pool)
|
||||
@@ -193,16 +205,15 @@ async fn set_up_server(config: Configuration) -> Result<ServerBuilder> {
|
||||
"Restart the server without --force-update-private-key or --force-ldap-user-pass-reset to continue."
|
||||
);
|
||||
}
|
||||
let server_builder = infra::ldap_server::build_ldap_server(
|
||||
let server_builder = ldap_server::build_ldap_server(
|
||||
&config,
|
||||
backend_handler.clone(),
|
||||
actix_server::Server::build(),
|
||||
)
|
||||
.context("while binding the LDAP server")?;
|
||||
let server_builder =
|
||||
infra::tcp_server::build_tcp_server(&config, backend_handler, server_builder)
|
||||
.await
|
||||
.context("while binding the TCP server")?;
|
||||
let server_builder = tcp_server::build_tcp_server(&config, backend_handler, server_builder)
|
||||
.await
|
||||
.context("while binding the TCP server")?;
|
||||
// Run every hour.
|
||||
let scheduler = Scheduler::new("0 0 * * * * *", sql_pool);
|
||||
scheduler.start();
|
||||
@@ -212,8 +223,8 @@ async fn set_up_server(config: Configuration) -> Result<ServerBuilder> {
|
||||
async fn run_server_command(opts: RunOpts) -> Result<()> {
|
||||
debug!("CLI: {:#?}", &opts);
|
||||
|
||||
let config = infra::configuration::init(opts)?;
|
||||
infra::logging::init(&config)?;
|
||||
let config = configuration::init(opts)?;
|
||||
logging::init(&config)?;
|
||||
|
||||
let server = set_up_server(config).await?.workers(1);
|
||||
|
||||
@@ -222,8 +233,8 @@ async fn run_server_command(opts: RunOpts) -> Result<()> {
|
||||
|
||||
async fn send_test_email_command(opts: TestEmailOpts) -> Result<()> {
|
||||
let to = opts.to.parse()?;
|
||||
let config = infra::configuration::init(opts)?;
|
||||
infra::logging::init(&config)?;
|
||||
let config = configuration::init(opts)?;
|
||||
logging::init(&config)?;
|
||||
|
||||
mail::send_test_email(to, &config.smtp_options)
|
||||
.await
|
||||
@@ -232,8 +243,8 @@ async fn send_test_email_command(opts: TestEmailOpts) -> Result<()> {
|
||||
|
||||
async fn run_healthcheck(opts: RunOpts) -> Result<()> {
|
||||
debug!("CLI: {:#?}", &opts);
|
||||
let config = infra::configuration::init(opts)?;
|
||||
infra::logging::init(&config)?;
|
||||
let config = configuration::init(opts)?;
|
||||
logging::init(&config)?;
|
||||
|
||||
info!("Starting healthchecks");
|
||||
|
||||
@@ -263,8 +274,8 @@ async fn run_healthcheck(opts: RunOpts) -> Result<()> {
|
||||
|
||||
async fn create_schema_command(opts: RunOpts) -> Result<()> {
|
||||
debug!("CLI: {:#?}", &opts);
|
||||
let config = infra::configuration::init(opts)?;
|
||||
infra::logging::init(&config)?;
|
||||
let config = configuration::init(opts)?;
|
||||
logging::init(&config)?;
|
||||
setup_sql_tables(&config.database_url).await?;
|
||||
info!("Schema created successfully.");
|
||||
Ok(())
|
||||
@@ -272,7 +283,7 @@ async fn create_schema_command(opts: RunOpts) -> Result<()> {
|
||||
|
||||
#[actix::main]
|
||||
async fn main() -> Result<()> {
|
||||
let cli_opts = infra::cli::init();
|
||||
let cli_opts = cli::init();
|
||||
match cli_opts.command {
|
||||
Command::ExportGraphQLSchema(opts) => {
|
||||
lldap_graphql_server::api::export_schema(opts.output_file)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::tcp_backend_handler::TcpBackendHandler;
|
||||
use crate::tcp_backend_handler::TcpBackendHandler;
|
||||
use async_trait::async_trait;
|
||||
use chrono::NaiveDateTime;
|
||||
use lldap_domain::types::UserId;
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::infra::{
|
||||
use crate::{
|
||||
auth_service,
|
||||
configuration::{Configuration, MailOptions},
|
||||
logging::CustomRootSpanBuilder,
|
||||
@@ -145,7 +145,7 @@ fn http_config<Backend>(
|
||||
.service(
|
||||
web::scope("/api")
|
||||
.wrap(auth_service::CookieToHeaderTranslatorFactory)
|
||||
.configure(crate::infra::graphql_server::configure_endpoint::<Backend>),
|
||||
.configure(crate::graphql_server::configure_endpoint::<Backend>),
|
||||
)
|
||||
.service(
|
||||
web::resource("/pkg/lldap_app_bg.wasm.gz")
|
||||
Reference in New Issue
Block a user