Skip to main content

TrustGate

Struct TrustGate 

Source
pub struct TrustGate { /* private fields */ }
Expand description

Checks integrations and AI profiles against the trust store.

File-backed gates re-read trust.toml on every use, so a trust run in another process (or the TUI’s dialog) takes effect at once.

Implementations§

Source§

impl TrustGate

Source

pub async fn verify_account( &self, integration: &Integration, client: &dyn HostingClient, reason: VerifyReason, ) -> Result<()>

Compares the account client’s token belongs to with the recorded one, when VerifyReason says it is due. The id is compared, not the login (a login can be renamed or re-registered). A record with no account yet (a migrated one) learns it here.

Source

pub fn check_account( &self, integration: &Integration, new: &Account, ) -> Result<()>

Compares new with the recorded account and, when it is the same one (or none was recorded yet), refreshes the record. The part of Self::verify_account for a caller that already holds the account, from a token check it just ran.

Source§

impl TrustGate

Source

pub fn load(paths: &ConfigPaths) -> Self

The gate over <private>/trust.toml of paths.

Source

pub fn ambient() -> Self

Self::load over the real config directory; with none to be found the gate keeps its records in memory only.

Source

pub fn admit(&self, integration: &Integration) -> Result<Admitted>

The first two checks, before anything (a token included) is resolved: plain http, then origin. A record that does not exist yet is made from the config as it stands: written at once for an integration that was connected before (the migration: it keeps today’s level of trust), held in memory for one that never was, until Self::record_after_check writes it.

Source

pub fn adopt(&self, integration: &Integration) -> Result<()>

Writes the record of integration now if there is none: for a caller that holds a token for it (stored, from the environment or from the credential helper), which is the migration case.

Source

pub fn preflight(&self, integration: &Integration) -> Result<()>

Self::admit, for a caller that only wants to know it passes before it resolves a token.

Source

pub fn record_of(&self, id: &str) -> Option<IntegrationRecord>

The record of id, if one was written.

Source

pub fn update_record<R>( &self, integration: &Integration, change: impl FnOnce(&mut IntegrationRecord) -> R, ) -> Result<R>

Changes the record of integration (made from the config first when there is none) and writes it. The one door every acceptance goes through.

Source

pub fn record_after_check( &self, integration: &Integration, account: &Account, ) -> Result<()>

Records (or refreshes) the trust of integration after a check that succeeded: its current address, and the account the token belongs to. Does not widen anything by itself: Self::admit has already passed for this address.

Source

pub fn trust_origin(&self, integration: &Integration) -> Result<()>

Accepts the integration’s current address as the trusted one. The account is forgotten with it: another server has other ids.

Source

pub fn trust_account( &self, integration: &Integration, account: &Account, ) -> Result<()>

Accepts account as the owner of the token.

Source

pub fn trust_certificate( &self, integration: &Integration, cert: &CertInfo, mode: TlsMode, ) -> Result<()>

Pins the certificate key of the integration’s host.

Source

pub fn set_strict( &self, integration: &Integration, strict: bool, ) -> Result<bool>

Switches the pin between tofu and strict (it needs a pinned key).

Source

pub fn set_allow_plain_http( &self, integration: &Integration, on: bool, ) -> Result<()>

Source

pub fn admit_ai( &self, profile: &str, base_url: &str, has_key: bool, ) -> Result<Vec<String>>

The checks of Self::admit for an API-key AI profile bound to base_url. has_key: a key is stored, so a missing record is written now (migration); without one it is held in memory until the key is stored and Self::record_ai runs. Returns the origins a request may reach.

Source

pub fn ai_record_of(&self, profile: &str) -> Option<AiRecord>

The AI record of profile, if one was written.

Source

pub fn update_ai_record<R>( &self, profile: &str, base_url: &str, change: impl FnOnce(&mut AiRecord) -> R, ) -> Result<R>

Changes the AI record of profile (made from base_url first when there is none) and writes it.

Source

pub fn record_ai(&self, profile: &str, base_url: &str) -> Result<()>

Binds the key of profile to the current origin of base_url: call it when a key is stored.

Source

pub fn trust_ai_origin(&self, profile: &str, base_url: &str) -> Result<()>

Accepts the profile’s current address as the trusted one.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more