Skip to main content

appcore_security/
auth.rs

1// =============================================================================
2//        #######
3//     ###       ###     F: auth.rs
4//    ##   ## ##   ##    P: AppCore-Runtime
5//         ## ##
6//                       C: 2026/05/31 13:38:42 by dnettoRaw
7//    ##   ## ##   ##    U: 2026/07/23 23:50:45 by dnettoRaw
8//      ###########      S: 1.0.1-rc.8
9// =============================================================================
10
11//! Authentication contracts for runtime command and peer entry points.
12
13use appcore_core::{AppId, CommandName, NodeId};
14
15/// Authentication request context.
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub struct AuthContext {
18    /// Application scope.
19    pub app_id: AppId,
20    /// Runtime node scope.
21    pub node_id: NodeId,
22    /// Command being authenticated.
23    pub command_name: CommandName,
24}
25
26/// Authentication decision outcome.
27#[derive(Debug, Clone, PartialEq, Eq)]
28pub enum AuthDecision {
29    /// Authentication succeeded.
30    Allow,
31    /// Authentication failed with a controlled reason.
32    Deny(String),
33}
34
35/// Contract for runtime authenticators.
36pub trait Authenticator {
37    /// Authenticates one Runtime request context.
38    fn authenticate(&self, context: &AuthContext) -> AuthDecision;
39}
40
41#[cfg(test)]
42#[path = "auth_tests.rs"]
43mod tests;