ic_auth_wire/model/mod.rs
1//! Transport records and discriminants, kept distinct from engine decisions.
2
3mod credential;
4
5use ic_auth_protocol_types::Principal;
6use serde::{Deserialize, Serialize};
7
8pub use credential::{
9 AudienceId, CertifiedProof, ChainKeyAlgorithm, ChainKeyBatchHeaderV1,
10 ChainKeyBatchWitnessStepV1, ChainKeyBatchWitnessV1, ChainKeyDelegationCertV1, ChainKeyKeyId,
11 ChainKeyRootSignatureV1, DelegatedRoleGrant, DelegationAudience, DelegationCert,
12 DelegationProof, IcCanisterSignatureProofV1, IcChainKeyBatchSignatureProofV1,
13 IssuerProofAlgorithm, IssuerProofBinding, PortableCredential, PortableProof, RootProof,
14};
15
16///
17/// AdmissionRefusal
18///
19/// Session-admission refusals in their fixed transport order.
20///
21
22#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, ic_wire::Wire)]
23pub enum AdmissionRefusal {
24 /// Credential is not yet valid at trusted time.
25 NotYetValid,
26 /// Credential has expired for fresh admission.
27 Expired,
28 /// Credential verification failed.
29 InvalidCredential,
30 /// Protected authority is not ready.
31 AuthorityUnavailable,
32 /// Credential predates the protected reset boundary.
33 BeforeReset,
34 /// Requested scopes are not admitted.
35 ScopeRejected,
36 /// A consumed credential conflicts with this request.
37 ReplayConflict,
38 /// Retained revocation prevents admission.
39 Revoked,
40 /// Required bounded state has no capacity.
41 Capacity,
42 /// The applicable attempt budget is exhausted.
43 Throttled,
44 /// Admission could not be completed.
45 Unavailable,
46}
47
48///
49/// SessionView
50///
51/// A local session receipt; receiving or constructing it grants no authority.
52///
53
54#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, ic_wire::Wire)]
55pub struct SessionView {
56 /// Host-authenticated browser principal bound to the session.
57 pub caller: Principal,
58 /// Issuer qualifying the subject.
59 pub issuer: Principal,
60 /// Issuer-qualified account subject.
61 pub subject: Principal,
62 /// Exclusive local lease deadline in nanoseconds.
63 pub expires_at_ns: u64,
64 /// Opaque issuer-attested application bytes, up to 4096 bytes.
65 pub ext: Option<ic_wire::Bytes<{ ic_auth_protocol_types::MAX_TOKEN_EXT_BYTES }>>,
66}
67
68///
69/// SessionReadRefusal
70///
71/// Existing read-refusal discriminants, in their fixed Wire order.
72///
73
74#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, ic_wire::Wire)]
75pub enum SessionReadRefusal {
76 /// No live local session.
77 MissingOrExpired,
78 /// Protected authority is not ready.
79 AuthorityUnavailable,
80 /// The required scope is not granted.
81 ScopeRejected,
82 /// Revocation prevents use.
83 Revoked,
84 /// The read could not be completed.
85 Unavailable,
86}
87
88///
89/// LogoutUnavailable
90///
91/// Existing unavailable-logout discriminants, in their fixed Wire order.
92///
93
94#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, ic_wire::Wire)]
95pub enum LogoutUnavailable {
96 /// No capacity to retain the required denial.
97 Capacity,
98 /// Storage could not commit the denial.
99 Storage,
100 /// Trusted time could not support the operation.
101 Clock,
102 /// A reset is pending.
103 ResetPending,
104}
105
106///
107/// LogoutResult
108///
109/// Local logout result; no variant acknowledges logout at another receiver.
110///
111
112#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, ic_wire::Wire)]
113pub enum LogoutResult {
114 /// Committed denial through this nanosecond deadline.
115 Revoked(u64),
116 /// Local denial deadline without confirmation of outstanding issuance.
117 Unconfirmed(u64),
118 /// The host-authenticated caller is not a valid logout identity.
119 InvalidCaller,
120 /// No revocation acknowledgement; issuance uncertainty must be retained.
121 Unavailable(LogoutUnavailable),
122}