pub struct Auth { /* private fields */ }Implementations§
Source§impl Auth
impl Auth
Sourcepub fn from_env() -> Option<Arc<Self>>
pub fn from_env() -> Option<Arc<Self>>
密码为空返回 None —— 调用方据此决定「不启用认证」
两个都没配返回 None —— 调用方据此决定「不启用认证」。
两种凭据是并列的,满足任一即放行:
DTMRS_ADMIN_PASSWORD:浏览器登录管理台,拿会话 cookieDTMRS_AUTH_TOKEN:业务服务/SDK 带Authorization: Bearer <token>
Sourcepub fn with_store(self: Arc<Self>, store: Store) -> Arc<Self> ⓘ
pub fn with_store(self: Arc<Self>, store: Store) -> Arc<Self> ⓘ
接上存储,启用「管理台可增删的托管令牌」。
不接的话只有 DTMRS_AUTH_TOKEN 那个静态令牌有效
Sourcepub async fn managed_ok(&self, presented: &str, ip: &str) -> bool
pub async fn managed_ok(&self, presented: &str, ip: &str) -> bool
校验托管令牌。缓存过期就先刷一遍。
命中之后顺手记一次使用(异步 spawn,失败只吞掉)—— 统计信息不值得让一次正常的业务调用失败或变慢。
Sourcepub fn invalidate_cache(&self)
pub fn invalidate_cache(&self)
作废之后立刻让缓存失效,省得等最多 10 秒
Auto Trait Implementations§
impl !Freeze for Auth
impl !RefUnwindSafe for Auth
impl !UnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnsafeUnpin for Auth
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<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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request