systemprompt-users 0.2.2

User management for systemprompt.io AI governance infrastructure. 6-tier RBAC, sessions, IP bans, and role-scoped access control for the MCP governance pipeline.
Documentation
mod listing;
mod queries;
mod types;

use std::sync::Arc;

use anyhow::Result;
use sqlx::PgPool;
use systemprompt_database::DbPool;

pub use types::{BanDuration, BanIpParams, BanIpWithMetadataParams, BannedIp};

#[derive(Clone, Debug)]
pub struct BannedIpRepository {
    pool: Arc<PgPool>,
    write_pool: Arc<PgPool>,
}

impl BannedIpRepository {
    pub fn new(db: &DbPool) -> Result<Self> {
        let pool = db.pool_arc()?;
        let write_pool = db.write_pool_arc()?;
        Ok(Self { pool, write_pool })
    }

    pub fn from_pool(pool: Arc<PgPool>) -> Self {
        let write_pool = Arc::clone(&pool);
        Self { pool, write_pool }
    }
}