add JWT based authentication for the registry #718
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, the registry for GitOps based deployments is protected with basic authentication. Basic authentication is simple, but may not be the best choice for multi user environments since it doesn't seem to work properly if the user doesn't have the
config:readpermission (and giving that permission to arbitrary non-admins seems like a bad idea).This PR depends on changes in the operator to use Token Authentication in the distribution registry. This PR implements a "Authorization service" (see link above) in the Kubero UI. This delegates the registry authorization to Kubero and allows us to grant minimal privileges to each build job.
The authentication for build jobs works like this:
RegistryUseris created with a randomly generated password and stored in the databasemakeTemporaryPushCredentialsForImage()401 Unauthorizedand ask buildah to call back to the Kubero UIFor the JWT to work, the registry needs access to the public part of the JWK used to sign the JWT. This is done in
onApplicationBootstrapof theRegistryService.In addition, we also need a credential authorizing kubernetes to pull images for spinning up pods. This is also created in
onApplicationBootstrap.The PR is currently marked as draft to solicit feedback on the approach. It is missing:
RegistryUsersdon't expireRegistryUsersshould be deleted when a build is doneType of change
Marking as a breaking change since existing registry with basic authentication would stop working and need to be migrated. However, token authentication is very flexible and in the future we could add a UI to create arbitrary registry users if that is a known use case we don't want to break.
How Has This Been Tested?
I have build the operator with my changes, deployed it in a kind cluster and kicked off a build which worked fine.
Test Configuration:
Checklist: