From c4b314054093066a2edb42ae2e912aa77b1740b1 Mon Sep 17 00:00:00 2001 From: nkottary Date: Tue, 21 Jul 2020 12:11:52 +0530 Subject: [PATCH] Handle GitLab subgroups --- Manifest.toml | 51 ++++++++++++++++++++++--------------------- Project.toml | 2 +- src/webui/gitutils.jl | 14 +++++++++--- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 9efaf77bbb..ebed2653c7 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -15,9 +15,9 @@ version = "0.2.0" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[DataAPI]] -git-tree-sha1 = "00612b2fbe534a539dc7f70106c71e3a943d9b98" +git-tree-sha1 = "176e23402d80e7743fc26c19c681bfb11246af32" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" -version = "1.2.0" +version = "1.3.0" [[DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" @@ -37,21 +37,21 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[GitForge]] deps = ["Dates", "HTTP", "JSON2"] -git-tree-sha1 = "4469573ba6e4c262ba3c3018de2166c063ec5c2d" +git-tree-sha1 = "ded1b4ce9518e7568bad8dc20171a34684e8c6d2" uuid = "8f6bce27-0656-5410-875b-07a5572985df" -version = "0.1.5" +version = "0.1.6" [[GitHub]] deps = ["Base64", "Dates", "HTTP", "JSON", "MbedTLS", "Sockets"] -git-tree-sha1 = "bc8ded5984130076ca6fe6b752508effa1201a19" +git-tree-sha1 = "a1c60c4079c54486e5e1daab1f4cdaebb21f6f63" uuid = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" -version = "5.1.5" +version = "5.1.6" [[HTTP]] deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"] -git-tree-sha1 = "fe31f4ff144392ad8176f5c7c03cca6ba320271c" +git-tree-sha1 = "eca61b35cdd8cd2fcc5eec1eda766424a995b02f" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "0.8.14" +version = "0.8.16" [[Hiccup]] deps = ["MacroTools", "Test"] @@ -82,9 +82,9 @@ version = "0.21.0" [[JSON2]] deps = ["Dates", "Parsers", "Test"] -git-tree-sha1 = "6cbbbab27d9411946725f5d5c91e8b8fb5f7d5db" +git-tree-sha1 = "66397cc6c08922f98a28ab05a8d3002f9853b129" uuid = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" -version = "0.3.1" +version = "0.3.2" [[Lazy]] deps = ["MacroTools"] @@ -93,6 +93,7 @@ uuid = "50d2b5c4-7a5e-59d5-8109-a42b560f39c0" version = "0.14.0" [[LibGit2]] +deps = ["Printf"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[Libdl]] @@ -123,39 +124,39 @@ version = "1.0.2" [[MbedTLS_jll]] deps = ["Libdl", "Pkg"] -git-tree-sha1 = "c83f5a1d038f034ad0549f9ee4d5fac3fb429e33" +git-tree-sha1 = "a0cb0d489819fa7ea5f9fa84c7e7eba19d8073af" uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.16.0+2" +version = "2.16.6+1" [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[Mustache]] deps = ["Printf", "Tables"] -git-tree-sha1 = "2e11fc5de3a01d23482a257e22009ddaab058d9a" +git-tree-sha1 = "fcfc8266461f2905534aa00c0fc59b8751b1026e" uuid = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" -version = "1.0.2" +version = "1.0.3" [[Mux]] deps = ["AssetRegistry", "Base64", "HTTP", "Hiccup", "Lazy", "Pkg", "Sockets", "WebSockets"] -git-tree-sha1 = "3621676e7f711aca14d783d1bff9ac379d9df6b7" +git-tree-sha1 = "0f3a0c7e6ee65b7cc096feac8748f6ee03ea487f" uuid = "a975b10e-0019-58db-a62f-e48ff68538c9" -version = "0.7.1" +version = "0.7.2" [[Parsers]] deps = ["Dates", "Test"] -git-tree-sha1 = "f8f5d2d4b4b07342e5811d2b6428e45524e241df" +git-tree-sha1 = "10134f2ee0b1978ae7752c41306e131a684e1f06" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "1.0.2" +version = "1.0.7" [[Pidfile]] deps = ["FileWatching", "Test"] -git-tree-sha1 = "1ffd82728498b5071cde851bbb7abd780d4445f3" +git-tree-sha1 = "1be8660b2064893cd2dae4bd004b589278e4440d" uuid = "fa939f87-e72e-5be4-a000-7fc836dbe307" -version = "1.1.0" +version = "1.2.0" [[Pkg]] -deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"] +deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [[Printf]] @@ -222,12 +223,12 @@ version = "1.5.2" [[ZMQ]] deps = ["FileWatching", "Sockets", "ZeroMQ_jll"] -git-tree-sha1 = "adb2d52aa12c8284da12714f35d2b21fc3d5b2bb" +git-tree-sha1 = "fc68e8a3719166950a0f3e390a14c7302c48f8de" uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" -version = "1.2.0" +version = "1.2.1" [[ZeroMQ_jll]] deps = ["Libdl", "Pkg"] -git-tree-sha1 = "42b0955a7ad0935d454d750fedd812d3f2836fde" +git-tree-sha1 = "733352667c60ce39dfd3017db9b798b288c87417" uuid = "8f1865be-045e-5c20-9c9f-bfbfb0764568" -version = "4.3.2+2" +version = "4.3.2+4" diff --git a/Project.toml b/Project.toml index e7970315b9..b4bc33cca7 100644 --- a/Project.toml +++ b/Project.toml @@ -28,7 +28,7 @@ ZMQ = "c2297ded-f4af-51ae-bb23-16f91089e4e1" [compat] AutoHashEquals = "0.2" -GitForge = "~0.1.4" +GitForge = "~0.1.5" GitHub = "5" HTTP = "0.8" JSON = "0.20, 0.21" diff --git a/src/webui/gitutils.jl b/src/webui/gitutils.jl index e0b497a01d..832735a734 100644 --- a/src/webui/gitutils.jl +++ b/src/webui/gitutils.jl @@ -66,9 +66,17 @@ function isauthorized(u::User{GitLab.User}, repo::GitLab.Project) @gf is_collaborator(forge, repo.owner.username, repo.name, u.user.id) else # Same as above: group membership then collaborator check. - ismember = @gf is_member(forge, repo.namespace.full_path, u.user.id) - something(ismember, false) || - @gf is_collaborator(u.forge, repo.namespace.full_path, repo.name, u.user.id) + nspath = split(repo.namespace.full_path, "/") + ismember = @gf is_collaborator(u.forge, repo.namespace.full_path, repo.name, u.user.id) + if !something(ismember, false) + accns = "" + for ns in nspath + accns = joinpath(accns, ns) + ismember = @gf is_member(forge, accns, u.user.id) + something(ismember, false) && break + end + end + ismember end return something(hasauth, false) end