aboutsummaryrefslogtreecommitdiffstats
path: root/lib/auth-service/src/client/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/auth-service/src/client/mod.rs')
-rw-r--r--lib/auth-service/src/client/mod.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/auth-service/src/client/mod.rs b/lib/auth-service/src/client/mod.rs
index 25cf16c..af581b0 100644
--- a/lib/auth-service/src/client/mod.rs
+++ b/lib/auth-service/src/client/mod.rs
@@ -22,18 +22,34 @@ pub struct ClientConfig {
auth_url: Url,
}
+impl ClientConfig {
+ pub fn new(
+ client_id: String,
+ client_secret: SecretString,
+ token_url: Url,
+ auth_url: Url,
+ ) -> Self {
+ Self {
+ client_id,
+ client_secret,
+ token_url,
+ auth_url,
+ }
+ }
+}
+
impl TryFrom<ClientConfig> for OauthClient {
type Error = AuthServiceError;
fn try_from(value: ClientConfig) -> Result<Self, Self::Error> {
debug!("creating oauth client");
Ok(Self(
- oauth2::basic::BasicClient::new(ClientId::new(value.client_id))
+ oauth2::basic::BasicClient::new(ClientId::new(value.client_id.to_string()))
.set_client_secret(ClientSecret::new(
value.client_secret.expose_secret().to_string(),
))
- .set_auth_uri(AuthUrl::from_url(value.auth_url))
- .set_token_uri(TokenUrl::from_url(value.token_url)),
+ .set_auth_uri(AuthUrl::from_url(value.auth_url.to_owned()))
+ .set_token_uri(TokenUrl::from_url(value.token_url.to_owned())),
))
}
}