Skip to main content

Module security

Module security 

Source
Expand description

Security primitives for CLASP authentication and authorization

This module provides a hybrid token system that works across all platforms, including embedded devices with limited resources.

§Token Types

§Capability Pre-Shared Keys (CPSK) - Default

Format: cpsk_<base62-random-32-chars>
Example: cpsk_7kX9mP2nQ4rT6vW8xZ0aB3cD5eF1gH

Simple lookup-based validation, works on any device.

§External Tokens (PASETO/JWT) - Optional

Format: ext_<paseto-or-jwt-token>

Cryptographic validation for federated identity providers.

§Scope Format

action:pattern

Actions:
  read   - SUBSCRIBE, GET
  write  - SET, PUBLISH
  admin  - Full access

Patterns:
  /path/to/addr   - Exact match
  /path/*         - Single segment wildcard
  /path/**        - Multi-segment wildcard

Examples:
  read:/**                 - Read everything
  write:/lights/**         - Control lights namespace
  admin:/**                - Full access

Structs§

CpskValidator
Capability Pre-Shared Key (CPSK) validator
Scope
A scope defines what actions are allowed on which address patterns
TokenInfo
Information about a validated token
ValidatorChain
A chain of validators that tries each one in order

Enums§

Action
Actions that can be performed on addresses
SecurityMode
Security mode for the router
ValidationResult
Result of token validation

Traits§

TokenValidator
Trait for token validators

Functions§

from_unix_timestamp
Parse a Unix timestamp to SystemTime
parse_duration
Parse a duration string like “7d”, “24h”, “30m”, “60s”
parse_scopes
Parse multiple scopes from a comma-separated string
to_unix_timestamp
Format a SystemTime as a Unix timestamp