auth_kit 0.1.2

Toolkit for Authentication and Authorization in Rust
Documentation
use auth_kit::auth::auth_z::Authorization;
use auth_kit::error::AuthError;
use auth_kit::model::{AuthContext, Resource, Role, User};

fn main() -> Result<(), AuthError> {
     let user = User {
         email: "abac@example.com".to_string(),
         password_hash: "".to_string(),
         role: Role {
             name: "employee".to_string(),
             permissions: vec![],
         },
         department: "engineering".to_string(),
         clearance_level: 5,
     };

     let resource = Resource {
         department: "engineering".to_string(),
         required_level: 3,
     };

     let context = AuthContext {
         user: Some(user),
         claims: None,
         resource: Some(resource),
     };

     let authorized = Authorization::new("ABAC");
     match authorized {
        Ok(mut auth) => {
            let result = auth.authorize(&context, "", "", None);
            match result {
                Ok(_) => println!("Access granted via ABAC."),
                Err(e) => println!("ABAC check failed: {}", e.to_string()),
            }

        },
        Err(e) => {
            println!("Error initializing Authorization: {}", e.to_string());
        }
     }

     Ok(())
 }