diff --git a/Cargo.lock b/Cargo.lock index ebb9f5f2..a4331480 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,9 +149,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "aws-lc-rs" @@ -235,9 +235,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.20.2" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "byteorder" @@ -755,7 +755,7 @@ dependencies = [ [[package]] name = "dropshot-authorization-header" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "async-trait", "base64", @@ -806,9 +806,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" [[package]] name = "encoding_rs" @@ -2740,9 +2740,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", @@ -3589,7 +3589,7 @@ dependencies = [ [[package]] name = "v-api" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "anyhow", "async-trait", @@ -3637,7 +3637,7 @@ dependencies = [ [[package]] name = "v-api-param" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "secrecy", "serde", @@ -3648,7 +3648,7 @@ dependencies = [ [[package]] name = "v-api-permission-derive" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "heck", "newtype-uuid", @@ -3665,7 +3665,7 @@ dependencies = [ [[package]] name = "v-cli-sdk" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "anyhow", "clap", @@ -3688,7 +3688,7 @@ dependencies = [ [[package]] name = "v-model" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "async-bb8-diesel", "async-trait", @@ -4282,7 +4282,7 @@ checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" [[package]] name = "xtask" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" dependencies = [ "clap", "regex", diff --git a/Cargo.toml b/Cargo.toml index 76f39a8b..71e49230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ resolver = "2" [workspace.package] publish = true edition = "2024" -version = "0.4.0-alpha.1" +version = "0.4.0-alpha.2" [workspace.dependencies] anyhow = "1.0" diff --git a/v-api-param/src/lib.rs b/v-api-param/src/lib.rs index 842ba826..bb0545d9 100644 --- a/v-api-param/src/lib.rs +++ b/v-api-param/src/lib.rs @@ -22,7 +22,7 @@ use secrecy::SecretString; use serde::Deserialize; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use thiserror::Error; #[derive(Debug, Error)] @@ -54,7 +54,7 @@ impl StringParam { /// /// For inline values, returns the value directly. /// For path-based values, reads the file contents and trims trailing whitespace. - pub fn resolve(&self, base: Option) -> Result { + pub fn resolve(&self, base: Option<&Path>) -> Result { match self { StringParam::Inline(value) => Ok(value.clone()), StringParam::FromPath { path } => { @@ -123,7 +123,7 @@ mod tests { let base_path = std::env::temp_dir(); assert_eq!( - param.resolve(Some(base_path)).unwrap().expose_secret(), + param.resolve(Some(&base_path)).unwrap().expose_secret(), "file-param" ); } diff --git a/v-api/src/config.rs b/v-api/src/config.rs index 0823d05a..bdfccbb6 100644 --- a/v-api/src/config.rs +++ b/v-api/src/config.rs @@ -21,7 +21,7 @@ use serde::{ Deserialize, Deserializer, de::{self, Visitor}, }; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use thiserror::Error; use v_api_param::{ParamResolutionError, StringParam}; use v_model::OAuthClientId; @@ -196,18 +196,10 @@ pub struct OAuthWebProxyConfig { impl OAuthConfig { pub fn resolve( &self, - base: Option, + base: Option<&Path>, ) -> Result { - let device = self - .device - .as_ref() - .map(|d| d.resolve(base.clone())) - .transpose()?; - let web = self - .web - .as_ref() - .map(|w| w.resolve(base.clone())) - .transpose()?; + let device = self.device.as_ref().map(|d| d.resolve(base)).transpose()?; + let web = self.web.as_ref().map(|w| w.resolve(base)).transpose()?; let proxy_web = self .proxy_web .as_ref() @@ -223,7 +215,7 @@ impl OAuthConfig { impl OAuthDeviceConfig { pub fn resolve( &self, - base: Option, + base: Option<&Path>, ) -> Result { let remote_client_secret = self.remote_client_secret.resolve(base)?; Ok(ResolvedOAuthDeviceConfig { @@ -236,7 +228,7 @@ impl OAuthDeviceConfig { impl OAuthWebConfig { pub fn resolve( &self, - base: Option, + base: Option<&Path>, ) -> Result { let remote_client_secret = self.remote_client_secret.resolve(base)?; Ok(ResolvedOAuthWebConfig { @@ -248,7 +240,7 @@ impl OAuthWebConfig { impl OAuthWebProxyConfig { pub fn resolve( &self, - _base: Option, + _base: Option<&Path>, ) -> Result { Ok(ResolvedOAuthWebProxyConfig { client_id: self.client_id, @@ -259,7 +251,7 @@ impl OAuthWebProxyConfig { } impl AsymmetricKey { - pub fn resolve_signer(&self, path: Option) -> Result { + pub fn resolve_signer(&self, path: Option<&Path>) -> Result { Ok(Signer::new( self.kid().to_string(), match self { @@ -279,10 +271,7 @@ impl AsymmetricKey { )) } - pub async fn resolve_verifier( - &self, - path: Option, - ) -> Result { + pub async fn resolve_verifier(&self, path: Option<&Path>) -> Result { Ok(match self { AsymmetricKey::LocalVerifier { .. } => Verifier::Local(LocalVerifyingKey::new( VerifyingKey::new(self.public_key(path)?), @@ -294,7 +283,7 @@ impl AsymmetricKey { }) } - pub fn resolve_jwk(&self, path: Option) -> Result { + pub fn resolve_jwk(&self, path: Option<&Path>) -> Result { let key_id = self.kid(); let public_key = self.public_key(path).map_err(JwtSignerError::InvalidKey)?; @@ -317,7 +306,7 @@ impl AsymmetricKey { }) } - fn public_key(&self, path: Option) -> Result { + fn public_key(&self, path: Option<&Path>) -> Result { Ok(match self { AsymmetricKey::LocalVerifier { public, .. } => { RsaPublicKey::from_public_key_pem(public.resolve(path)?.expose_secret())? diff --git a/v-api/src/context/mod.rs b/v-api/src/context/mod.rs index 9e2888e1..e100a3e7 100644 --- a/v-api/src/context/mod.rs +++ b/v-api/src/context/mod.rs @@ -919,16 +919,16 @@ where let jwks = JwkSet { keys: keys .iter() - .filter_map(|key| key.resolve_jwk(param_path.clone()).ok()) + .filter_map(|key| key.resolve_jwk(param_path.as_deref()).ok()) .collect::>(), }; let signers = keys .iter() - .filter_map(|key| key.resolve_signer(param_path.clone()).ok()) + .filter_map(|key| key.resolve_signer(param_path.as_deref()).ok()) .collect::>(); let verifiers = join_all( keys.iter() - .map(|key| key.resolve_verifier(param_path.clone())), + .map(|key| key.resolve_verifier(param_path.as_deref())), ) .await .into_iter()