Skip to content

Commit 94a1608

Browse files
authored
feat: remove oauth2 code and support tinyship session (#2032)
1 parent faf14ab commit 94a1608

File tree

14 files changed

+304
-596
lines changed

14 files changed

+304
-596
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ ctrlc = "3.5.2"
9393
cedar-policy = "4.9.1"
9494
secp256k1 = "0.30.0"
9595
pgp = "0.15.0"
96-
oauth2 = "5.0.0"
9796
base64 = "0.22.1"
9897

9998
utoipa = { version = "5.4.0", features = ["chrono"] }

common/src/config/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,22 +606,28 @@ pub struct ObjectStorageConfig {
606606

607607
#[derive(Serialize, Deserialize, Debug, Clone)]
608608
pub struct OauthConfig {
609-
pub github_client_id: String,
610-
pub github_client_secret: String,
611-
pub ui_domain: String,
612-
pub cookie_domain: String,
613609
pub campsite_api_domain: String,
610+
pub tinyship_api_domain: String,
611+
#[serde(default)]
612+
pub api_store_backend: OauthApiStoreBackend,
614613
pub allowed_cors_origins: Vec<String>,
615614
}
616615

616+
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
617+
#[serde(rename_all = "lowercase")]
618+
#[derive(Default)]
619+
pub enum OauthApiStoreBackend {
620+
#[default]
621+
Campsite,
622+
Tinyship,
623+
}
624+
617625
impl Default for OauthConfig {
618626
fn default() -> Self {
619627
Self {
620-
github_client_id: String::new(),
621-
github_client_secret: String::new(),
622-
ui_domain: "http://localhost".to_string(),
623-
cookie_domain: "localhost".to_string(),
624628
campsite_api_domain: "http://api.gitmono.test:3001".to_string(),
629+
tinyship_api_domain: "https://libra.tools".to_string(),
630+
api_store_backend: OauthApiStoreBackend::Campsite,
625631
allowed_cors_origins: vec![
626632
"http://localhost",
627633
"http://app.gitmega.com",

config/config-test.toml

Lines changed: 0 additions & 268 deletions
This file was deleted.

config/config.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,15 @@ bucket = "gitmega"
167167
root_dir = "${base_dir}/objects"
168168

169169
[oauth]
170-
# GitHub OAuth application client id and secret
171-
github_client_id = ""
172-
github_client_secret = ""
170+
# Used for call api from campsite server, for example: http://api.gitmono.test:3001
171+
campsite_api_domain = "http://api.gitmono.test:3001"
173172

174-
# Used for redirect to ui after login, for example: http://app.gitmega.com
175-
ui_domain = "http://local.gitmega.com"
173+
# Used for call api from tinyship server, for example: https://libra.tools
174+
tinyship_api_domain = "https://libra.tools"
176175

177-
# Set your own domain here, for example: .gitmono.com
178-
cookie_domain = "localhost"
176+
# Which auth API to use when loading users (campsite or tinyship)
177+
api_store_backend = "campsite"
179178

180-
# Used for call api from campsite server, for example: http://api.gitmono.test:3001
181-
campsite_api_domain = "http://api.gitmono.test:3001"
182179

183180
# allowed cors origins
184181
allowed_cors_origins = [
@@ -278,4 +275,3 @@ default_items = [
278275
{ public_id = "rust", label = "Rust", href = "/rust", visible = false, order_index = 11 },
279276
{ public_id = "oc", label = "Orion Client", href = "/oc", visible = true, order_index = 13 },
280277
]
281-

mono/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,14 @@ tokio = { workspace = true, features = ["net", "macros", "signal"] }
5151
tokio-stream = { workspace = true }
5252
tokio-util = { workspace = true }
5353
async-stream = { workspace = true }
54-
# TODO: temporary using 0.12.28, wait for oauth2 to be compatible
55-
reqwest = { version = "0.12.28", features = [
56-
"rustls-tls-webpki-roots",
54+
reqwest = { workspace = true, features = [
5755
"json",
5856
"stream",
5957
"blocking",
6058
] }
6159
regex = { workspace = true }
6260
ed25519-dalek = { workspace = true, features = ["pkcs8"] }
6361
ctrlc = { workspace = true }
64-
oauth2 = { workspace = true }
6562
tower-sessions = { workspace = true, features = ["memory-store"] }
6663
async-trait = { workspace = true }
6764
time = { workspace = true, features = ["serde"] }

0 commit comments

Comments
 (0)