pub struct ScopeConfig {
pub scopes: Vec<String>,
pub sub: String,
pub expires_at: u64,
pub rate_config: Option<RateConfig>,
}Expand description
Scope configuration — constructed from JWT claims or programmatically.
Fields§
§scopes: Vec<String>Parsed scope strings (e.g. [“tool:web_search”, “tool:github:*”, “help”]).
sub: StringAgent identity (from JWT sub claim).
expires_at: u64Expiry timestamp (from JWT exp claim). 0 = no expiry.
rate_config: Option<RateConfig>Per-tool rate limits parsed from JWT claims.
Implementations§
Source§impl ScopeConfig
impl ScopeConfig
Sourcepub fn from_jwt(claims: &TokenClaims) -> Self
pub fn from_jwt(claims: &TokenClaims) -> Self
Build a ScopeConfig from JWT TokenClaims.
Sourcepub fn unrestricted() -> Self
pub fn unrestricted() -> Self
Create an unrestricted scope config (for dev mode / no JWT set).
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the scopes have expired.
Sourcepub fn is_allowed(&self, tool_scope: &str) -> bool
pub fn is_allowed(&self, tool_scope: &str) -> bool
Check if a specific tool scope is allowed.
Supports:
- Exact match:
"tool:web_search"matches"tool:web_search" - Wildcard suffix:
"tool:github:*"matches"tool:github:search_repos" - Global wildcard:
"*"matches everything - Empty tool scope: always allowed (tool has no scope requirement)
Sourcepub fn check_access(
&self,
tool_name: &str,
tool_scope: &str,
) -> Result<(), ScopeError>
pub fn check_access( &self, tool_name: &str, tool_scope: &str, ) -> Result<(), ScopeError>
Check access for a tool, returning an error if denied.
Sourcepub fn time_remaining(&self) -> Option<u64>
pub fn time_remaining(&self) -> Option<u64>
Get time remaining until expiry, in seconds. Returns None if no expiry.
Sourcepub fn tool_scope_count(&self) -> usize
pub fn tool_scope_count(&self) -> usize
Number of tool scopes (those starting with “tool:”).
Sourcepub fn skill_scope_count(&self) -> usize
pub fn skill_scope_count(&self) -> usize
Number of skill scopes (those starting with “skill:”).
Sourcepub fn help_enabled(&self) -> bool
pub fn help_enabled(&self) -> bool
Check if help is enabled.
Sourcepub fn is_wildcard(&self) -> bool
pub fn is_wildcard(&self) -> bool
Check if this is an unrestricted (wildcard) scope.
Trait Implementations§
Source§impl Clone for ScopeConfig
impl Clone for ScopeConfig
Source§fn clone(&self) -> ScopeConfig
fn clone(&self) -> ScopeConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more