diff --git a/CHANGELOG.md b/CHANGELOG.md index 214b1c7..106b63f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.1] - 2024-09-30 + +### Changed + +- Removed generic lifetime parameter from DapsClient to make the usage easier + ## [0.2.0] - 2024-09-30 ### Changed @@ -14,5 +20,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Moved the CertificatesCache to its own module and added a test for it - Bump dependencies +[0.2.1]: https://github.com///compare/v0.2.0..0.2.1 diff --git a/Cargo.lock b/Cargo.lock index ff48447..a81347d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -783,7 +783,7 @@ dependencies = [ [[package]] name = "ids-daps-client" -version = "0.2.0" +version = "0.2.1" dependencies = [ "async-lock", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 0fd924e..044de79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ edition = "2021" name = "ids-daps-client" description = "A client to connect with the IDS DAPS." -version = "0.2.0" +version = "0.2.1" license = "Apache-2.0" repository = "https://github.com/truzzt/ids-daps-client-rs" readme = "README.md" diff --git a/src/config.rs b/src/config.rs index db1355f..128153b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,6 +3,7 @@ use std::borrow::Cow; /// Configuration for the DAPS client. #[derive(Debug, derive_builder::Builder)] #[builder(setter(into), build_fn(validate = "Self::validate"))] +#[allow(clippy::module_name_repetitions)] pub struct DapsConfig<'a> { /// The URL for the request of a DAPS token. pub(super) token_url: Cow<'a, str>, @@ -46,4 +47,4 @@ impl DapsConfigBuilder<'_> { } Ok(()) } -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 255d035..72998f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,7 @@ //! .expect("Failed to build DAPS-Config"); //! //! // Create DAPS client -//! let client: ReqwestDapsClient<'_> = DapsClient::new(config); +//! let client: ReqwestDapsClient = DapsClient::new(&config); //! //! // Request a DAT token //! let dat = client.request_dat().await?; @@ -68,8 +68,6 @@ pub mod cert; pub mod config; mod http_client; -use std::borrow::Cow; - /// The type of the audience field in the DAT token. It can be a single string or a list of strings. #[derive(Debug, serde::Deserialize, Clone)] #[serde(untagged)] @@ -142,15 +140,15 @@ pub enum DapsError { } /// An alias for the DAPS client using the Reqwest HTTP client. -pub type ReqwestDapsClient<'a> = DapsClient<'a, http_client::reqwest_client::ReqwestDapsClient>; +pub type ReqwestDapsClient = DapsClient; /// The main struct of this crate. It provides the functionality to request and validate DAT tokens /// from a DAPS. -pub struct DapsClient<'a, C> { +pub struct DapsClient { /// The HTTP client to use for requests. It is generic over the actual implementation. client: C, /// The subject of the client. - sub: Cow<'a, str>, + sub: String, /// The URL for the request of the certificates for validation. certs_url: String, /// The URL for the request of a DAPS token. @@ -165,13 +163,13 @@ pub struct DapsClient<'a, C> { certs_cache: cache::CertificatesCache, } -impl DapsClient<'_, C> +impl DapsClient where C: http_client::DapsClientRequest, { /// Creates a new DAPS client based on the given configuration. #[must_use] - pub fn new(config: config::DapsConfig<'_>) -> Self { + pub fn new(config: &config::DapsConfig<'_>) -> Self { // Read sub and private key from file let (ski_aki, private_key) = cert::ski_aki_and_private_key_from_file( config.private_key.as_ref(), @@ -184,7 +182,7 @@ where Self { client: C::default(), - sub: ski_aki, + sub: ski_aki.to_string(), scope: config.scope.to_string(), certs_url: config.certs_url.to_string(), token_url: config.token_url.to_string(), @@ -356,14 +354,14 @@ mod test { .certs_url(certs_url) .token_url(token_url) .private_key(std::path::Path::new("./testdata/connector-certificate.p12")) - .private_key_password(Some(Cow::from("Password1"))) - .scope(Cow::from("idsc:IDS_CONNECTORS_ALL")) + .private_key_password(Some(std::borrow::Cow::from("Password1"))) + .scope(std::borrow::Cow::from("idsc:IDS_CONNECTORS_ALL")) .certs_cache_ttl(1_u64) .build() .expect("Failed to build DAPS-Config"); // Create DAPS client - let client: ReqwestDapsClient<'_> = DapsClient::new(config); + let client: ReqwestDapsClient = DapsClient::new(&config); // Now the test really starts... // Request a DAT token