Skip to main content

reifydb_core/interface/
auth.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 ReifyDB
3
4use std::collections::HashMap;
5
6use reifydb_runtime::context::rng::Rng;
7use reifydb_value::Result;
8
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum AuthStep {
11	Authenticated,
12
13	Failed,
14
15	Rejected {
16		reason: String,
17	},
18
19	Challenge {
20		payload: HashMap<String, String>,
21	},
22}
23
24pub trait AuthenticationProvider: Send + Sync {
25	fn method(&self) -> &str;
26
27	fn create(&self, rng: &Rng, config: &HashMap<String, String>) -> Result<HashMap<String, String>>;
28
29	fn authenticate(
30		&self,
31		stored: &HashMap<String, String>,
32		credentials: &HashMap<String, String>,
33	) -> Result<AuthStep>;
34
35	fn verify_challenge(
36		&self,
37		_stored: &HashMap<String, String>,
38		_challenge: &HashMap<String, String>,
39		_credentials: &HashMap<String, String>,
40	) -> Result<AuthStep> {
41		Ok(AuthStep::Failed)
42	}
43}