swarmhive_api_types/
oauth.rs1use chrono::{DateTime, Utc};
9use serde::{Deserialize, Serialize};
10use utoipa::ToSchema;
11use uuid::Uuid;
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
16#[serde(rename_all = "lowercase")]
17pub enum OAuthProviderKind {
18 Github,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
23pub struct OAuthProviderView {
24 pub id: Uuid,
25 pub kind: OAuthProviderKind,
26 pub name: String,
27 pub enabled: bool,
28 pub client_id: String,
29 pub secret_set: bool,
32 pub scopes: Vec<String>,
33 pub authorize_url: String,
34 pub token_url: String,
35 pub userinfo_url: String,
36 pub email_field: String,
37 pub created_at: DateTime<Utc>,
38 pub updated_at: DateTime<Utc>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
43pub struct PublicOAuthProvider {
44 pub name: String,
45 pub kind: OAuthProviderKind,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
49pub struct CreateOAuthProviderReq {
50 pub kind: OAuthProviderKind,
51 pub name: String,
52 pub client_id: String,
53 pub client_secret: String,
54 #[serde(default)]
56 pub scopes: Option<Vec<String>>,
57 #[serde(default)]
60 pub authorize_url: Option<String>,
61 #[serde(default)]
62 pub token_url: Option<String>,
63 #[serde(default)]
64 pub userinfo_url: Option<String>,
65 #[serde(default)]
66 pub email_field: Option<String>,
67 #[serde(default)]
68 pub enabled: Option<bool>,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
72pub struct UpdateOAuthProviderReq {
73 #[serde(default)]
74 pub name: Option<String>,
75 #[serde(default)]
76 pub client_id: Option<String>,
77 #[serde(default)]
79 pub client_secret: Option<String>,
80 #[serde(default)]
81 pub scopes: Option<Vec<String>>,
82 #[serde(default)]
83 pub authorize_url: Option<String>,
84 #[serde(default)]
85 pub token_url: Option<String>,
86 #[serde(default)]
87 pub userinfo_url: Option<String>,
88 #[serde(default)]
89 pub email_field: Option<String>,
90 #[serde(default)]
91 pub enabled: Option<bool>,
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
97pub struct OAuthTestResult {
98 pub ok: bool,
99 pub detail: String,
100}