From 2bca19be64a5da777351c59d564a2a6e3373018d Mon Sep 17 00:00:00 2001 From: perillamint Date: Wed, 22 Mar 2023 15:42:07 +0900 Subject: [PATCH] Remove 'static lifetime requirement (#8) Co-authored-by: Yonghyu Ban --- jwt-authorizer/src/authorizer.rs | 4 ++-- jwt-authorizer/src/layer.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jwt-authorizer/src/authorizer.rs b/jwt-authorizer/src/authorizer.rs index 78e8ef8..1fca247 100644 --- a/jwt-authorizer/src/authorizer.rs +++ b/jwt-authorizer/src/authorizer.rs @@ -51,7 +51,7 @@ pub enum KeySourceType { RSA(String), EC(String), ED(String), - Secret(&'static str), + Secret(String), Jwks(String), JwksString(String), // TODO: expose JwksString in JwtAuthorizer or remove it Discovery(String), @@ -180,7 +180,7 @@ mod tests { #[tokio::test] async fn build_from_secret() { let h = Header::new(Algorithm::HS256); - let a = Authorizer::::build(&KeySourceType::Secret("xxxxxx"), None, None, Validation::new()) + let a = Authorizer::::build(&KeySourceType::Secret("xxxxxx".to_owned()), None, None, Validation::new()) .await .unwrap(); let k = a.key_source.get_key(h); diff --git a/jwt-authorizer/src/layer.rs b/jwt-authorizer/src/layer.rs index 5f3dc6c..fa2bd36 100644 --- a/jwt-authorizer/src/layer.rs +++ b/jwt-authorizer/src/layer.rs @@ -50,7 +50,7 @@ where } /// Builds Authorizer Layer from a JWKS endpoint - pub fn from_jwks_url(url: &'static str) -> JwtAuthorizer { + pub fn from_jwks_url(url: &str) -> JwtAuthorizer { JwtAuthorizer { key_source_type: KeySourceType::Jwks(url.to_owned()), refresh: Default::default(), @@ -60,7 +60,7 @@ where } /// Builds Authorizer Layer from a RSA PEM file - pub fn from_rsa_pem(path: &'static str) -> JwtAuthorizer { + pub fn from_rsa_pem(path: &str) -> JwtAuthorizer { JwtAuthorizer { key_source_type: KeySourceType::RSA(path.to_owned()), refresh: Default::default(), @@ -70,7 +70,7 @@ where } /// Builds Authorizer Layer from a EC PEM file - pub fn from_ec_pem(path: &'static str) -> JwtAuthorizer { + pub fn from_ec_pem(path: &str) -> JwtAuthorizer { JwtAuthorizer { key_source_type: KeySourceType::EC(path.to_owned()), refresh: Default::default(), @@ -80,7 +80,7 @@ where } /// Builds Authorizer Layer from a EC PEM file - pub fn from_ed_pem(path: &'static str) -> JwtAuthorizer { + pub fn from_ed_pem(path: &str) -> JwtAuthorizer { JwtAuthorizer { key_source_type: KeySourceType::ED(path.to_owned()), refresh: Default::default(), @@ -90,9 +90,9 @@ where } /// Builds Authorizer Layer from a secret phrase - pub fn from_secret(secret: &'static str) -> JwtAuthorizer { + pub fn from_secret(secret: &str) -> JwtAuthorizer { JwtAuthorizer { - key_source_type: KeySourceType::Secret(secret), + key_source_type: KeySourceType::Secret(secret.to_owned()), refresh: Default::default(), claims_checker: None, validation: None,