diff options
| author | rtkay123 <dev@kanjala.com> | 2026-02-09 19:33:04 +0200 |
|---|---|---|
| committer | rtkay123 <dev@kanjala.com> | 2026-02-09 19:33:04 +0200 |
| commit | 375da0e07f2b3e88c2f6db0e6f4565b3ad555b95 (patch) | |
| tree | dd7e302e7385c4e7cff5021178f127c693bede9d /lib/auth-service/src/client/mod.rs | |
| parent | a9630ecdc459068ca51ee2d7be3837d609840842 (diff) | |
| download | sellershut-375da0e07f2b3e88c2f6db0e6f4565b3ad555b95.tar.bz2 sellershut-375da0e07f2b3e88c2f6db0e6f4565b3ad555b95.zip | |
feat(auth): route to provider
Diffstat (limited to 'lib/auth-service/src/client/mod.rs')
| -rw-r--r-- | lib/auth-service/src/client/mod.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/auth-service/src/client/mod.rs b/lib/auth-service/src/client/mod.rs index 45e7e4d..45260fb 100644 --- a/lib/auth-service/src/client/mod.rs +++ b/lib/auth-service/src/client/mod.rs @@ -1,9 +1,12 @@ -use oauth2::{AuthUrl, ClientId, ClientSecret, EndpointNotSet, EndpointSet, RedirectUrl, TokenUrl}; +use oauth2::{ + AuthUrl, ClientId, ClientSecret, CsrfToken, EndpointNotSet, EndpointSet, RedirectUrl, Scope, + TokenUrl, +}; use secrecy::{ExposeSecret, SecretString}; use tracing::debug; use url::Url; -use crate::AuthServiceError; +use crate::{AuthServiceError, Provider}; #[derive(Debug, Clone)] pub struct OauthClient( @@ -16,6 +19,7 @@ pub struct OauthClient( >, ); +#[derive(Debug)] pub struct ClientConfig { client_id: String, client_secret: SecretString, @@ -63,4 +67,12 @@ impl OauthClient { .set_redirect_uri(RedirectUrl::from_url(url.to_owned())), ) } + + pub fn url_token(&self, provider: Provider) -> (Url, CsrfToken) { + let req = self.0.authorize_url(CsrfToken::new_random); + match provider { + Provider::Discord => req.add_scope(Scope::new("identify".to_string())), + } + .url() + } } |
