aboutsummaryrefslogtreecommitdiff
path: root/crates/secd/src/command/mod.rs
diff options
context:
space:
mode:
authorbenj <benj@rse8.com>2022-12-30 15:57:36 -0800
committerbenj <benj@rse8.com>2022-12-30 15:57:36 -0800
commit8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3 (patch)
tree1ff85fd9fbd94a5559f9dbac755973fd58b31f28 /crates/secd/src/command/mod.rs
parentf0ea9ecd17b03605d747044874a26e1bd52c0ee1 (diff)
downloadsecdiam-8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3.tar
secdiam-8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3.tar.gz
secdiam-8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3.tar.bz2
secdiam-8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3.tar.lz
secdiam-8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3.tar.xz
secdiam-8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3.tar.zst
secdiam-8ca3433b2a4a82723e00e64b1e5aff0b1bed95b3.zip
impl authZ write and check (depends on spicedb for now)
Diffstat (limited to 'crates/secd/src/command/mod.rs')
-rw-r--r--crates/secd/src/command/mod.rs74
1 files changed, 0 insertions, 74 deletions
diff --git a/crates/secd/src/command/mod.rs b/crates/secd/src/command/mod.rs
deleted file mode 100644
index c14cf6c..0000000
--- a/crates/secd/src/command/mod.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-pub mod authn;
-
-use super::{AuthEmailMessenger, AuthStore, Secd, SecdError};
-use crate::{
- client::{
- email,
- store::sql_db::{PgClient, SqliteClient},
- },
- ENV_AUTH_STORE_CONN_STRING, ENV_EMAIL_MESSENGER, ENV_EMAIL_MESSENGER_CLIENT_ID,
- ENV_EMAIL_MESSENGER_CLIENT_SECRET,
-};
-use log::{error, info};
-use std::{env::var, str::FromStr, sync::Arc};
-
-impl Secd {
- /// init
- ///
- /// Initialize SecD with the specified configuration, established the necessary
- /// constraints, persistance stores, and options.
- pub async fn init() -> Result<Self, SecdError> {
- let auth_store = AuthStore::from(var(ENV_AUTH_STORE_CONN_STRING).ok());
- let email_messenger = AuthEmailMessenger::from_str(
- &var(ENV_EMAIL_MESSENGER).unwrap_or(AuthEmailMessenger::Local.to_string()),
- )
- .expect("unreachable f4ad0f48-0812-427f-b477-0f9c67bb69c5");
- let email_messenger_client_id = var(ENV_EMAIL_MESSENGER_CLIENT_ID).ok();
- let email_messenger_client_secret = var(ENV_EMAIL_MESSENGER_CLIENT_SECRET).ok();
-
- info!("starting client with auth_store: {:?}", auth_store);
- info!("starting client with email_messenger: {:?}", auth_store);
-
- let store = match auth_store {
- AuthStore::Sqlite { conn } => {
- SqliteClient::new(
- sqlx::sqlite::SqlitePoolOptions::new()
- .connect(&conn)
- .await
- .map_err(|e| {
- SecdError::StoreInitFailure(format!("failed to init sqlite: {}", e))
- })?,
- )
- .await
- }
- AuthStore::Postgres { conn } => {
- PgClient::new(
- sqlx::postgres::PgPoolOptions::new()
- .connect(&conn)
- .await
- .map_err(|e| {
- SecdError::StoreInitFailure(format!("failed to init sqlite: {}", e))
- })?,
- )
- .await
- }
- rest @ _ => {
- error!(
- "requested an AuthStore which has not yet been implemented: {:?}",
- rest
- );
- unimplemented!()
- }
- };
-
- let email_sender = match email_messenger {
- AuthEmailMessenger::Local => email::LocalMailer {},
- _ => unimplemented!(),
- };
-
- Ok(Secd {
- store,
- email_messenger: Arc::new(email_sender),
- })
- }
-}