pub struct TopicAuth { /* private fields */ }Expand description
Topic authorization engine.
Holds a set of rules that map topic patterns to access policies.
When checking access, the first matching rule wins. If no rule matches,
a configurable default policy applies (defaults to Public for subscribe,
Authenticated for publish).
Implementations§
Source§impl TopicAuth
impl TopicAuth
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default rules for the standard topic namespaces.
Default rules:
system/#— subscribe: Authenticated, publish: never (internal only)plugin/#— subscribe: Public, publish: Authenticatedcustom/#— subscribe: Public, publish: Authenticated
Sourcepub fn with_rules(rules: Vec<AuthRule>) -> Self
pub fn with_rules(rules: Vec<AuthRule>) -> Self
Create with custom rules.
Sourcepub fn set_default_subscribe(&mut self, policy: Policy)
pub fn set_default_subscribe(&mut self, policy: Policy)
Override the default subscribe policy.
Sourcepub fn set_default_publish(&mut self, policy: Policy)
pub fn set_default_publish(&mut self, policy: Policy)
Override the default publish policy.
Sourcepub fn check_subscribe(&self, topic: &str, ctx: &AuthContext) -> bool
pub fn check_subscribe(&self, topic: &str, ctx: &AuthContext) -> bool
Check if the given context is allowed to subscribe to topic.
Sourcepub fn check_publish(&self, topic: &str, ctx: &AuthContext) -> bool
pub fn check_publish(&self, topic: &str, ctx: &AuthContext) -> bool
Check if the given context is allowed to publish to topic.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TopicAuth
impl RefUnwindSafe for TopicAuth
impl Send for TopicAuth
impl Sync for TopicAuth
impl Unpin for TopicAuth
impl UnsafeUnpin for TopicAuth
impl UnwindSafe for TopicAuth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more