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> {...@@ -53,8 +53,12 @@ fn client(db: &Connection, id: &str) -> Result<Value> {
53 .ok_or_else(|| invalid("invalid_client"))53 .ok_or_else(|| invalid("invalid_client"))
54}54}
5555
56fn guest_client(id: &str) -> bool {
57 id == "shale" || id == "shale-dev" || id.starts_with("shale-preview-")
58}
59
56fn guests_allowed(id: &str, config: &Value) -> bool {60fn 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)
58}62}
5963
60pub(crate) fn sign_in_target(auth: &auth::Store, next: &str) -> Result<(url::Url, Value)> {64pub(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> {...@@ -211,7 +215,7 @@ pub fn provision(auth: &auth::Store, input: Value) -> Result<Value> {
211 .unwrap_or_else(mcp::secret);215 .unwrap_or_else(mcp::secret);
212 let allow_guests = request["allowGuests"] == true;216 let allow_guests = request["allowGuests"] == true;
213 if allow_guests217 if allow_guests
214 && (!(id == "shale" || id.starts_with("shale-preview-"))218 && (!guest_client(id)
215 || redirects.iter().any(|v| {219 || redirects.iter().any(|v| {
216 url::Url::parse(string(v)).is_ok_and(|u| {220 url::Url::parse(string(v)).is_ok_and(|u| {
217 let site = auth221 let site = auth
...@@ -220,8 +224,13 @@ pub fn provision(auth: &auth::Store, input: Value) -> Result<Value> {...@@ -220,8 +224,13 @@ pub fn provision(auth: &auth::Store, input: Value) -> Result<Value> {
220 .unwrap()224 .unwrap()
221 .strip_prefix("snowglobe.")225 .strip_prefix("snowglobe.")
222 .unwrap_or_default();226 .unwrap_or_default();
227 let host = if id == "shale-dev" {
228 "git1.localhost".to_owned()
229 } else {
230 format!("{id}.{site}")
231 };
223 u.path() != "/-/callback"232 u.path() != "/-/callback"
224 || u.host_str() != Some(format!("{id}.{site}").as_str())233 || u.host_str() != Some(host.as_str())
225 || u.query().is_some()234 || u.query().is_some()
226 })235 })
227 }))236 }))
service/shale/service.pkl+10
...@@ -13,6 +13,16 @@ requirements {...@@ -13,6 +13,16 @@ requirements {
13 allowGuests = true13 allowGuests = true
14 usernameRequired = true14 usernameRequired = true
15 }15 }
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 }
16}26}
17prepare = "prepare.py"27prepare = "prepare.py"
1828
tools/dashboard-oidc-test.py+3
...@@ -60,6 +60,9 @@ def main():...@@ -60,6 +60,9 @@ def main():
60 provision('bad', ['https://evil.example/callback'], status=1)60 provision('bad', ['https://evil.example/callback'], status=1)
61 provision('bad', ['https://shale.paperclover.net/*'], status=1)61 provision('bad', ['https://shale.paperclover.net/*'], status=1)
62 provision('shale-preview-bad', ['https://jelly.paperclover.net/-/callback'], guests=True, status=1)62 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)
63 with socket.socket() as available:66 with socket.socket() as available:
64 available.bind(('127.0.0.1', 0)); port = available.getsockname()[1]67 available.bind(('127.0.0.1', 0)); port = available.getsockname()[1]
65 environment['PORT'] = str(port)68 environment['PORT'] = str(port)