Skip to main content

better_auth_core/config/
identity.rs

1use super::*;
2#[derive(Debug, Clone, Default)]
3pub struct UserConfig {
4    pub additional_fields: crate::field_policy::FieldConfigs,
5}
6
7/// Initialized identifier, persistence and cleanup policy for verification values.
8#[derive(Clone, Default)]
9pub struct VerificationConfig {
10    /// Keep globally expired verification rows during lookup. Default: false.
11    /// An atomic consume still invalidates an expired proof it selects.
12    pub disable_cleanup: bool,
13    /// Persist verification values alongside secondary storage. Without a
14    /// secondary backend, verification values always use the database.
15    pub store_in_database: bool,
16    /// Global identifier policy, applied after a plugin's own value codec.
17    pub store_identifier: crate::verification::VerificationIdentifierPolicy,
18    /// Optional shared secondary backend. Single-use values require its atomic
19    /// `get_and_delete` operation. This config does not change session storage.
20    pub secondary_storage: Option<Arc<dyn crate::store::CacheAdapter>>,
21}
22
23impl std::fmt::Debug for VerificationConfig {
24    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25        f.debug_struct("VerificationConfig")
26            .field("disable_cleanup", &self.disable_cleanup)
27            .field("store_in_database", &self.store_in_database)
28            .field("store_identifier", &self.store_identifier)
29            .field("secondary_storage", &self.secondary_storage.is_some())
30            .finish()
31    }
32}
33
34/// Password strength rules. Length limits belong to the email/password plugin
35/// (`password_min_length`, `password_max_length`). Built-in hashing uses
36/// pinned scrypt parameters.
37#[derive(Debug, Clone, Default)]
38#[expect(
39    clippy::struct_excessive_bools,
40    reason = "Independent configuration switches model distinct upstream behavior, rather than mutually exclusive states"
41)]
42pub struct PasswordConfig {
43    /// Require uppercase letters
44    pub require_uppercase: bool,
45
46    /// Require lowercase letters
47    pub require_lowercase: bool,
48
49    /// Require numbers
50    pub require_numbers: bool,
51
52    /// Require special characters
53    pub require_special: bool,
54}