Skip to main content

alibi_sqlx/store/entities/
jwk.rs

1use crate::SqlxModel;
2use alibi_core::types::Jwk;
3use chrono::{DateTime, Utc};
4
5#[derive(Clone, Debug, PartialEq, Eq, sqlx::FromRow, SqlxModel)]
6#[auth(table = "jwks")]
7pub struct Model {
8    pub id: String,
9    pub public_key: String,
10    pub private_key: String,
11    pub created_at: DateTime<Utc>,
12    pub expires_at: Option<DateTime<Utc>>,
13    pub alg: Option<String>,
14    pub crv: Option<String>,
15}
16
17impl From<Model> for Jwk {
18    fn from(row: Model) -> Self {
19        Self {
20            id: row.id,
21            public_key: row.public_key,
22            private_key: row.private_key,
23            created_at: row.created_at,
24            expires_at: row.expires_at,
25            alg: row.alg,
26            crv: row.crv,
27        }
28    }
29}