feat(auth): add authentication integration
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -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
|
||||
|
@@ -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)]
|
||||
|
@@ -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,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user