Drive container registry migration phase 1 with Rails FFs [RUN ALL RSPEC] [RUN AS-IF-FOSS]
What does this MR do?
Related to #335260 (closed). Please see the description of this issue for context, technical background, functional diagrams, and a description of each FF introduced here as well as how they relate to each other.
How to test this change locally with GDK
We'll assume the existence of the gitlab-org/gitlab-test
project in your GDK instance and use it for these tests. You can pick any other project, as long as the Container Registry feature is enabled for it.
We'll also assume that your GDK Rails instance is listening at gdk.test:3000
and you have a user root
with a PAT foobar
, with write permissions to the container registry.
We need to query the Rails API and decode a few JWT tokens during these tests. To do so you can either decode it with a JWT debugger on the web (e.g. https://jwt.io/) or use a CLI tool such as jwt-cli
. We'll use the latter. We'll also use httpie
to make the requests and jq
to parse the token from the response, but you can do that with any other tools or manually.
Current behavior
-
Checkout the
main
branch of this repository. -
Open up a Rails console and a terminal window/pane.
-
On your terminal and obtain a JWT token with
push
permissions forgitlab-org/gitlab-test
:http -a root:foobar http://gdk.test:3000/jwt/auth \ client_id=="docker" \ service=="container_registry" \ scope=="repository:gitlab-org/gitlab-test:push" | jq -r '.token' | jwt decode -
Output (timestamp fields will vary, the important part is
access
):Token header ------------ ... Token claims ------------ { "access": [ { "actions": [ "push" ], "name": "gitlab-org/gitlab-test", "type": "repository" } ], "aud": "container_registry", "exp": 1625855309, "iat": 1625851709, "iss": "gitlab-issuer", "jti": "51d7aa5d-5077-4d27-94fc-a250f4e7501e", "nbf": 1625851704, "sub": "root" }
New behavior
-
Checkout this MR's branch.
-
Repeat the
/jwt/auth
request. The output should be identical to the above (except for the timestamp fields), because all FFs are disabled by default. -
Enable
container_registry_migration_phase1
:Feature.enable(:container_registry_migration_phase1)
-
Repeat the
/jwt/auth
request. This time we should now see a newmigration_eligible
field set tofalse
(the FF change may take a bit to propagate):Token header ------------ ... Token claims ------------ { "access": [ { "actions": [ "push" ], "migration_eligible": false, "name": "gitlab-org/gitlab-test", "type": "repository" } ], "aud": "container_registry", "exp": 1625855625, "iat": 1625852025, "iss": "gitlab-issuer", "jti": "c750d758-8944-4a86-ab34-bca6082ce2ee", "nbf": 1625852020, "sub": "root" }
-
Repeat the
/jwt/auth
request, but this time set thescope
parameter torepository:gitlab-org/gitlab-test:pull
instead ofrepository:gitlab-org/gitlab-test:push
. Because we're not granting write permissions with this token, there should be nomigration_eligible
field in the token. -
Enable
container_registry_migration_phase1_allow
forgitlab-org/gitlab-test
:Feature.enable(:container_registry_migration_phase1_allow, Project.find_by_full_path('gitlab-org/gitlab-test'))
-
Repeat the
/jwt/auth
request. This timemigration_eligible
should be set totrue
. -
Enable
container_registry_migration_phase1_deny
for thegitlab-org
top-level group/namespace:Feature.enable(:container_registry_migration_phase1_deny, Project.find_by_full_path('gitlab-org/gitlab-test').root_ancestor)
-
Repeat the
/jwt/auth
request. This timemigration_eligible
should be set tofalse
once again.
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team