botserver/src/core/shared/admin_handlers.rs
Rodrigo Rodriguez e143968179 feat: Add JWT secret rotation and health verification
SEC-02: Implement credential rotation security improvements

- Add JWT secret rotation to rotate-secret command
- Generate 64-character HS512-compatible secrets
- Automatic .env backup with timestamp
- Atomic file updates via temp+rename pattern
- Add health verification for rotated credentials
- Route rotate-secret, rotate-secrets, vault commands in CLI
- Add verification attempts for database and JWT endpoints

Security improvements:
- JWT_SECRET now rotatable (previously impossible)
- Automatic rollback via backup files
- Health checks catch configuration errors
- Clear warnings about token invalidation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-19 19:42:41 +00:00

50 lines
1.3 KiB
Rust

// Helper function to get dashboard members
async fn get_dashboard_members(
state: &AppState,
bot_id: Uuid,
limit: i64,
) -> Result<i64, diesel::result::Error> {
// TODO: Implement actual member fetching logic
// For now, return a placeholder count
Ok(0)
}
// Helper function to get dashboard invitations
async fn get_dashboard_invitations(
state: &AppState,
bot_id: Uuid,
limit: i64,
) -> Result<i64, diesel::result::Error> {
// TODO: Use organization_invitations table when available in model maps
Ok(0)
}
// Helper function to get dashboard bots
async fn get_dashboard_bots(
state: &AppState,
bot_id: Uuid,
limit: i64,
) -> Result<Vec<BotStat>, diesel::result::Error> {
use crate::core::shared::models::schema::bots;
let bot_list = bots::table
.limit(limit)
.load::<crate::core::shared::models::Bot>(&state.conn)?;
let stats = bot_list.into_iter().map(|b| BotStat {
id: b.id,
name: b.name,
count: 1, // Placeholder
}).collect();
Ok(stats)
}
// Helper function to get dashboard activity
async fn get_dashboard_activity(
state: &AppState,
limit: Option<i64>,
) -> Result<Vec<ActivityLog>, diesel::result::Error> {
// Placeholder
Ok(vec![])
}