Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update redis requirement from 0.23 to 0.24 #146

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ futures-util = "0.3"
jsonwebtoken = {version = "9.0", optional = true}
opentelemetry = {version = ">=0.17, <=0.20", optional = true}
rand = {version = "0.8", optional = true}
redis = {version = "0.23", features = ["tokio-comp"], optional = true}
redis = {version = "0.24", features = ["tokio-comp"], optional = true}
reqwest = {version = "0.11", features = ["json", "multipart", "stream"]}
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/auth0/cache/inmemory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Cache for InMemoryCache {
.transpose()
}

async fn put_jwks(&self, value_ref: &JsonWebKeySet, _expiration: Option<usize>) -> Result<(), Auth0Error> {
async fn put_jwks(&self, value_ref: &JsonWebKeySet, _expiration: Option<u64>) -> Result<(), Auth0Error> {
let key: String = cache::jwks_key(&self.caller, &self.audience);
let encrypted_value: Vec<u8> = crypto::encrypt(value_ref, self.encryption_key.as_str())?;
let _ = self.key_value.insert(key, encrypted_value);
Expand Down
2 changes: 1 addition & 1 deletion src/auth0/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait Cache: Send + Sync + std::fmt::Debug {

async fn get_jwks(&self) -> Result<Option<JsonWebKeySet>, Auth0Error>;

async fn put_jwks(&self, value_ref: &JsonWebKeySet, expiration: Option<usize>) -> Result<(), Auth0Error>;
async fn put_jwks(&self, value_ref: &JsonWebKeySet, expiration: Option<u64>) -> Result<(), Auth0Error>;
}

pub(in crate::auth0::cache) fn token_key(caller: &str, audience: &str) -> String {
Expand Down
6 changes: 3 additions & 3 deletions src/auth0/cache/redis_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Cache for RedisCache {
let key: &str = &cache::token_key(&self.caller, &self.audience);
let mut connection = self.client.get_async_connection().await?;
let encrypted_value: Vec<u8> = crypto::encrypt(value_ref, self.encryption_key.as_str())?;
let expiration: usize = value_ref.lifetime_in_seconds();
let expiration: u64 = value_ref.lifetime_in_seconds();
connection.set_ex(key, encrypted_value, expiration).await?;
Ok(())
}
Expand All @@ -63,11 +63,11 @@ impl Cache for RedisCache {
self.get(key).await
}

async fn put_jwks(&self, value_ref: &JsonWebKeySet, expiration: Option<usize>) -> Result<(), Auth0Error> {
async fn put_jwks(&self, value_ref: &JsonWebKeySet, expiration: Option<u64>) -> Result<(), Auth0Error> {
let key: &str = &cache::jwks_key(&self.caller, &self.audience);
let mut connection = self.client.get_async_connection().await?;
let encrypted_value: Vec<u8> = crypto::encrypt(value_ref, self.encryption_key.as_str())?;
let expiration: usize = expiration.unwrap_or(86400);
let expiration: u64 = expiration.unwrap_or(86400);
connection.set_ex(key, encrypted_value, expiration).await?;
Ok(())
}
Expand Down
7 changes: 5 additions & 2 deletions src/auth0/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ impl Token {
}
}

pub fn lifetime_in_seconds(&self) -> usize {
(self.expire_date - self.issue_date).num_seconds() as usize
pub fn lifetime_in_seconds(&self) -> u64 {
(self.expire_date - self.issue_date)
.to_std()
.expect("expire_date should be greater than issue_date")
.as_secs()
}

// Check if the token remaining lifetime it's less than a randomized percentage that is between
Expand Down
Loading