Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
feat: debug traces in register
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Basty committed Sep 7, 2023
1 parent 0033f34 commit 5578082
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl AuthBearer {
Self(contents.to_string())
}

fn decode_request_parts(req: &mut Parts) -> Result<Self, Rejection> {
fn decode_request_parts(req: &Parts) -> Result<Self, Rejection> {
// Get authorization header
let authorization = req
.headers
Expand All @@ -73,7 +73,7 @@ impl AuthBearer {
let split = authorization.split_once(' ');
match split {
// Found proper bearer
Some((name, contents)) if name == "Bearer" => Ok(Self::from_header(contents)),
Some(("Bearer", contents)) => Ok(Self::from_header(contents)),
// Found empty bearer
_ if authorization == "Bearer" => Ok(Self::from_header("")),
// Found nothing
Expand Down
21 changes: 21 additions & 0 deletions src/handlers/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ async fn overwrite_registration(
tags: HashSet<Arc<str>>,
relay_url: Arc<str>,
) -> error::Result<Response> {
info!(
"DBG:{}:overwrite_registration: upsert registration",
client_id
);
state
.registration_store
.upsert_registration(
Expand All @@ -79,6 +83,10 @@ async fn overwrite_registration(
)
.await?;

info!(
"DBG:{}:overwrite_registration: cache registration",
client_id
);
state
.registration_cache
.insert(client_id.into_value(), CachedRegistration {
Expand All @@ -100,15 +108,27 @@ async fn update_registration(
let append_tags = append_tags.unwrap_or_default();
let remove_tags = remove_tags.unwrap_or_default();

info!(
"DBG:{}:update_registration: process intersection of <append_tags> and <remove_tags>...",
client_id
);
if remove_tags.intersection(&append_tags).count() > 0 {
return Err(Error::InvalidUpdateRequest);
}

info!(
"DBG:{}:update_registration: get current registration",
client_id
);
let registration = state
.registration_store
.get_registration(client_id.as_ref())
.await?;

info!(
"DBG:{}:update_registration: get current registration",
client_id
);
let tags = registration
.tags
.into_iter()
Expand All @@ -120,5 +140,6 @@ async fn update_registration(
.cloned()
.collect();

info!("DBG:{}: overwrite registration", client_id);
overwrite_registration(state, client_id, tags, relay_url).await
}

0 comments on commit 5578082

Please sign in to comment.