summaryrefslogtreecommitdiff
path: root/src/services/mod.rs
blob: 26d74e33cdd4bc5ea014f3799226ddcbd391761f (plain)
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
use anyhow::Result;
use std::collections::HashMap;

/// Service trait for client authentication
pub trait ClientAuthenticator: Send + Sync {
    fn authenticate(
        &self,
        params: &HashMap<String, String>,
        auth_header: Option<&str>,
    ) -> Result<(String, String), String>; // Returns (client_id, client_secret)
}

/// Service trait for rate limiting
pub trait RateLimiter: Send + Sync {
    fn check_rate_limit(&self, identifier: &str, endpoint: &str) -> Result<()>;
}

/// Service trait for audit logging
pub trait AuditLogger: Send + Sync {
    fn log_event(
        &self,
        event_type: &str,
        client_id: Option<&str>,
        user_id: Option<&str>,
        ip_address: Option<&str>,
        success: bool,
        details: Option<&str>,
    ) -> Result<()>;
}

/// Service trait for token generation
pub trait TokenGenerator: Send + Sync {
    fn generate_access_token(
        &self,
        user_id: &str,
        client_id: &str,
        scope: &Option<String>,
        token_id: &str,
    ) -> Result<String, String>;

    fn generate_refresh_token(
        &self,
        client_id: &str,
        user_id: &str,
        scope: &Option<String>,
    ) -> Result<String, String>;
}

pub mod implementations;