Skip to content

Commit

Permalink
doc: improve method
Browse files Browse the repository at this point in the history
  • Loading branch information
de-sh committed Jan 10, 2025
1 parent 2afb69b commit 9b0a05e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,26 @@ impl Query {
) -> Result<(), Unauthorized> {
// check authorization of this query if it references physical table;
let mut authorized = false;
let mut tags = Vec::new();

// in permission check if user can run query on the stream.
// also while iterating add any filter tags for this stream
for permission in permissions {
match permission {
// Full access to all actions on stream
Permission::Stream(Action::All, _) => {
authorized = true;
break;
}
// Query access to specific stream or all streams (*)
Permission::StreamWithTag(Action::Query, ref stream, tag)
if stream == table_name || stream == "*" =>
{
authorized = true;
// add filter tags for this stream from permission
if let Some(tag) = tag {
tags.push(tag)
self.filter_tag.get_or_insert_with(Vec::new).push(tag)
}
}
// Other permissions are ignored
_ => (),
}
}
Expand All @@ -232,10 +234,6 @@ impl Query {
return Err(Unauthorized);
}

if !tags.is_empty() {
self.filter_tag = Some(tags)
}

Ok(())
}
}
Expand Down

0 comments on commit 9b0a05e

Please sign in to comment.