Skip to main content

swarmhive_api_types/
identity.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use utoipa::ToSchema;
4use uuid::Uuid;
5
6/// Where a user's identity comes from. New providers are added by extending
7/// this enum *and* the [`IdentityProvider`] adapter on the server side.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]
9#[serde(rename_all = "snake_case")]
10pub enum IdentityProvider {
11    /// Local email + argon2id password.
12    Password,
13    /// GitHub OAuth.
14    Github,
15}
16
17/// Link between a user and an external identity provider (or local password).
18#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
19pub struct IdentityLink {
20    pub user_id: Uuid,
21    pub provider: IdentityProvider,
22    /// Stable provider-side ID (e.g. GitHub user id; for password = email).
23    pub subject: String,
24    pub created_at: DateTime<Utc>,
25}