From 200d5a28438846413d0e4a2d201b6d6bb440de04 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Sun, 1 Nov 2026 22:19:03 -0800 Subject: [PATCH] Add a guest-capable Shale dev OIDC client for git1.localhost --- dashboard/src/oidc.rs | 15 ++++++++++++--- service/shale/service.pkl | 10 ++++++++++ tools/dashboard-oidc-test.py | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dashboard/src/oidc.rs b/dashboard/src/oidc.rs index 2866ba36b316995a939abb09c7c1fe6c1f0b1834..f39ba498ebae2198420e07cd5671f74f2f5a3129 100644 --- a/dashboard/src/oidc.rs +++ b/dashboard/src/oidc.rs @@ -53,8 +53,12 @@ fn client(db: &Connection, id: &str) -> Result { .ok_or_else(|| invalid("invalid_client")) } +fn guest_client(id: &str) -> bool { + id == "shale" || id == "shale-dev" || id.starts_with("shale-preview-") +} + fn guests_allowed(id: &str, config: &Value) -> bool { - config["allowGuests"] == true && (id == "shale" || id.starts_with("shale-preview-")) + config["allowGuests"] == true && guest_client(id) } pub(crate) fn sign_in_target(auth: &auth::Store, next: &str) -> Result<(url::Url, Value)> { @@ -211,7 +215,7 @@ pub fn provision(auth: &auth::Store, input: Value) -> Result { .unwrap_or_else(mcp::secret); let allow_guests = request["allowGuests"] == true; if allow_guests - && (!(id == "shale" || id.starts_with("shale-preview-")) + && (!guest_client(id) || redirects.iter().any(|v| { url::Url::parse(string(v)).is_ok_and(|u| { let site = auth @@ -220,8 +224,13 @@ pub fn provision(auth: &auth::Store, input: Value) -> Result { .unwrap() .strip_prefix("snowglobe.") .unwrap_or_default(); + let host = if id == "shale-dev" { + "git1.localhost".to_owned() + } else { + format!("{id}.{site}") + }; u.path() != "/-/callback" - || u.host_str() != Some(format!("{id}.{site}").as_str()) + || u.host_str() != Some(host.as_str()) || u.query().is_some() }) })) diff --git a/service/shale/service.pkl b/service/shale/service.pkl index 0fdfe0fb269db7badba13f01f645b683b91d68f4..15fc16462a5302f3f7daa42e510b1010d1529f6e 100644 --- a/service/shale/service.pkl +++ b/service/shale/service.pkl @@ -13,6 +13,16 @@ requirements { allowGuests = true usernameRequired = true } + when (!site.preview) { + new sso.Client { + alias = "dev" + clientId = "\(module.id)-dev" + name = "\(module.name) dev" + redirectUris { "http://git1.localhost/-/callback" } + allowGuests = true + usernameRequired = true + } + } } prepare = "prepare.py" diff --git a/tools/dashboard-oidc-test.py b/tools/dashboard-oidc-test.py index d6ee6e8f7a24066c9c4b70ef7a9825660dc756ac..f1e2d0485a7deb00f689e91633940a628a495cf5 100644 --- a/tools/dashboard-oidc-test.py +++ b/tools/dashboard-oidc-test.py @@ -60,6 +60,9 @@ def main(): provision('bad', ['https://evil.example/callback'], status=1) provision('bad', ['https://shale.paperclover.net/*'], status=1) provision('shale-preview-bad', ['https://jelly.paperclover.net/-/callback'], guests=True, status=1) + provision('shale-dev', ['http://git1.localhost/-/callback'], guests=True, username=True) + provision('shale-dev', ['http://other.localhost/-/callback'], guests=True, status=1) + provision('shale', ['http://git1.localhost/-/callback'], guests=True, status=1) with socket.socket() as available: available.bind(('127.0.0.1', 0)); port = available.getsockname()[1] environment['PORT'] = str(port) -- 2.54.1