-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(oci): dont use preparing client for docker authorizer #7196
Draft
bluebrown
wants to merge
1
commit into
open-policy-agent:main
Choose a base branch
from
bluebrown:fix/oci-download
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many of the auth plugins had been supported before? With this change, we go back to only supporting bearer creds as auth mechanism, don't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as I understand, this would drop mtls authentication, since azure
managed identity is not supported for OCI. Or is tls even covered
by constructing the tls config? Is this maybe also an issue on redirect?
Personally, I would add another auth type that maps closely to the options
provides by containerd.docker package. Registry protocols are kind of
specific, and I don't think you can cover it with some more simple, generic
auth plugin.
So either we need to make the auth plugins alot more complex for all users,
or we just create a registry specific one, that can deal with the quirky,
protocols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where @DerGut introduced the feature. It also mentions
s3_signing
for talking to AWS.I'd like to avoid throwing the baby out with the bathwater 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this github ui terrible. I don't know understand what all the
buttons are suppossed to do. I keep deleting my comments
by accident, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi all, as @bluebrown mentioned the registry protocols are quite specific so maybe keeping it simple makes more sense. The addition of the plugins seems to have complicated the behavior of the OCI downloader and is currently causing issues with some registries (AWS and Azure ) because of the underlying redirect mechanism.
Would changing the plugin authorizer used in the OCI downloader to not attach the authorization header on a redirect make sense in this scenario ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carabasdaniel, to my understanding, this should solve the problem.
Based on my research, there is nothing in the HTTP spec that says if/when
credentials should be sent during redirect.
However, there is the
www-authenticate
header, that is used by someimplementations, including containerd.
They maintain a handler map, to know what endpoints should get auth
header. One criterion for adding a URL to the map, is
www-authenticate
.You can see this roughly here:
https://github.com/containerd/containerd/blob/88bf19b2105c8b17560993bee28a01ddc2f97182/remotes/docker/authorizer.go#L114
And here: https://github.com/containerd/containerd/blob/2c042ae0de7b9d69df8df8e370e2d802f10f9ee5/core/remotes/docker/auth/parse.go#L98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bluebrown, @srenatus sorry for the late reply I grabbed this change on top of latest main and I was testing this change with different OCI registries.
Public registries seem to work as expected, however when testing against some private registries I seem to hit the same problem that the CI shows. Basically the client created by
rest.DefaultRoundTripperClient(tc, *config.ResponseHeaderTimeoutSeconds)
doesn't have the necessary credentials and it fails to get the manifest of a private image returning a 401.You can use docker to spin up a local private registry to repro this issue or rely on the tests to easily debug. Please let me know if you need more details about this.
In the CNCF policy CLI project used to build and push policy images to different OCI registries we use the oci package from here to solve this issue https://github.com/opcr-io/policy/blob/main/oci/oci.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I meant this as answer to your question:
We also found some code that would not add the headers on redirect if the hostname changes.