030e59e
zhenyi
refactor(lib): migrate storage and security tier to central lib/config (auth, cache, db, email, jwt, payment, queue, rate_limit, storage)
030e59e
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(Debug, Clone, Copy, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(32))")]
pub enum SshKeyType {
#[sea_orm(string_value = "ssh_rsa")]
SshRsa,
#[sea_orm(string_value = "ssh_ed25519")]
SshEd25519,
#[sea_orm(string_value = "ecdsa_sha2_nistp256")]
EcdsaSha2Nistp256,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "user_ssh_key")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: Uuid,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<crate::user::users::Entity>,
pub key_type: SshKeyType,
#[sea_orm(unique)]
pub fingerprint: String,
pub name: String,
pub content: String,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
pub last_used_at: Option<OffsetDateTime>,
}
impl ActiveModelBehavior for ActiveModel {}