Skip to content

Make `-/` segment optional for group packages API

Sean McGivern requested to merge add-new-nuget-group-paths into master

This is needed for the NuGet group API, which was added in gitlab-org/gitlab!48356 (merged). (cc @10io @sabrams.)

I tested this with this minimal config:

frontend foo
    mode http
    bind *:8081
    use_backend ruby
    acl is_gitlab_com_package_registry path_reg ^/api/v[0-9]/packages/
    acl is_gitlab_com_package_registry path_reg ^/api/v[0-9]/projects/[^/]+/packages(/|$)
    acl is_gitlab_com_package_registry path_reg ^/api/v[0-9]/groups/[^/]+/(-/)?packages(/|$)
    http-request set-header X-Acl-Match 1 if is_gitlab_com_package_registry

backend ruby
    mode http
    server bar localhost:8000

And this Ruby server:

require 'webrick'

server = WEBrick::HTTPServer.new(Port: 8000)

server.mount_proc '/' do |req, res|
  p req.header
end

server.start

Before this change:

{"host"=>["localhost:8081"], "user-agent"=>["curl/7.64.1"], "accept"=>["*/*"]}
127.0.0.1 - - [12/Jan/2021:11:22:51 GMT] "HEAD /api/v4/groups/foo/packages/ HTTP/1.1" 200 0
- -> /api/v4/groups/foo/packages/
{"host"=>["localhost:8081"], "user-agent"=>["curl/7.64.1"], "accept"=>["*/*"], "x-acl-match"=>["1"]}
127.0.0.1 - - [12/Jan/2021:11:23:02 GMT] "HEAD /api/v4/groups/foo/-/packages/ HTTP/1.1" 200 0
- -> /api/v4/groups/foo/-/packages/

After this change:

{"host"=>["localhost:8081"], "user-agent"=>["curl/7.64.1"], "accept"=>["*/*"], "x-acl-match"=>["1"]}
127.0.0.1 - - [12/Jan/2021:11:23:29 GMT] "HEAD /api/v4/groups/foo/packages/ HTTP/1.1" 200 0
- -> /api/v4/groups/foo/packages/
{"host"=>["localhost:8081"], "user-agent"=>["curl/7.64.1"], "accept"=>["*/*"], "x-acl-match"=>["1"]}
127.0.0.1 - - [12/Jan/2021:11:23:32 GMT] "HEAD /api/v4/groups/foo/-/packages/ HTTP/1.1" 200 0
- -> /api/v4/groups/foo/-/packages/

See gitlab-com/gl-infra/scalability#778 (closed).

Merge request reports