Skip to content

Commit

Permalink
Merge pull request #171 from ArunaStorage/feat/nats_improvements
Browse files Browse the repository at this point in the history
Feat/nats improvements
  • Loading branch information
lfbrehm authored May 8, 2024
2 parents dcc3964 + f2704f5 commit 91f0293
Show file tree
Hide file tree
Showing 42 changed files with 940 additions and 319 deletions.
20 changes: 10 additions & 10 deletions components/data_proxy/src/auth/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl AuthHandler {
encode_secret
);
let encoding_key = EncodingKey::from_ed_pem(private_pem.as_bytes()).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?;

Expand All @@ -162,17 +162,17 @@ impl AuthHandler {
.kid
.ok_or_else(|| anyhow!("Unspecified kid"))
.map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?;
let (pk, dec_key) = self
.cache
.get_pubkey(i32::from_str(&kid).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?)
.map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?;
let claims = self.extract_claims(token, &dec_key)?;
Expand Down Expand Up @@ -205,7 +205,7 @@ impl AuthHandler {
// No intent, no Dataproxy/Action check
Ok((
DieselUlid::from_str(&claims.sub).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?,
claims.tid,
Expand All @@ -229,7 +229,7 @@ impl AuthHandler {
&validation, //&Validation::new(Algorithm::EdDSA)
)
.map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?;
Ok(token.claims)
Expand Down Expand Up @@ -647,7 +647,7 @@ impl AuthHandler {
};

self.sign_token(claims).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})
}
Expand All @@ -670,7 +670,7 @@ impl AuthHandler {
};

self.sign_token(claims).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})
}
Expand All @@ -696,7 +696,7 @@ impl AuthHandler {
};

self.sign_token(claims).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})
}
Expand All @@ -709,7 +709,7 @@ impl AuthHandler {
};

let token = jsonwebtoken::encode(&header, &claims, &self.encoding_key.1).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?;

Expand Down
2 changes: 1 addition & 1 deletion components/data_proxy/src/auth/auth_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn get_token_from_md(md: &MetadataMap) -> Result<String> {
.get("Authorization")
.ok_or(anyhow!("Metadata token not found"))
.map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?
.to_str()?;
Expand Down
9 changes: 4 additions & 5 deletions components/data_proxy/src/caching/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Cache {
GrpcQueryHandler::new(url, cache.clone(), self_id.to_string())
.await
.map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?,
);
Expand Down Expand Up @@ -486,8 +486,7 @@ impl Cache {
// /foo/bar: id-foo/bar

// VecDeque<(id, [Option<(String, DieselUlid)>; 4])>
const ARRAY_REPEAT_VALUE: std::option::Option<(std::string::String, TypedId)> =
None::<(String, TypedId)>;
const ARRAY_REPEAT_VALUE: Option<(String, TypedId)> = None::<(String, TypedId)>;
let mut prefixes = VecDeque::from([(*resource_id, [ARRAY_REPEAT_VALUE; 3])]);
let mut final_result = Vec::new();
while let Some((id, visited)) = prefixes.pop_front() {
Expand Down Expand Up @@ -627,7 +626,7 @@ impl Cache {
.pubkeys
.get(&kid)
.ok_or_else(|| {
tracing::error!(error = "Pubkey not found");
error!(error = "Pubkey not found");
anyhow!("Pubkey not found")
})?
.clone())
Expand All @@ -636,7 +635,7 @@ impl Cache {
#[tracing::instrument(level = "trace", skip(self))]
pub async fn upsert_user(self: Arc<Cache>, user: GrpcUser) -> Result<()> {
let user_id = DieselUlid::from_str(&user.id).map_err(|e| {
tracing::error!(error = ?e, msg = e.to_string());
error!(error = ?e, msg = e.to_string());
e
})?;
let proxy_user = User::try_from(user)?;
Expand Down
Loading

0 comments on commit 91f0293

Please sign in to comment.