| ... | @@ -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 | } |
| 55 | | 55 | |
| | 56 | fn guest_client(id: &str) -> bool { |
| | 57 | id == "shale" || id == "shale-dev" || id.starts_with("shale-preview-") |
| | 58 | } |
| | 59 | |
| 56 | fn guests_allowed(id: &str, config: &Value) -> bool { | 60 | fn 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 | } |
| 59 | | 63 | |
| 60 | pub(crate) fn sign_in_target(auth: &auth::Store, next: &str) -> Result<(url::Url, Value)> { | 64 | 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<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_guests | 217 | 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 = auth | 221 | 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 | })) |