mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-12 16:10:06 +01:00
Remove 'static lifetime requirement (#8)
Co-authored-by: Yonghyu Ban <yhban@cleanc.kr>
This commit is contained in:
parent
5b99335da6
commit
2bca19be64
2 changed files with 8 additions and 8 deletions
|
|
@ -51,7 +51,7 @@ pub enum KeySourceType {
|
||||||
RSA(String),
|
RSA(String),
|
||||||
EC(String),
|
EC(String),
|
||||||
ED(String),
|
ED(String),
|
||||||
Secret(&'static str),
|
Secret(String),
|
||||||
Jwks(String),
|
Jwks(String),
|
||||||
JwksString(String), // TODO: expose JwksString in JwtAuthorizer or remove it
|
JwksString(String), // TODO: expose JwksString in JwtAuthorizer or remove it
|
||||||
Discovery(String),
|
Discovery(String),
|
||||||
|
|
@ -180,7 +180,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn build_from_secret() {
|
async fn build_from_secret() {
|
||||||
let h = Header::new(Algorithm::HS256);
|
let h = Header::new(Algorithm::HS256);
|
||||||
let a = Authorizer::<Value>::build(&KeySourceType::Secret("xxxxxx"), None, None, Validation::new())
|
let a = Authorizer::<Value>::build(&KeySourceType::Secret("xxxxxx".to_owned()), None, None, Validation::new())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let k = a.key_source.get_key(h);
|
let k = a.key_source.get_key(h);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds Authorizer Layer from a JWKS endpoint
|
/// Builds Authorizer Layer from a JWKS endpoint
|
||||||
pub fn from_jwks_url(url: &'static str) -> JwtAuthorizer<C> {
|
pub fn from_jwks_url(url: &str) -> JwtAuthorizer<C> {
|
||||||
JwtAuthorizer {
|
JwtAuthorizer {
|
||||||
key_source_type: KeySourceType::Jwks(url.to_owned()),
|
key_source_type: KeySourceType::Jwks(url.to_owned()),
|
||||||
refresh: Default::default(),
|
refresh: Default::default(),
|
||||||
|
|
@ -60,7 +60,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds Authorizer Layer from a RSA PEM file
|
/// Builds Authorizer Layer from a RSA PEM file
|
||||||
pub fn from_rsa_pem(path: &'static str) -> JwtAuthorizer<C> {
|
pub fn from_rsa_pem(path: &str) -> JwtAuthorizer<C> {
|
||||||
JwtAuthorizer {
|
JwtAuthorizer {
|
||||||
key_source_type: KeySourceType::RSA(path.to_owned()),
|
key_source_type: KeySourceType::RSA(path.to_owned()),
|
||||||
refresh: Default::default(),
|
refresh: Default::default(),
|
||||||
|
|
@ -70,7 +70,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds Authorizer Layer from a EC PEM file
|
/// Builds Authorizer Layer from a EC PEM file
|
||||||
pub fn from_ec_pem(path: &'static str) -> JwtAuthorizer<C> {
|
pub fn from_ec_pem(path: &str) -> JwtAuthorizer<C> {
|
||||||
JwtAuthorizer {
|
JwtAuthorizer {
|
||||||
key_source_type: KeySourceType::EC(path.to_owned()),
|
key_source_type: KeySourceType::EC(path.to_owned()),
|
||||||
refresh: Default::default(),
|
refresh: Default::default(),
|
||||||
|
|
@ -80,7 +80,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds Authorizer Layer from a EC PEM file
|
/// Builds Authorizer Layer from a EC PEM file
|
||||||
pub fn from_ed_pem(path: &'static str) -> JwtAuthorizer<C> {
|
pub fn from_ed_pem(path: &str) -> JwtAuthorizer<C> {
|
||||||
JwtAuthorizer {
|
JwtAuthorizer {
|
||||||
key_source_type: KeySourceType::ED(path.to_owned()),
|
key_source_type: KeySourceType::ED(path.to_owned()),
|
||||||
refresh: Default::default(),
|
refresh: Default::default(),
|
||||||
|
|
@ -90,9 +90,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds Authorizer Layer from a secret phrase
|
/// Builds Authorizer Layer from a secret phrase
|
||||||
pub fn from_secret(secret: &'static str) -> JwtAuthorizer<C> {
|
pub fn from_secret(secret: &str) -> JwtAuthorizer<C> {
|
||||||
JwtAuthorizer {
|
JwtAuthorizer {
|
||||||
key_source_type: KeySourceType::Secret(secret),
|
key_source_type: KeySourceType::Secret(secret.to_owned()),
|
||||||
refresh: Default::default(),
|
refresh: Default::default(),
|
||||||
claims_checker: None,
|
claims_checker: None,
|
||||||
validation: None,
|
validation: None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue