auth-framework 0.4.2

A comprehensive, production-ready authentication and authorization framework for Rust applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
//! Builder patterns and ergonomic helpers for the Auth Framework
//!
//! This module provides fluent builder APIs and helper functions to make
//! common authentication setup tasks easier and more discoverable.
//!
//! # Quick Start Builders
//!
//! For the most common setups, use the quick start builders:
//!
//! ```rust,no_run
//! use auth_framework::prelude::*;
//!
//! // Simple JWT auth with environment variables
//! let auth = AuthFramework::quick_start()
//!     .jwt_auth_from_env()
//!     .build().await?;
//!
//! // Web app with database
//! let auth = AuthFramework::quick_start()
//!     .jwt_auth("your-secret-key")
//!     .with_postgres("postgresql://...")
//!     .with_axum()
//!     .build().await?;
//! ```
//!
//! # Preset Configurations
//!
//! Use presets for common security and performance configurations:
//!
//! ```rust,no_run
//! use auth_framework::prelude::*;
//!
//! let auth = AuthFramework::new()
//!     .security_preset(SecurityPreset::HighSecurity)
//!     .performance_preset(PerformancePreset::LowLatency)
//!     .build().await?;
//! ```
//!
//! # Use Case Templates
//!
//! Get started quickly with templates for common use cases:
//!
//! ```rust,no_run
//! use auth_framework::prelude::*;
//!
//! // Configure for web application
//! let auth = AuthFramework::for_use_case(UseCasePreset::WebApp)
//!     .customize(|config| {
//!         config.token_lifetime(hours(24))
//!               .enable_sessions(true)
//!     })
//!     .build().await?;
//! ```

use crate::{
    AuthConfig, AuthError, AuthFramework,
    config::{RateLimitConfig, SecurityConfig, StorageConfig},
    prelude::{PerformancePreset, UseCasePreset, days, hours, minutes},
    security::SecurityPreset,
};
use std::time::Duration;

/// Main builder for AuthFramework with fluent API
#[derive(Debug)]
pub struct AuthBuilder {
    config: AuthConfig,
    security_preset: Option<SecurityPreset>,
    performance_preset: Option<PerformancePreset>,
    use_case_preset: Option<UseCasePreset>,
}

/// Quick start builder for common authentication setups
#[derive(Debug)]
pub struct QuickStartBuilder {
    auth_method: Option<QuickStartAuth>,
    storage: Option<QuickStartStorage>,
    framework: Option<QuickStartFramework>,
    security_level: SecurityPreset,
}

/// Authentication method configuration for quick start
#[derive(Debug)]
pub enum QuickStartAuth {
    Jwt {
        secret: String,
    },
    JwtFromEnv,
    OAuth2 {
        client_id: String,
        client_secret: String,
    },
    Combined {
        jwt_secret: String,
        oauth_client_id: String,
        oauth_client_secret: String,
    },
}

/// Storage configuration for quick start
#[derive(Debug)]
pub enum QuickStartStorage {
    Memory,
    Postgres(String),
    PostgresFromEnv,
    Redis(String),
    RedisFromEnv,
}

/// Web framework integration for quick start
#[derive(Debug)]
pub enum QuickStartFramework {
    Axum,
    ActixWeb,
    Warp,
}

impl AuthFramework {
    /// Create a new builder for the authentication framework
    pub fn builder() -> AuthBuilder {
        AuthBuilder::new()
    }

    /// Quick start builder for common setups
    pub fn quick_start() -> QuickStartBuilder {
        QuickStartBuilder::new()
    }

    /// Create a builder for a specific use case
    pub fn for_use_case(use_case: UseCasePreset) -> AuthBuilder {
        AuthBuilder::new().use_case_preset(use_case)
    }

    /// Create an authentication framework with preset configuration
    pub fn preset(preset: SecurityPreset) -> AuthBuilder {
        AuthBuilder::new().security_preset(preset)
    }
}

impl AuthBuilder {
    /// Create a new builder with default configuration
    pub fn new() -> Self {
        Self {
            config: AuthConfig::default(),
            security_preset: None,
            performance_preset: None,
            use_case_preset: None,
        }
    }

    /// Apply a security preset
    pub fn security_preset(mut self, preset: SecurityPreset) -> Self {
        self.security_preset = Some(preset);
        self
    }

    /// Apply a performance preset
    pub fn performance_preset(mut self, preset: PerformancePreset) -> Self {
        self.performance_preset = Some(preset);
        self
    }

    /// Apply a use case preset
    pub fn use_case_preset(mut self, preset: UseCasePreset) -> Self {
        self.use_case_preset = Some(preset);
        self
    }

    /// Configure JWT authentication
    pub fn with_jwt(self) -> JwtBuilder {
        JwtBuilder::new(self)
    }

    /// Configure OAuth2 authentication
    pub fn with_oauth2(self) -> OAuth2Builder {
        OAuth2Builder::new(self)
    }

    /// Configure storage backend
    pub fn with_storage(self) -> StorageBuilder {
        StorageBuilder::new(self)
    }

    /// Configure rate limiting
    pub fn with_rate_limiting(self) -> RateLimitBuilder {
        RateLimitBuilder::new(self)
    }

    /// Configure security settings
    pub fn with_security(self) -> SecurityBuilder {
        SecurityBuilder::new(self)
    }

    /// Configure audit logging
    pub fn with_audit(self) -> AuditBuilder {
        AuditBuilder::new(self)
    }

    /// Customize configuration with a closure
    pub fn customize<F>(mut self, f: F) -> Self
    where
        F: FnOnce(&mut AuthConfig) -> &mut AuthConfig,
    {
        f(&mut self.config);
        self
    }

    /// Build the authentication framework
    pub async fn build(mut self) -> Result<AuthFramework, AuthError> {
        // Apply presets before building
        if let Some(preset) = self.security_preset.take() {
            self.config.security = self.apply_security_preset(preset);
        }

        if let Some(preset) = self.performance_preset.take() {
            self.apply_performance_preset(preset);
        }

        if let Some(preset) = self.use_case_preset.take() {
            self.apply_use_case_preset(preset);
        }

        // Validate configuration
        self.config.validate()?;

        // Create and initialize framework
        let mut framework = AuthFramework::new(self.config);
        framework.initialize().await?;

        Ok(framework)
    }

    fn apply_security_preset(&self, preset: SecurityPreset) -> SecurityConfig {
        match preset {
            SecurityPreset::Development => SecurityConfig::development(),
            SecurityPreset::Balanced => SecurityConfig::default(),
            SecurityPreset::HighSecurity | SecurityPreset::Paranoid => SecurityConfig::secure(),
        }
    }

    fn apply_performance_preset(&mut self, preset: PerformancePreset) {
        match preset {
            PerformancePreset::HighThroughput => {
                // Optimize for throughput
                self.config.rate_limiting.max_requests = 1000;
                self.config.rate_limiting.window = Duration::from_secs(60);
            }
            PerformancePreset::LowLatency => {
                // Optimize for latency
                self.config.token_lifetime = hours(1);
                self.config.rate_limiting.max_requests = 100;
                self.config.rate_limiting.window = Duration::from_secs(60);
            }
            PerformancePreset::LowMemory => {
                // Optimize for memory usage
                self.config.token_lifetime = minutes(15);
                self.config.refresh_token_lifetime = hours(2);
            }
            PerformancePreset::Balanced => {
                // Keep defaults
            }
        }
    }

    fn apply_use_case_preset(&mut self, preset: UseCasePreset) {
        match preset {
            UseCasePreset::WebApp => {
                self.config.token_lifetime = hours(24);
                self.config.refresh_token_lifetime = days(7);
                self.config.security.secure_cookies = true;
                self.config.security.csrf_protection = true;
            }
            UseCasePreset::ApiService => {
                self.config.token_lifetime = hours(1);
                self.config.refresh_token_lifetime = hours(24);
                self.config.rate_limiting.enabled = true;
                self.config.rate_limiting.max_requests = 1000;
            }
            UseCasePreset::Microservices => {
                self.config.token_lifetime = minutes(15);
                self.config.refresh_token_lifetime = hours(1);
                self.config.audit.enabled = true;
            }
            UseCasePreset::MobileBackend => {
                self.config.token_lifetime = hours(1);
                self.config.refresh_token_lifetime = days(30);
                self.config.security.secure_cookies = false; // Mobile doesn't use cookies
            }
            UseCasePreset::Enterprise => {
                self.config.enable_multi_factor = true;
                self.config.security = SecurityConfig::secure();
                self.config.audit.enabled = true;
                self.config.audit.log_success = true;
                self.config.audit.log_failures = true;
            }
        }
    }
}

impl QuickStartBuilder {
    fn new() -> Self {
        Self {
            auth_method: None,
            storage: None,
            framework: None,
            security_level: SecurityPreset::Balanced,
        }
    }

    /// Configure JWT authentication with a secret key
    pub fn jwt_auth(mut self, secret: impl Into<String>) -> Self {
        self.auth_method = Some(QuickStartAuth::Jwt {
            secret: secret.into(),
        });
        self
    }

    /// Configure JWT authentication from JWT_SECRET environment variable
    pub fn jwt_auth_from_env(mut self) -> Self {
        self.auth_method = Some(QuickStartAuth::JwtFromEnv);
        self
    }

    /// Configure OAuth2 authentication
    pub fn oauth2_auth(
        mut self,
        client_id: impl Into<String>,
        client_secret: impl Into<String>,
    ) -> Self {
        self.auth_method = Some(QuickStartAuth::OAuth2 {
            client_id: client_id.into(),
            client_secret: client_secret.into(),
        });
        self
    }

    /// Configure both JWT and OAuth2 authentication
    pub fn combined_auth(
        mut self,
        jwt_secret: impl Into<String>,
        oauth_client_id: impl Into<String>,
        oauth_client_secret: impl Into<String>,
    ) -> Self {
        self.auth_method = Some(QuickStartAuth::Combined {
            jwt_secret: jwt_secret.into(),
            oauth_client_id: oauth_client_id.into(),
            oauth_client_secret: oauth_client_secret.into(),
        });
        self
    }

    /// Use PostgreSQL storage with connection string
    pub fn with_postgres(mut self, connection_string: impl Into<String>) -> Self {
        self.storage = Some(QuickStartStorage::Postgres(connection_string.into()));
        self
    }

    /// Use PostgreSQL storage from DATABASE_URL environment variable
    pub fn with_postgres_from_env(mut self) -> Self {
        self.storage = Some(QuickStartStorage::PostgresFromEnv);
        self
    }

    /// Use Redis storage with connection string
    pub fn with_redis(mut self, connection_string: impl Into<String>) -> Self {
        self.storage = Some(QuickStartStorage::Redis(connection_string.into()));
        self
    }

    /// Use Redis storage from REDIS_URL environment variable
    pub fn with_redis_from_env(mut self) -> Self {
        self.storage = Some(QuickStartStorage::RedisFromEnv);
        self
    }

    /// Use in-memory storage (development only)
    pub fn with_memory_storage(mut self) -> Self {
        self.storage = Some(QuickStartStorage::Memory);
        self
    }

    /// Configure for Axum web framework
    pub fn with_axum(mut self) -> Self {
        self.framework = Some(QuickStartFramework::Axum);
        self
    }

    /// Configure for Actix Web framework
    pub fn with_actix(mut self) -> Self {
        self.framework = Some(QuickStartFramework::ActixWeb);
        self
    }

    /// Configure for Warp web framework
    pub fn with_warp(mut self) -> Self {
        self.framework = Some(QuickStartFramework::Warp);
        self
    }

    /// Set security level
    pub fn security_level(mut self, level: SecurityPreset) -> Self {
        self.security_level = level;
        self
    }

    /// Build the authentication framework
    pub async fn build(self) -> Result<AuthFramework, AuthError> {
        let mut builder = AuthBuilder::new().security_preset(self.security_level);

        // Configure authentication method
        match self.auth_method {
            Some(QuickStartAuth::Jwt { secret }) => {
                builder = builder.with_jwt().secret(secret).done();
            }
            Some(QuickStartAuth::JwtFromEnv) => {
                let secret = std::env::var("JWT_SECRET").map_err(|_| {
                    AuthError::config("JWT_SECRET environment variable is required")
                })?;
                builder = builder.with_jwt().secret(secret).done();
            }
            Some(QuickStartAuth::OAuth2 {
                client_id,
                client_secret,
            }) => {
                builder = builder
                    .with_oauth2()
                    .client_id(client_id)
                    .client_secret(client_secret)
                    .done();
            }
            Some(QuickStartAuth::Combined {
                jwt_secret,
                oauth_client_id,
                oauth_client_secret,
            }) => {
                builder = builder
                    .with_jwt()
                    .secret(jwt_secret)
                    .done()
                    .with_oauth2()
                    .client_id(oauth_client_id)
                    .client_secret(oauth_client_secret)
                    .done();
            }
            None => {
                return Err(AuthError::config("Authentication method is required"));
            }
        }

        // Configure storage
        match self.storage {
            Some(QuickStartStorage::Memory) => {
                builder = builder.with_storage().memory().done();
            }
            Some(QuickStartStorage::Postgres(conn_str)) => {
                builder = builder.with_storage().postgres(conn_str).done();
            }
            Some(QuickStartStorage::PostgresFromEnv) => {
                let conn_str = std::env::var("DATABASE_URL").map_err(|_| {
                    AuthError::config("DATABASE_URL environment variable is required")
                })?;
                builder = builder.with_storage().postgres(conn_str).done();
            }
            Some(QuickStartStorage::Redis(_conn_str)) => {
                // Redis storage not yet implemented, fallback to memory
                builder = builder.with_storage().memory().done();
            }
            Some(QuickStartStorage::RedisFromEnv) => {
                // Redis storage not yet implemented, fallback to memory
                builder = builder.with_storage().memory().done();
            }
            None => {
                // Default to memory storage for quick start
                builder = builder.with_storage().memory().done();
            }
        }

        builder.build().await
    }
}

/// JWT configuration builder
pub struct JwtBuilder {
    parent: AuthBuilder,
    secret: Option<String>,
    issuer: Option<String>,
    audience: Option<String>,
    token_lifetime: Option<Duration>,
}

impl JwtBuilder {
    fn new(parent: AuthBuilder) -> Self {
        Self {
            parent,
            secret: None,
            issuer: None,
            audience: None,
            token_lifetime: None,
        }
    }

    /// Set JWT secret key
    pub fn secret(mut self, secret: impl Into<String>) -> Self {
        self.secret = Some(secret.into());
        self
    }

    /// Load JWT secret from environment variable
    pub fn secret_from_env(mut self, env_var: &str) -> Self {
        if let Ok(secret) = std::env::var(env_var) {
            self.secret = Some(secret);
        }
        self
    }

    /// Set JWT issuer
    pub fn issuer(mut self, issuer: impl Into<String>) -> Self {
        self.issuer = Some(issuer.into());
        self
    }

    /// Set JWT audience
    pub fn audience(mut self, audience: impl Into<String>) -> Self {
        self.audience = Some(audience.into());
        self
    }

    /// Set token lifetime
    pub fn token_lifetime(mut self, lifetime: Duration) -> Self {
        self.token_lifetime = Some(lifetime);
        self
    }

    /// Complete JWT configuration and return to main builder
    pub fn done(mut self) -> AuthBuilder {
        if let Some(secret) = self.secret {
            self.parent.config.secret = Some(secret);
        }
        if let Some(issuer) = self.issuer {
            self.parent.config.issuer = issuer;
        }
        if let Some(audience) = self.audience {
            self.parent.config.audience = audience;
        }
        if let Some(lifetime) = self.token_lifetime {
            self.parent.config.token_lifetime = lifetime;
        }
        self.parent
    }
}

/// OAuth2 configuration builder
pub struct OAuth2Builder {
    parent: AuthBuilder,
    client_id: Option<String>,
    client_secret: Option<String>,
    redirect_uri: Option<String>,
}

impl OAuth2Builder {
    fn new(parent: AuthBuilder) -> Self {
        Self {
            parent,
            client_id: None,
            client_secret: None,
            redirect_uri: None,
        }
    }

    /// Set OAuth2 client ID
    pub fn client_id(mut self, client_id: impl Into<String>) -> Self {
        self.client_id = Some(client_id.into());
        self
    }

    /// Set OAuth2 client secret
    pub fn client_secret(mut self, client_secret: impl Into<String>) -> Self {
        self.client_secret = Some(client_secret.into());
        self
    }

    /// Set redirect URI
    pub fn redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
        self.redirect_uri = Some(redirect_uri.into());
        self
    }

    /// Configure Google OAuth2
    pub fn google_client_id(self, client_id: impl Into<String>) -> Self {
        self.client_id(client_id)
    }

    /// Configure GitHub OAuth2
    pub fn github_client_id(self, client_id: impl Into<String>) -> Self {
        self.client_id(client_id)
    }

    /// Complete OAuth2 configuration and return to main builder
    pub fn done(self) -> AuthBuilder {
        // OAuth2 configuration would be stored in method_configs
        // This is a simplified version
        self.parent
    }
}

/// Storage configuration builder
pub struct StorageBuilder {
    parent: AuthBuilder,
}

impl StorageBuilder {
    fn new(parent: AuthBuilder) -> Self {
        Self { parent }
    }

    /// Configure in-memory storage
    pub fn memory(mut self) -> Self {
        self.parent.config.storage = StorageConfig::Memory;
        self
    }

    /// Configure PostgreSQL storage
    #[cfg(feature = "postgres-storage")]
    pub fn postgres(mut self, connection_string: impl Into<String>) -> Self {
        self.parent.config.storage = StorageConfig::Postgres {
            connection_string: connection_string.into(),
            table_prefix: "auth_".to_string(),
        };
        self
    }

    /// Configure PostgreSQL storage from environment
    #[cfg(feature = "postgres-storage")]
    pub fn postgres_from_env(mut self) -> Self {
        if let Ok(conn_str) = std::env::var("DATABASE_URL") {
            self = self.postgres(conn_str);
        }
        self
    }

    /// Configure Redis storage
    #[cfg(feature = "redis-storage")]
    pub fn redis(mut self, url: impl Into<String>) -> Self {
        self.parent.config.storage = StorageConfig::Redis {
            url: url.into(),
            key_prefix: "auth:".to_string(),
        };
        self
    }

    /// Configure Redis storage from environment
    #[cfg(feature = "redis-storage")]
    pub fn redis_from_env(mut self) -> Self {
        if let Ok(url) = std::env::var("REDIS_URL") {
            self = self.redis(url);
        }
        self
    }

    /// Set connection pool size
    pub fn connection_pool_size(self, _size: u32) -> Self {
        // This would be implemented when storage supports connection pooling
        self
    }

    /// Complete storage configuration and return to main builder
    pub fn done(self) -> AuthBuilder {
        self.parent
    }
}

/// Rate limiting configuration builder
pub struct RateLimitBuilder {
    parent: AuthBuilder,
}

impl RateLimitBuilder {
    fn new(parent: AuthBuilder) -> Self {
        Self { parent }
    }

    /// Configure rate limiting per IP
    pub fn per_ip(mut self, (requests, window): (u32, Duration)) -> Self {
        self.parent.config.rate_limiting = RateLimitConfig {
            enabled: true,
            max_requests: requests,
            window,
            burst: requests / 10,
        };
        self
    }

    /// Disable rate limiting
    pub fn disabled(mut self) -> Self {
        self.parent.config.rate_limiting.enabled = false;
        self
    }

    /// Complete rate limiting configuration and return to main builder
    pub fn done(self) -> AuthBuilder {
        self.parent
    }
}

/// Security configuration builder
pub struct SecurityBuilder {
    parent: AuthBuilder,
}

impl SecurityBuilder {
    fn new(parent: AuthBuilder) -> Self {
        Self { parent }
    }

    /// Set minimum password length
    pub fn min_password_length(mut self, length: usize) -> Self {
        self.parent.config.security.min_password_length = length;
        self
    }

    /// Enable/disable password complexity requirements
    pub fn require_password_complexity(mut self, required: bool) -> Self {
        self.parent.config.security.require_password_complexity = required;
        self
    }

    /// Enable/disable secure cookies
    pub fn secure_cookies(mut self, enabled: bool) -> Self {
        self.parent.config.security.secure_cookies = enabled;
        self
    }

    /// Complete security configuration and return to main builder
    pub fn done(self) -> AuthBuilder {
        self.parent
    }
}

/// Audit configuration builder
pub struct AuditBuilder {
    parent: AuthBuilder,
}

impl AuditBuilder {
    fn new(parent: AuthBuilder) -> Self {
        Self { parent }
    }

    /// Enable audit logging
    pub fn enabled(mut self, enabled: bool) -> Self {
        self.parent.config.audit.enabled = enabled;
        self
    }

    /// Log successful authentications
    pub fn log_success(mut self, enabled: bool) -> Self {
        self.parent.config.audit.log_success = enabled;
        self
    }

    /// Log failed authentications
    pub fn log_failures(mut self, enabled: bool) -> Self {
        self.parent.config.audit.log_failures = enabled;
        self
    }

    /// Complete audit configuration and return to main builder
    pub fn done(self) -> AuthBuilder {
        self.parent
    }
}

impl Default for AuthBuilder {
    fn default() -> Self {
        Self::new()
    }
}