Skip to main content

alibi_plugins/scim/
authentication.rs

1//! Application-owned inbound bearer verification.
2use alibi_core::store::AuthStore;
3use alibi_core::utils::json::JsValue;
4use alibi_core::{AuthResult, AuthSchema, HttpMethod};
5use async_trait::async_trait;
6/// Actual logical request data supplied to the bearer verifier.
7#[derive(Clone, Debug)]
8pub struct ScimBearerTokenVerificationInput {
9    pub token: String,
10    pub method: HttpMethod,
11    pub path: String,
12    pub headers: std::collections::BTreeMap<String, String>,
13}
14/// Verify an external token and return declared or dynamically resolved claims.
15/// Claims retain trusted Date values and are validated before authorization.
16#[async_trait]
17pub trait ScimBearerTokenVerifier<S: AuthSchema>: Send + Sync {
18    async fn verify_bearer_token(
19        &self,
20        input: &ScimBearerTokenVerificationInput,
21        database: &dyn AuthStore<S>,
22    ) -> AuthResult<Option<JsValue>>;
23}
24pub(super) struct ScimBearerVerifierHandle<S: AuthSchema>(
25    pub std::sync::Arc<dyn ScimBearerTokenVerifier<S>>,
26);