Skip to main content

alibi_plugins/oauth_provider/
signup.rs

1use alibi_core::AuthResult;
2use async_trait::async_trait;
3use std::sync::Arc;
4
5/// Authenticated input to the application's additional registration decision.
6/// Headers come from the physical authorization request, not logical API headers.
7pub type OAuthSignupContext<'a> = super::OAuthInteractionContext<'a>;
8
9/// Better Auth's boolean-or-string signup decision. An empty page string, like
10/// `false`, continues authorization; `true` uses the configured page fallback.
11#[derive(Debug, Clone)]
12pub enum OAuthSignupRedirect {
13    Continue,
14    ConfiguredPage,
15    Page(String),
16}
17
18#[async_trait]
19pub trait OAuthSignupPolicy: Send + Sync + std::fmt::Debug {
20    async fn should_redirect(
21        &self,
22        input: OAuthSignupContext<'_>,
23    ) -> AuthResult<OAuthSignupRedirect>;
24}
25
26#[derive(Debug, Clone, Default)]
27pub struct OAuthSignupConfig {
28    pub page: Option<String>,
29    pub should_redirect: Option<Arc<dyn OAuthSignupPolicy>>,
30}