summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-04 12:46:24 -0600
committermo khan <mo@mokhan.ca>2025-07-04 12:46:24 -0600
commit093c2a626b41f920e6c9fa8efbc6e497761cba10 (patch)
tree5187f7fffb7daa6ab57ccbc7e12e4407cece4a9b
parentf8549af8d64b551449957c3004b74ed0bf69c593 (diff)
feat: allow access to sparkle homepage
-rw-r--r--src/authorization/cedar_authorizer.rs6
-rw-r--r--tests/authorization/check_service_test.rs28
2 files changed, 15 insertions, 19 deletions
diff --git a/src/authorization/cedar_authorizer.rs b/src/authorization/cedar_authorizer.rs
index fd27565d..163f5b83 100644
--- a/src/authorization/cedar_authorizer.rs
+++ b/src/authorization/cedar_authorizer.rs
@@ -70,8 +70,10 @@ impl Authorizer for CedarAuthorizer {
None => return false,
};
- if http_request.path == "/" {
- return true;
+ if http_request.host == "sparkle.staging.runway.gitlab.net" {
+ if http_request.method == "GET" && http_request.path == "/" {
+ return true;
+ }
}
let headers = match request
diff --git a/tests/authorization/check_service_test.rs b/tests/authorization/check_service_test.rs
index 3f8adec2..0a2997cf 100644
--- a/tests/authorization/check_service_test.rs
+++ b/tests/authorization/check_service_test.rs
@@ -140,35 +140,29 @@ mod tests {
// {status: tonic::Code::PermissionDenied, http: &HTTPRequest{Method: "GET", Path: "/dashboard", Headers: invalidHeaders}},
// {status: tonic::Code::PermissionDenied, http: &HTTPRequest{Method: "POST", Path: "/sparkles"}},
//
- // http: Some(HttpRequest {
- // id: \"13810813926834082307\",
+ // http:
// method: \"GET\",
// headers: {
- // \"accept\": \"*/*\",
// \":method\": \"GET\",
- // \"accept-encoding\": \"gzip, deflate, br, zstd\",
- // \"user-agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36\",
- // \"x-request-id\": \"b191fe87-e9b8-458e-b9ec-46d477a62803\",
// \":authority\": \"localhost:10000\",
// \":path\": \"/sparkles\",
- // \"x-forwarded-proto\": \"http\",
- // \":scheme\": \"http\",
// },
- // header_map: None,
// path: \"/sparkles\",
// host: \"localhost:10000\",
- // scheme: \"http\",
- // query: \"\",
- // fragment: \"\",
- // size: 0,
- // protocol: \"HTTP/1.1\",
- // body: \"\",
- // raw_body: []
let request = tonic::Request::new(build_request(|item: &mut HttpRequest| {
let path = String::from("/");
+ let method = String::from("GET");
+ let host = String::from("sparkle.staging.runway.gitlab.net");
+
+ item.method = method.clone();
item.path = path.clone();
- item.headers = build_headers(vec![(String::from(":path"), path)]);
+ item.host = host.clone();
+ item.headers = build_headers(vec![
+ (String::from(":path"), path),
+ (String::from(":method"), method),
+ (String::from(":authority"), host),
+ ]);
}));
let response = subject().check(request).await;