pub struct AIdCredentialValidator;Expand description
AId Token 验证器 - 静态方法验证 AIdCredential(Ed25519 签名)
Implementations§
Source§impl AIdCredentialValidator
impl AIdCredentialValidator
Sourcepub async fn init(sqlite_path: &Path) -> Result<(), AidError>
pub async fn init(sqlite_path: &Path) -> Result<(), AidError>
初始化全局 KeyCache 实例(通常在服务启动时调用一次)
可多次调用,首次调用有效;后续调用被忽略(幂等)。
Sourcepub async fn check(
credential: &AIdCredential,
realm_id: u32,
) -> Result<(IdentityClaims, bool), AidError>
pub async fn check( credential: &AIdCredential, realm_id: u32, ) -> Result<(IdentityClaims, bool), AidError>
校验 AIdCredential:Ed25519 签名验证 + realm_id 检查
§Returns
Ok((IdentityClaims, false)) — Ed25519 模式无容忍期概念,第二个值恒为 false
Sourcepub async fn get_key_bytes(key_id: u32) -> Result<Option<Vec<u8>>, AidError>
pub async fn get_key_bytes(key_id: u32) -> Result<Option<Vec<u8>>, AidError>
返回 key_id 对应的 Ed25519 公钥字节(用于 GetSigningKeyRequest 响应)
Sourcepub async fn populate_key(
key_id: u32,
verifying_key: &VerifyingKey,
expires_at: u64,
) -> Result<(), AidError>
pub async fn populate_key( key_id: u32, verifying_key: &VerifyingKey, expires_at: u64, ) -> Result<(), AidError>
将 Ed25519 verifying key 写入全局 KeyCache(由 AIS 签发器调用)
AIS 在加载或刷新 signing key 后调用此方法,让 signaling 等服务能验证凭证。
若 KeyCache 尚未初始化(init 未调用),此方法是无操作(non-fatal)。
Sourcepub async fn persist_key(
sqlite_path: &Path,
key_id: u32,
verifying_key: &VerifyingKey,
expires_at: u64,
) -> Result<(), AidError>
pub async fn persist_key( sqlite_path: &Path, key_id: u32, verifying_key: &VerifyingKey, expires_at: u64, ) -> Result<(), AidError>
将 Ed25519 verifying key 持久化写入 SQLite DB,无需 KeyCache 已初始化。
供 AIS 签发器在 init 调用前写入密钥,确保后续 init 能从 DB 读取到该密钥。
若全局 KeyCache 已初始化,同时更新内存缓存。
Sourcepub fn check_sync(
credential: &AIdCredential,
realm_id: u32,
) -> Result<IdentityClaims, AidError>
pub fn check_sync( credential: &AIdCredential, realm_id: u32, ) -> Result<IdentityClaims, AidError>
同步校验(用于非 async 上下文,如 TURN 认证)
Auto Trait Implementations§
impl Freeze for AIdCredentialValidator
impl RefUnwindSafe for AIdCredentialValidator
impl Send for AIdCredentialValidator
impl Sync for AIdCredentialValidator
impl Unpin for AIdCredentialValidator
impl UnsafeUnpin for AIdCredentialValidator
impl UnwindSafe for AIdCredentialValidator
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