diff --git a/proxy/src/cache/project_info.rs b/proxy/src/cache/project_info.rs index d8a1d261ce..58bd76b5de 100644 --- a/proxy/src/cache/project_info.rs +++ b/proxy/src/cache/project_info.rs @@ -16,7 +16,7 @@ use crate::{ config::ProjectInfoCacheOptions, console::AuthSecret, intern::{EndpointIdInt, ProjectIdInt, RoleNameInt}, - EndpointId, RoleName, + EndpointCacheKey, EndpointId, RoleName, }; use super::{Cache, Cached}; @@ -196,7 +196,7 @@ impl ProjectInfoCacheImpl { } pub fn get_allowed_ips( &self, - endpoint_id: &EndpointId, + endpoint_id: &EndpointCacheKey, ) -> Option>>> { let endpoint_id = EndpointIdInt::get(endpoint_id)?; let (valid_since, ignore_cache_since) = self.get_cache_times(); diff --git a/proxy/src/console/provider/neon.rs b/proxy/src/console/provider/neon.rs index ea429cf22f..26b074848b 100644 --- a/proxy/src/console/provider/neon.rs +++ b/proxy/src/console/provider/neon.rs @@ -222,8 +222,8 @@ impl super::Api for Api { ctx: &mut RequestMonitoring, user_info: &ComputeUserInfo, ) -> Result<(CachedAllowedIps, Option), GetAuthInfoError> { - let ep = &user_info.endpoint; - if let Some(allowed_ips) = self.caches.project_info.get_allowed_ips(ep) { + let cache_key = user_info.endpoint_cache_key(); + if let Some(allowed_ips) = self.caches.project_info.get_allowed_ips(&cache_key) { ALLOWED_IPS_BY_CACHE_OUTCOME .with_label_values(&["hit"]) .inc(); @@ -236,7 +236,7 @@ impl super::Api for Api { let allowed_ips = Arc::new(auth_info.allowed_ips); let user = &user_info.user; if let Some(project_id) = auth_info.project_id { - let ep_int = ep.normalize().into(); + let ep_int = cache_key.normalize().into(); self.caches.project_info.insert_role_secret( project_id, ep_int, diff --git a/proxy/src/intern.rs b/proxy/src/intern.rs index e38135dd22..a4562fea18 100644 --- a/proxy/src/intern.rs +++ b/proxy/src/intern.rs @@ -5,7 +5,7 @@ use std::{ use lasso::{Capacity, MemoryLimits, Spur, ThreadedRodeo}; use rustc_hash::FxHasher; -use crate::{BranchId, EndpointId, ProjectId, RoleName}; +use crate::{BranchId, EndpointCacheKey, EndpointId, ProjectId, RoleName}; pub trait InternId: Sized + 'static { fn get_interner() -> &'static StringInterner; @@ -165,6 +165,11 @@ impl From for EndpointIdInt { EndpointIdTag::get_interner().get_or_intern(&value) } } +impl From for EndpointIdInt { + fn from(value: EndpointCacheKey) -> Self { + EndpointIdTag::get_interner().get_or_intern(&value) + } +} #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub struct BranchIdTag;