mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-24 00:20:37 +00:00
## Problem Current cache doesn't support any updates from the cplane. ## Summary of changes * Added redis notifier listner. * Added cache which can be invalidated with the notifier. If the notifier is not available, it's just a normal ttl cache. * Updated cplane api. The motivation behind this organization of the data is the following: * In the Neon data model there are projects. Projects could have multiple branches and each branch could have more than one endpoint. * Also there is one special `main` branch. * Password reset works per branch. * Allowed IPs are the same for every branch in the project (except, maybe, the main one). * The main branch can be changed to the other branch. * The endpoint can be moved between branches. Every event described above requires some special processing on the porxy (or cplane) side. The idea of invalidating for the project is that whenever one of the events above is happening with the project, proxy can invalidate all entries for the entire project. This approach also requires some additional API change (returning project_id inside the auth info).
38 lines
880 B
Rust
38 lines
880 B
Rust
//! Tools for client/server/stored key management.
|
|
|
|
/// Faithfully taken from PostgreSQL.
|
|
pub const SCRAM_KEY_LEN: usize = 32;
|
|
|
|
/// One of the keys derived from the [password](super::password::SaltedPassword).
|
|
/// We use the same structure for all keys, i.e.
|
|
/// `ClientKey`, `StoredKey`, and `ServerKey`.
|
|
#[derive(Clone, Default, PartialEq, Eq, Debug)]
|
|
#[repr(transparent)]
|
|
pub struct ScramKey {
|
|
bytes: [u8; SCRAM_KEY_LEN],
|
|
}
|
|
|
|
impl ScramKey {
|
|
pub fn sha256(&self) -> Self {
|
|
super::sha256([self.as_ref()]).into()
|
|
}
|
|
|
|
pub fn as_bytes(&self) -> [u8; SCRAM_KEY_LEN] {
|
|
self.bytes
|
|
}
|
|
}
|
|
|
|
impl From<[u8; SCRAM_KEY_LEN]> for ScramKey {
|
|
#[inline(always)]
|
|
fn from(bytes: [u8; SCRAM_KEY_LEN]) -> Self {
|
|
Self { bytes }
|
|
}
|
|
}
|
|
|
|
impl AsRef<[u8]> for ScramKey {
|
|
#[inline(always)]
|
|
fn as_ref(&self) -> &[u8] {
|
|
&self.bytes
|
|
}
|
|
}
|