authoravatarclover caruso<git@paperclover.net>2026-11-01 22:19:03-08:00
committeravatarclover caruso<git@paperclover.net>2026-11-12 16:08:55-08:00
log200d5a28438846413d0e4a2d201b6d6bb440de04
treef2fea8de63d4fbd0038fd126bbe81efc4e862447
parent8b83b426422ffbcea026852a96e781de7616fd8f
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Add a guest-capable Shale dev OIDC client for git1.localhost


3 files changed, 25 insertions(+), 3 deletions(-)

dashboard/src/oidc.rs+12-3
......@@ -53,8 +53,12 @@ fn client(db: &Connection, id: &str) -> Result<Value> {
5353 .ok_or_else(|| invalid("invalid_client"))
5454}
5555
56fn guest_client(id: &str) -> bool {
57 id == "shale" || id == "shale-dev" || id.starts_with("shale-preview-")
58}
59
5660fn guests_allowed(id: &str, config: &Value) -> bool {
57 config["allowGuests"] == true && (id == "shale" || id.starts_with("shale-preview-"))
61 config["allowGuests"] == true && guest_client(id)
5862}
5963
6064pub(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<Value> {
211215 .unwrap_or_else(mcp::secret);
212216 let allow_guests = request["allowGuests"] == true;
213217 if allow_guests
214 && (!(id == "shale" || id.starts_with("shale-preview-"))
218 && (!guest_client(id)
215219 || redirects.iter().any(|v| {
216220 url::Url::parse(string(v)).is_ok_and(|u| {
217221 let site = auth
......@@ -220,8 +224,13 @@ pub fn provision(auth: &auth::Store, input: Value) -> Result<Value> {
220224 .unwrap()
221225 .strip_prefix("snowglobe.")
222226 .unwrap_or_default();
227 let host = if id == "shale-dev" {
228 "git1.localhost".to_owned()
229 } else {
230 format!("{id}.{site}")
231 };
223232 u.path() != "/-/callback"
224 || u.host_str() != Some(format!("{id}.{site}").as_str())
233 || u.host_str() != Some(host.as_str())
225234 || u.query().is_some()
226235 })
227236 }))
service/shale/service.pkl+10
......@@ -13,6 +13,16 @@ requirements {
1313 allowGuests = true
1414 usernameRequired = true
1515 }
16 when (!site.preview) {
17 new sso.Client {
18 alias = "dev"
19 clientId = "\(module.id)-dev"
20 name = "\(module.name) dev"
21 redirectUris { "http://git1.localhost/-/callback" }
22 allowGuests = true
23 usernameRequired = true
24 }
25 }
1626}
1727prepare = "prepare.py"
1828
tools/dashboard-oidc-test.py+3
......@@ -60,6 +60,9 @@ def main():
6060 provision('bad', ['https://evil.example/callback'], status=1)
6161 provision('bad', ['https://shale.paperclover.net/*'], status=1)
6262 provision('shale-preview-bad', ['https://jelly.paperclover.net/-/callback'], guests=True, status=1)
63 provision('shale-dev', ['http://git1.localhost/-/callback'], guests=True, username=True)
64 provision('shale-dev', ['http://other.localhost/-/callback'], guests=True, status=1)
65 provision('shale', ['http://git1.localhost/-/callback'], guests=True, status=1)
6366 with socket.socket() as available:
6467 available.bind(('127.0.0.1', 0)); port = available.getsockname()[1]
6568 environment['PORT'] = str(port)