feat(auth): add authentication integration
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-20 14:08:40 +02:00
parent 48d09c8ae3
commit e6084a7f4e
13 changed files with 409 additions and 233 deletions

View File

@@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
como_core.workspace = true
como_domain.workspace = true
como_auth.workspace = true
axum.workspace = true
async-trait.workspace = true

View File

@@ -1,4 +1,5 @@
use clap::ValueEnum;
use como_auth::AuthClap;
#[derive(clap::Parser)]
pub struct AppConfig {
@@ -18,6 +19,9 @@ pub struct AppConfig {
pub seed: bool,
#[clap(long, env)]
pub cors_origin: String,
#[clap(flatten)]
pub auth: AuthClap,
}
#[derive(Clone, Debug, ValueEnum)]

View File

@@ -1,6 +1,7 @@
use std::sync::Arc;
use async_sqlx_session::PostgresSessionStore;
use como_auth::AuthService;
use como_core::{items::DynItemService, projects::DynProjectService, users::DynUserService};
use tracing::log::info;
@@ -20,12 +21,15 @@ pub struct ServiceRegister {
pub project_service: DynProjectService,
pub user_service: DynUserService,
pub session_store: PostgresSessionStore,
pub auth_service: AuthService,
}
impl ServiceRegister {
pub async fn new(pool: ConnectionPool, config: Arc<AppConfig>) -> anyhow::Result<Self> {
info!("creating services");
let auth = AuthService::new(&config.auth).await?;
let s = match config.database_type {
DatabaseType::Postgres => {
let item_service =
@@ -42,6 +46,7 @@ impl ServiceRegister {
user_service,
project_service,
session_store: store,
auth_service: auth,
}
}
DatabaseType::InMemory => {
@@ -57,6 +62,7 @@ impl ServiceRegister {
user_service,
project_service,
session_store: store,
auth_service: auth,
}
}
};