a06673b
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize,
)]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum SigningAlgorithm {
#[default]
#[sea_orm(num_value = 0)]
Ed25519,
#[sea_orm(num_value = 1)]
ES256,
#[sea_orm(num_value = 2)]
RS256,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "system_signing_keys")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub kid: Uuid,
pub name: String,
pub algorithm: SigningAlgorithm,
pub public_key: Vec<u8>,
pub private_key_encrypted: Option<Vec<u8>>,
#[sea_orm(unique)]
pub key_hash: String,
#[sea_orm(default_value = "false")]
pub is_active: bool,
#[sea_orm(default_value = "false")]
pub is_signing: bool,
#[sea_orm(default_value = "false")]
pub is_rotating: bool,
pub grace_started_at: Option<OffsetDateTime>,
pub grace_ends_at: Option<OffsetDateTime>,
pub expires_at: Option<OffsetDateTime>,
pub created_at: OffsetDateTime,
pub created_by: Option<Uuid>,
pub rotated_by: Option<Uuid>,
pub revoked_at: Option<OffsetDateTime>,
pub revoked_reason: Option<String>,
pub updated_at: OffsetDateTime,
}
impl ActiveModelBehavior for ActiveModel {}