Determine Current.organization on requests
This is a continuation of the efforts started in #437541 (closed).
The current solution is:
- Map
Routable
paths back to an organization. e.g./gitlab-org/gitlab/issues/443829
-> default org. - When user is authenticated, use
current_user.organizations.first
.Routable
path will override to reflect accurate HTTP 403/404/etc scenarios. (#464667 (closed)) - Else, default organization.
- When path has a uniqueness claim, the router will direct to the correct cell so this should work. E.g
/some-username
. - When path is ambiguous, this will not necessarily return a correct result. Maybe this is enough for Cells 1.0.
- When path has a uniqueness claim, the router will direct to the correct cell so this should work. E.g
Obsolete issue description within.
In this issue we'll focus on adding the routed organization_id calculated from the route supplied by the router service described in #437541 (comment 1785691864) and !144811 (comment 1784126192)
X-GL-ORG-ID: 123
header
1. Router returns HTTP 307 with added flowchart TD
browser -- gitlab.com/some group --> router
router -- gitlab.com/some group --> classify
classify -- status: 307; header: X-GL-ORG-ID: 123 --> router
router -- status: 307; header: X-GL-ORG-ID: 123 --> browser
X-GL-ORG-ID: 123
header
2. Browser makes a new request with added flowchart TD
browser -- gitlab.com/some group; header: X-GL-ORG-ID: 123 --> router
router -- header: X-GL-ORG-ID: 123 --> cell_2_middleware
cell_2_middleware -- Current.organization = 123 --> rails_stack
- Is possible for the classify service to do in the redirect(307) and can we decide on the header name(
X-GL-ORG-ID
for example) that will hold this info?
Proposal
-
Determine if the above design is feasible and determine the header name. /cc @ayufan -
Add the logic to the current organization middleware to use this info, if provided to set the Current.organization
if the initialHTTP_
header is not provided inlib/gitlab/middleware/organizations/current.rb
Edited by Alex Pooley