diff options
| author | benj <benj@rse8.com> | 2022-11-25 16:42:16 -0800 |
|---|---|---|
| committer | benj <benj@rse8.com> | 2022-11-25 16:42:16 -0800 |
| commit | aa8c20d501b58001a5e1b24964c62363e2112ff8 (patch) | |
| tree | 82e53aa5efd6e0a96e8c436655c083de617a6131 /src/client/mod.rs | |
| parent | fcd972fd9ae7579724b0ba9b401ceb729e6e0108 (diff) | |
| download | secdiam-aa8c20d501b58001a5e1b24964c62363e2112ff8.tar secdiam-aa8c20d501b58001a5e1b24964c62363e2112ff8.tar.gz secdiam-aa8c20d501b58001a5e1b24964c62363e2112ff8.tar.bz2 secdiam-aa8c20d501b58001a5e1b24964c62363e2112ff8.tar.lz secdiam-aa8c20d501b58001a5e1b24964c62363e2112ff8.tar.xz secdiam-aa8c20d501b58001a5e1b24964c62363e2112ff8.tar.zst secdiam-aa8c20d501b58001a5e1b24964c62363e2112ff8.zip | |
some shell is coming together and a rough API
Diffstat (limited to 'src/client/mod.rs')
| -rw-r--r-- | src/client/mod.rs | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs new file mode 100644 index 0000000..bb32e2c --- /dev/null +++ b/src/client/mod.rs @@ -0,0 +1,81 @@ +pub mod sqldb; + +use thiserror::Error; +use uuid::Uuid; + +use super::Identity; + +#[derive(Error, Debug)] +pub enum StoreError { + #[error("sqlx client error")] + SqlxError(#[from] sqlx::Error), + #[error( + "More than one oauth provider identified, but no client_id was provided for disambiguation" + )] + TooManyOauthProviders, + #[error("Oath provider not registered. First register the Oauth provider before executing")] + OauthProviderNotRegistered, + #[error("An unknown error occurred")] + Unknown, +} + +#[async_trait::async_trait] +pub trait Store { + // async fn read_oauth_authorization_location( + // &self, + // provider: OauthProvider, + // client_id: Option<OauthClientId>, + // ) -> Result<String, StoreError>; + + // async fn write_oauth_authorization_request( + // &self, + // identity_id: Uuid, + // provider: OauthProvider, + // raw: String, + // state: String, + // ) -> Result<(), StoreError>; + + // async fn write_oauth_provider( + // &self, + // provider: OauthProvider, + // consent_uri: OauthConsentUri, + // client_id: OauthClientId, + // client_secret: OauthClientSecretEncrypted, + // redirect_uri: String, + // ) -> Result<(), StoreError>; + + // fn read_email_challenge(&self) -> Result<T, StoreError>; + // fn write_email_challenge(&self) -> Result<T, StoreError>; + + async fn write_email(&self, id: Uuid, email_address: &str) -> Result<(), StoreError>; + async fn write_email_validation_request( + &self, + id: Uuid, + email_address: &str, + ) -> Result<Uuid, StoreError>; + + async fn find_identity( + &self, + id: Option<&Uuid>, + email: Option<&str>, + ) -> Result<Option<Identity>, StoreError>; + async fn write_identity(&self, i: &Identity) -> Result<(), StoreError>; + async fn read_identity(&self, id: &Uuid) -> Result<Identity, StoreError>; + + // fn read_sms_challenge(&self) -> Result<T, StoreError>; + // fn write_sms_challenge(&self) -> Result<T, StoreError>; +} + +// #[derive(sqlx::FromRow, Debug)] +// struct Identity { +// #[sqlx(rename = "identity_public_id")] +// id: Uuid, +// } + +// #[derive(sqlx::FromRow, Debug)] +// struct OauthProviderRecord { +// consent_uri: String, +// client_id: OauthClientId, +// client_secret_encrypted: OauthClientSecretEncrypted, +// redirect_uri: String, +// } |
