aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrtkay123 <dev@kanjala.com>2026-02-02 13:30:25 +0200
committerrtkay123 <dev@kanjala.com>2026-02-02 13:30:25 +0200
commit549d98f3b457ddfc6dffbe2fad406da4ac50ebc7 (patch)
treed1563d048eb7600f0f1265766efffb2797280051 /lib
parente06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c (diff)
downloadsellershut-549d98f3b457ddfc6dffbe2fad406da4ac50ebc7.tar.bz2
sellershut-549d98f3b457ddfc6dffbe2fad406da4ac50ebc7.zip
refactor: collapse auth
Diffstat (limited to 'lib')
-rw-r--r--lib/auth/Cargo.toml13
-rw-r--r--lib/auth/src/lib.rs41
2 files changed, 0 insertions, 54 deletions
diff --git a/lib/auth/Cargo.toml b/lib/auth/Cargo.toml
deleted file mode 100644
index 0852935..0000000
--- a/lib/auth/Cargo.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-[package]
-name = "sellershut-auth"
-version = "0.1.0"
-edition = "2024"
-license.workspace = true
-documentation.workspace = true
-
-[dependencies]
-bon.workspace = true
-oauth2.workspace = true
-secrecy.workspace = true
-thiserror.workspace = true
-url.workspace = true
diff --git a/lib/auth/src/lib.rs b/lib/auth/src/lib.rs
deleted file mode 100644
index 2a1390e..0000000
--- a/lib/auth/src/lib.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-use bon::Builder;
-use oauth2::{AuthUrl, ClientId, ClientSecret, EndpointNotSet, EndpointSet, RedirectUrl, TokenUrl};
-use secrecy::{ExposeSecret, SecretString};
-use thiserror::Error;
-
-#[derive(Builder)]
-pub struct ClientOptions {
- client_id: String,
- client_secret: SecretString,
- token_url: String,
- auth_url: String,
- redirect_url: String,
-}
-
-#[derive(Error, Debug)]
-pub enum OauthError {
- #[error("invalid url")]
- InvalidUrl(#[from] url::ParseError),
-}
-
-pub type OauthClient = oauth2::basic::BasicClient<
- EndpointSet,
- EndpointNotSet,
- EndpointNotSet,
- EndpointNotSet,
- EndpointSet,
->;
-
-pub fn oauth_client(opts: &ClientOptions) -> Result<OauthClient, OauthError> {
- let redirect_url = RedirectUrl::new(opts.redirect_url.to_owned())?;
- let client_id = ClientId::new(opts.client_id.to_owned());
- let auth_url = AuthUrl::new(opts.auth_url.to_owned())?;
- let token_url = TokenUrl::new(opts.token_url.to_owned())?;
- let client_secret = ClientSecret::new(opts.client_secret.expose_secret().to_string());
-
- Ok(oauth2::basic::BasicClient::new(client_id)
- .set_client_secret(client_secret)
- .set_auth_uri(auth_url)
- .set_token_uri(token_url)
- .set_redirect_uri(redirect_url))
-}