Struct PairingCodePolicy
pub struct PairingCodePolicy {
pub length: usize,
pub charset: PairingCodeCharset,
}Expand description
The one pairing-code generation policy.
Every code the gateway issues — the startup code, zeroclaw gateway get-paircode --new, POST /api/pairing/initiate, and the rotate-device
flow — comes from this policy via PairingGuard. There is no second
pairing-code setting anywhere in the schema.
§Default
32 case-sensitive alphanumeric characters ≈ 190.6 bits of entropy, against ≈19.9 bits for the six-digit numeric code shipped before the shared policy. Pairing codes are pasted far more often than they are retyped, and a pairing code is the gateway’s front door: getting it wrong is an authentication bypass, while getting it long is a paste.
Operators who transfer the code by hand have two supported alternatives, both still far stronger than the old default:
# Read-aloud friendly: 24 Crockford-Base32 chars ≈ 120 bits.
[gateway.pairing_code]
length = 24
charset = "unambiguous"
# Exact legacy behaviour. Only for local, short-lived pairing.
[gateway.pairing_code]
length = 6
charset = "numeric"Fields§
§length: usizeNumber of characters in a generated pairing code
(6..=128, default: 32).
charset: PairingCodeCharsetCharacter family: numeric, alphanumeric (default), or
unambiguous.
Implementations§
Source§impl PairingCodePolicy
impl PairingCodePolicy
Sourcepub fn configurable_prefix() -> &'static str
pub fn configurable_prefix() -> &'static str
Returns the #[prefix] value for this Configurable struct.
Sourcepub fn init_requires_explicit_config() -> bool
pub fn init_requires_explicit_config() -> bool
True when this struct has a required leaf field that a
bare/ancestor-prefix init_defaults scaffold must not
materialize (it would fill the field with its Rust
Default, which prune_empty_leaves then strips on save,
leaving a partial sub-table that fails strict reload).
Explicitly targeting this section (or a descendant of it)
still scaffolds regardless of this flag, so the section can
be materialized for the operator to fill in.
Sourcepub fn secret_fields(&self) -> Vec<SecretFieldInfo>
pub fn secret_fields(&self) -> Vec<SecretFieldInfo>
Returns metadata about all #[secret] fields on this struct and nested children.
pub fn secret_field_terminals() -> Vec<&'static str>
Sourcepub fn encrypt_secrets(&mut self, store: &SecretStore) -> Result<(), Error>
pub fn encrypt_secrets(&mut self, store: &SecretStore) -> Result<(), Error>
Encrypt all secret fields in place using the provided store.
Sourcepub fn decrypt_secrets(&mut self, store: &SecretStore) -> Result<(), Error>
pub fn decrypt_secrets(&mut self, store: &SecretStore) -> Result<(), Error>
Decrypt all secret fields in place using the provided store.
Sourcepub fn set_secret(&mut self, name: &str, value: String) -> Result<(), Error>
pub fn set_secret(&mut self, name: &str, value: String) -> Result<(), Error>
Set a secret field by its full dotted name, dispatching to nested children.
Sourcepub fn prop_fields(&self) -> Vec<PropFieldInfo>
pub fn prop_fields(&self) -> Vec<PropFieldInfo>
Returns metadata about all property fields on this struct and nested children.
Sourcepub fn get_prop(&self, name: &str) -> Result<String, Error>
pub fn get_prop(&self, name: &str) -> Result<String, Error>
Get a property value by its full dotted name, returning it as a display string.
Sourcepub fn set_prop(&mut self, name: &str, value_str: &str) -> Result<(), Error>
pub fn set_prop(&mut self, name: &str, value_str: &str) -> Result<(), Error>
Set a property value by its full dotted name, parsing from string.
Sourcepub fn prop_is_secret(name: &str) -> bool
pub fn prop_is_secret(name: &str) -> bool
Check if a property name refers to a secret field (static, no instance needed).
Sourcepub fn init_defaults(&mut self, prefix: Option<&str>) -> Vec<&'static str>
pub fn init_defaults(&mut self, prefix: Option<&str>) -> Vec<&'static str>
Instantiate None nested sections whose prefix matches.
Returns the prefixes that were initialized.
Sourcepub fn map_key_sections() -> Vec<MapKeySection>
pub fn map_key_sections() -> Vec<MapKeySection>
Enumerate every map-keyed (HashMap<String, T>) and list-shaped
(Vec<T>) section discoverable from this Configurable’s tree.
The dashboard / CLI consume this to surface “+ Add” affordances
without hardcoding the section list.
Sourcepub fn nested_section_help(name: &str) -> Option<&'static str>
pub fn nested_section_help(name: &str) -> Option<&'static str>
Help blurb for a #[nested] field on this struct, sourced from
the field-level /// docstring. Returns None for unknown
names so callers can fall through to a different lookup.
pub fn nested_section_group(name: &str) -> Option<&'static str>
Sourcepub fn get_map_keys(&self, section_path: &str) -> Option<Vec<String>>
pub fn get_map_keys(&self, section_path: &str) -> Option<Vec<String>>
Return the current alias keys at section_path, or None if
the path doesn’t resolve to a map-keyed section in this tree.
pub fn nested_option_entries(&self) -> Vec<NestedOptionEntry>
pub fn create_map_key( &mut self, section_path: &str, map_key: &str, ) -> Result<bool, String>
pub fn delete_map_key( &mut self, section_path: &str, map_key: &str, ) -> Result<bool, String>
pub fn rename_map_key( &mut self, section_path: &str, map_key: &str, new_key: &str, ) -> Result<bool, String>
Source§impl PairingCodePolicy
impl PairingCodePolicy
Sourcepub fn new(
length: usize,
charset: PairingCodeCharset,
) -> Result<PairingCodePolicy, PairingCodePolicyError>
pub fn new( length: usize, charset: PairingCodeCharset, ) -> Result<PairingCodePolicy, PairingCodePolicyError>
Build a validated policy.
Sourcepub const fn numeric_compat() -> PairingCodePolicy
pub const fn numeric_compat() -> PairingCodePolicy
The exact legacy policy: six numeric digits.
Kept as a named constructor so the compatibility shape is testable and greppable rather than a magic pair of literals.
Sourcepub fn validate(&self) -> Result<(), PairingCodePolicyError>
pub fn validate(&self) -> Result<(), PairingCodePolicyError>
Reject lengths outside PAIRING_CODE_MIN_LENGTH..=PAIRING_CODE_MAX_LENGTH.
Sourcepub fn resolve_length(&self) -> (usize, Option<usize>)
pub fn resolve_length(&self) -> (usize, Option<usize>)
The length generation will actually use, paired with the configured length it replaced when the two differ.
Split out from Self::generate so the clamp decision is a plain
value a test can assert on directly, independent of the WARN that
Self::generate emits when it fires.
Sourcepub fn effective_length(&self) -> usize
pub fn effective_length(&self) -> usize
The length actually used for generation.
Config::validate rejects an out-of-range length, and the gateway
PATCH /api/config path refuses such a write outright, so reaching
the clamp means the policy was built by some other route. Generation
must still never panic or emit a zero-length code.
Sourcepub fn entropy_bits(&self) -> f64
pub fn entropy_bits(&self) -> f64
Shannon entropy of a code generated under this policy, in bits.
Reported so a security-posture surface can state the active strength rather than restating the raw length and charset.
Trait Implementations§
Source§impl Clone for PairingCodePolicy
impl Clone for PairingCodePolicy
Source§fn clone(&self) -> PairingCodePolicy
fn clone(&self) -> PairingCodePolicy
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PairingCodePolicy
Source§impl Debug for PairingCodePolicy
impl Debug for PairingCodePolicy
Source§impl Default for PairingCodePolicy
impl Default for PairingCodePolicy
Source§fn default() -> PairingCodePolicy
fn default() -> PairingCodePolicy
Source§impl<'de> Deserialize<'de> for PairingCodePolicy
impl<'de> Deserialize<'de> for PairingCodePolicy
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PairingCodePolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PairingCodePolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for PairingCodePolicy
Source§impl JsonSchema for PairingCodePolicy
impl JsonSchema for PairingCodePolicy
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl MaskSecrets for PairingCodePolicy
impl MaskSecrets for PairingCodePolicy
fn mask_secrets(&mut self)
fn restore_secrets_from(&mut self, current: &PairingCodePolicy)
Source§impl PartialEq for PairingCodePolicy
impl PartialEq for PairingCodePolicy
Source§impl Serialize for PairingCodePolicy
impl Serialize for PairingCodePolicy
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for PairingCodePolicy
Auto Trait Implementations§
impl Freeze for PairingCodePolicy
impl RefUnwindSafe for PairingCodePolicy
impl Send for PairingCodePolicy
impl Sync for PairingCodePolicy
impl Unpin for PairingCodePolicy
impl UnsafeUnpin for PairingCodePolicy
impl UnwindSafe for PairingCodePolicy
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more