Skip to main content

Credentials

Struct Credentials 

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

The credential sources of every service.

Implementations§

Source§

impl Credentials

Source

pub fn from_system(config: &Config) -> Self

Uses the process environment, the signed-in accounts and the real gh CLI.

Source

pub fn new( config: &Config, environment: impl Environment + 'static, runner: impl Runner + 'static, ) -> Self

Signed-in accounts are kept in memory until Self::with_signed_in.

Source

pub fn with_signed_in(self, accounts: SignedInAccounts) -> Self

Reads and keeps signed-in accounts in accounts.

Source

pub fn with_sign_in_offered(self, offered: bool) -> Self

Whether the app offers Sign in with GitHub (it has an OAuth App). Guidance names it only then; the credential order is the same.

Source

pub fn sign_in_offered(&self) -> bool

Source

pub fn github(&self, login: Option<&str>) -> Result<Credential, CredentialError>

The GitHub credential. Without an environment or config token, the token of login’s account, or of gh’s active account (else the first account) when login is None.

Source

pub fn account(&self, login: &str) -> Result<Credential, CredentialError>

The token of exactly the account login: its sign-in through Subspace, else its gh CLI token. GH_TOKEN, GITHUB_TOKEN and the config file token are ignored.

Source

pub fn sign_in( &self, login: &str, token: &Secret, ) -> Result<(), CredentialError>

Keeps a new sign-in of login, replacing an earlier one.

Source

pub fn sign_out(&self, login: &str) -> Result<Option<Secret>, CredentialError>

Forgets the sign-in of login and gives back its token, so it can be revoked. gh’s own account of the same login is not changed.

Source

pub fn gh_cli(&self, login: &str) -> Result<Credential, CredentialError>

The gh CLI token of exactly login, ignoring GH_TOKEN, GITHUB_TOKEN and the config file token.

Source

pub fn github_accounts(&self) -> Result<GitHubAccounts, CredentialError>

The github.com accounts: those signed in through Subspace and gh’s, from hosts.yml in gh’s config directory. Only logins are read, never token values.

Source

pub fn invalidate(&self, credential: &Credential)

Drops a cached token after the service rejected it (REQ-22), so the next call asks again. A rejected signed-in token marks its account as needing sign-in again.

Source

pub fn forget_gh_token(&self, login: &str)

Drops the cached gh token of login, such as after a new sign-in.

Auto Trait Implementations§

§

impl !Freeze for Credentials

§

impl !RefUnwindSafe for Credentials

§

impl !UnwindSafe for Credentials

§

impl Forget for Credentials

§

impl Move for Credentials

§

impl Send for Credentials
where BoxRaw<dyn Environment>: Send, BoxRaw<dyn Runner>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, RawVecInner: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, NodeRef<Owned, String, bool, LeafOrInternal>: Send, BoxRaw<(String, bool)>: Send, NodeRef<Owned, String, Map<String, Value>, LeafOrInternal>: Send, BoxRaw<(String, Map<String, Value>)>: Send, NodeRef<Owned, String, Secret, LeafOrInternal>: Send, BoxRaw<(String, Secret)>: Send, Mutex<Vec<SignedInAccount>>: Send, BoxRaw<dyn Vault>: Send, Mutex<HashMap<String, Secret>>: Send,

§

impl Sync for Credentials
where BoxRaw<dyn Environment>: Sync, BoxRaw<dyn Runner>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, RawVecInner: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, NodeRef<Owned, String, bool, LeafOrInternal>: Sync, BoxRaw<(String, bool)>: Sync, NodeRef<Owned, String, Map<String, Value>, LeafOrInternal>: Sync, BoxRaw<(String, Map<String, Value>)>: Sync, NodeRef<Owned, String, Secret, LeafOrInternal>: Sync, BoxRaw<(String, Secret)>: Sync, Mutex<Vec<SignedInAccount>>: Sync, BoxRaw<dyn Vault>: Sync, Mutex<HashMap<String, Secret>>: Sync,

§

impl Unpin for Credentials
where Box<dyn Environment>: Unpin, Box<dyn Runner>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, *const LeafNode<String, bool> is !null: Unpin, Box<(String, bool)>: Unpin, *const LeafNode<String, Map<String, Value>> is !null: Unpin, Box<(String, Map<String, Value>)>: Unpin, *const LeafNode<String, Secret> is !null: Unpin, Box<(String, Secret)>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, Box<dyn Vault>: Unpin,

§

impl UnsafeUnpin for Credentials

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<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> 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<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