pub struct StaticTokenAuth { /* private fields */ }Expand description
An AuthProvider holding one fixed secret credential.
A credential may be host-scoped (StaticTokenAuth::bearer_scoped): it is
then sent only to that host (or its subdomains), so a page that links to a
foreign host reached via an in-scope crawl can never exfiltrate the token.
Implementations§
Source§impl StaticTokenAuth
impl StaticTokenAuth
Sourcepub fn bearer(token: impl Into<String>) -> Self
pub fn bearer(token: impl Into<String>) -> Self
Authorization: Bearer <token>, sent to any host.
Prefer StaticTokenAuth::bearer_scoped for private crawls so the token is
confined to the intended host.
Sourcepub fn bearer_scoped(
token: impl Into<String>,
host: impl Into<CompactString>,
) -> Self
pub fn bearer_scoped( token: impl Into<String>, host: impl Into<CompactString>, ) -> Self
Authorization: Bearer <token>, sent only to host and its subdomains.
Sourcepub fn github_pat(token: impl Into<String>) -> Self
pub fn github_pat(token: impl Into<String>) -> Self
A GitHub personal access token (sent as a bearer token, which the GitHub REST API accepts).
Trait Implementations§
Source§impl AuthProvider for StaticTokenAuth
impl AuthProvider for StaticTokenAuth
Source§type RefreshFuture<'a> = Ready<Result<(), Error>>
type RefreshFuture<'a> = Ready<Result<(), Error>>
The future returned by
AuthProvider::refresh. Static providers use
std::future::Ready; OAuth uses its token-exchange future.Source§fn credential(&self, resource: &Resource) -> Credential<'_>
fn credential(&self, resource: &Resource) -> Credential<'_>
The credential to apply to a request for
resource. Synchronous and
lock-free — this is the per-fetch hot path.Source§fn refresh(&self) -> Self::RefreshFuture<'_>
fn refresh(&self) -> Self::RefreshFuture<'_>
Refresh an expiring credential. Static providers return a ready no-op.
Source§fn needs_refresh(&self) -> bool
fn needs_refresh(&self) -> bool
Whether the cached credential is missing or near expiry. Default: never.
Auto Trait Implementations§
impl Freeze for StaticTokenAuth
impl RefUnwindSafe for StaticTokenAuth
impl Send for StaticTokenAuth
impl Sync for StaticTokenAuth
impl Unpin for StaticTokenAuth
impl UnsafeUnpin for StaticTokenAuth
impl UnwindSafe for StaticTokenAuth
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<A> DynAuthProvider for Awhere
A: AuthProvider,
impl<A> DynAuthProvider for Awhere
A: AuthProvider,
Source§fn credential(&self, resource: &Resource) -> Credential<'_>
fn credential(&self, resource: &Resource) -> Credential<'_>
Source§fn needs_refresh(&self) -> bool
fn needs_refresh(&self) -> bool
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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> ⓘ
Converts
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> ⓘ
Converts
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