Skip to main content

AccountsAuth

Struct AccountsAuth 

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

Signs Carbons and Silicons in to Commit at Silicon Accounts, without an app secret.

Implementations§

Source§

impl AccountsAuth

Source

pub fn new(accounts_url: impl Into<String>) -> Result<Self, Error>

Signs in to Commit (commit) at the given Silicon Accounts URL.

Source

pub fn builder(accounts_url: impl Into<String>) -> AccountsAuthBuilder

Starts a builder for the given Silicon Accounts URL.

Source

pub fn accounts_url(&self) -> &Url

The Silicon Accounts URL requests go to.

Source

pub fn app_id(&self) -> &str

The app id this client signs in to.

Source

pub async fn start_device_sign_in( &self, scope: Option<&str>, client_label: Option<&str>, ) -> Result<DeviceAuthorization, Error>

POST /v1/device/authorize with Commit’s client_id: starts a Carbon’s sign-in. Show user_code and verification_uri (or verification_uri_complete), then poll with AccountsAuth::wait_for_device_sign_in. scope asks for extra details the Carbon may share (space-separated, e.g. email); client_label names this device in the Carbon’s sign-in history.

Source

pub async fn poll_device_sign_in( &self, device: &DeviceAuthorization, ) -> Result<DeviceStatus, Error>

Polls a device sign-in once.

Source

pub async fn wait_for_device_sign_in( &self, device: &DeviceAuthorization, on_event: impl FnMut(DeviceEvent<'_>), ) -> Result<SignIn, Error>

Polls a device sign-in until the Carbon approves it, honouring interval, adding 5 seconds after every slow_down, retrying temporary failures, and giving up when the code expires. A denied sign-in fails with code access_denied, an expired one with expired_token.

Source

pub async fn exchange_slt(&self, slt: &str) -> Result<SignIn, Error>

Exchanges a Silicon’s short-lived token (slt_…, single use, 2 minutes, minted for Commit with silicon-accounts login --app commit -q) for Commit’s tokens, with Commit’s client_id alone. Commit’s sign-in setup has public_client on. The token is never logged or echoed in errors.

Source

pub async fn refresh(&self, refresh_token: &str) -> Result<SignIn, Error>

Rotates a refresh token with Commit’s client_id alone. The old token stops working even if this answer is lost, and presenting it again ends the sign-in: store the new pair before using it, and never run two refreshes of one sign-in at once.

Source

pub async fn revoke(&self, token: &str) -> Result<Revocation, Error>

Ends the sign-in behind a refresh token (or access token) at Silicon Accounts (POST /v1/oauth/revoke with Commit’s client_id). Commit hears membership.signed_out with reason app_revoked; the account’s other sign-ins stay. An unknown or already-ended token answers revoked: false with the reason.

Trait Implementations§

Source§

impl Clone for AccountsAuth

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AccountsAuth

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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