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    #[sqlx(rename = "publicKey")]
10    pub public_key: String,
11    #[sqlx(rename = "privateKey")]
12    pub private_key: String,
13    #[sqlx(rename = "createdAt")]
14    pub created_at: DateTime<Utc>,
15    #[sqlx(rename = "expiresAt")]
16    pub expires_at: Option<DateTime<Utc>>,
17    pub alg: Option<String>,
18    pub crv: Option<String>,
19}
20
21impl From<Model> for Jwk {
22    fn from(row: Model) -> Self {
23        Self {
24            id: row.id,
25            public_key: row.public_key,
26            private_key: row.private_key,
27            created_at: row.created_at,
28            expires_at: row.expires_at,
29            alg: row.alg,
30            crv: row.crv,
31        }
32    }
33}