Skip to main content

ic_auth_protocol_types/
common.rs

1//! Passive application authentication common contracts.
2//! Adapted from Canic; see docs/design/canic-source-review.md.
3
4use crate::{AudienceId, AuthRole, ScopeLabel};
5use serde::{Deserialize, Serialize};
6
7//
8// DelegationAudience
9//
10
11/// Claimed application audience; verification compares it with protected policy.
12#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
13pub enum DelegationAudience {
14    /// One network-qualified fleet identity, without fleet membership information.
15    Fleet(AudienceId),
16}
17
18//
19// DelegatedRoleGrant
20//
21
22#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
23/// Checked labels only; grant count, strict ordering and authority remain
24/// engine/host policy. Serialized labels retain their exact text representation.
25pub struct DelegatedRoleGrant {
26    /// Role whose permissions this grant describes; interpretation is host-owned.
27    pub target: AuthRole,
28    /// Exact scope labels granted to the role, without implicit wildcard expansion.
29    pub scopes: Vec<ScopeLabel>,
30}
31
32//
33// AuthRequestMetadata
34//
35
36/// Caller-provided request correlation and requested lifetime, not authorization.
37#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
38pub struct AuthRequestMetadata {
39    /// Opaque request identifier; uniqueness and retry policy belong to the host.
40    pub request_id: [u8; 32],
41    /// Requested lifetime in nanoseconds, subject to the host's admitted limits.
42    pub ttl_ns: u64,
43}