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.26 #166

Merged
merged 2 commits into from
Sep 9, 2024
Merged
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 @@ -34,7 +34,7 @@ futures = "0.3"
futures-util = "0.3"
jsonwebtoken = {version = "9.0", optional = true}
rand = {version = "0.8", optional = true}
redis = {version = "0.23", features = ["tokio-comp"], optional = true}
redis = {version = "0.26", features = ["tokio-comp"], optional = true}
reqwest = {version = "0.12", features = ["json", "multipart", "stream"]}
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0"
Expand Down
8 changes: 4 additions & 4 deletions src/auth0/cache/redis_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl RedisCache {
pub async fn new(config_ref: &Config) -> Result<Self, Auth0Error> {
let client: redis::Client = redis::Client::open(config_ref.cache_type().redis_connection_url())?;
// Ensure connection is fine. Should fail otherwise
let _ = client.get_async_connection().await?;
let _ = client.get_multiplexed_async_connection().await?;

Ok(RedisCache {
client,
Expand All @@ -32,7 +32,7 @@ impl RedisCache {
for<'de> T: Deserialize<'de>,
{
self.client
.get_async_connection()
.get_multiplexed_async_connection()
.await?
.get::<_, Option<Vec<u8>>>(key)
.await?
Expand All @@ -50,9 +50,9 @@ impl Cache for RedisCache {

async fn put_token(&self, value_ref: &Token) -> Result<(), Auth0Error> {
let key: &str = &cache::token_key(&self.caller, &self.audience);
let mut connection = self.client.get_async_connection().await?;
let mut connection = self.client.get_multiplexed_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 = value_ref.lifetime_in_seconds();
let _: () = connection.set_ex(key, encrypted_value, expiration).await?;
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/auth0/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ 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).num_seconds() as u64
}

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