Skip to content

Commit

Permalink
Merge pull request #5037 from systeminit/nf/forklift-permisive-subjects
Browse files Browse the repository at this point in the history
fix(forklift): properly handle optional change set id in NATS subject
  • Loading branch information
fnichol authored Nov 27, 2024
2 parents beafa8b + 7bfc490 commit ff00fcf
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions lib/forklift-server/src/server/app/audit_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,54 @@ where

match self.prefix {
Some(_) => {
if let (Some(prefix), Some(p1), Some(p2), Some(_workspace_id), None) = (
match (
parts.next(),
parts.next(),
parts.next(),
parts.next(),
parts.next(),
parts.next(),
) {
let matched = format!("{prefix}.{p1}.{p2}.:workspace_id");
req.extensions_mut().insert(MatchedSubject::from(matched));
};
// Subject with change set id
(
Some(prefix),
Some(p1),
Some(p2),
Some(_workspace_id),
Some(_change_set_id),
None,
) => {
let matched = format!("{prefix}.{p1}.{p2}.:workspace_id.:change_set_id");
req.extensions_mut().insert(MatchedSubject::from(matched));
}
// Subject without change set id
(Some(prefix), Some(p1), Some(p2), Some(_workspace_id), None, None) => {
let matched = format!("{prefix}.{p1}.{p2}.:workspace_id.");
req.extensions_mut().insert(MatchedSubject::from(matched));
}
_ => {}
}
}
None => {
if let (Some(p1), Some(p2), Some(_workspace_id), None) =
(parts.next(), parts.next(), parts.next(), parts.next())
{
let matched = format!("{p1}.{p2}.:workspace_id");
req.extensions_mut().insert(MatchedSubject::from(matched));
};
match (
parts.next(),
parts.next(),
parts.next(),
parts.next(),
parts.next(),
) {
// Subject with change set id
(Some(p1), Some(p2), Some(_workspace_id), Some(_change_set_id), None) => {
let matched = format!("{p1}.{p2}.:workspace_id.:change_set_id");
req.extensions_mut().insert(MatchedSubject::from(matched));
}
// Subject without change set id
(Some(p1), Some(p2), Some(_workspace_id), None, None) => {
let matched = format!("{p1}.{p2}.:workspace_id.");
req.extensions_mut().insert(MatchedSubject::from(matched));
}
_ => {}
}
}
}
}
Expand Down

0 comments on commit ff00fcf

Please sign in to comment.