Add auth headers to request when using BasicAuth#215
Open
corin33 wants to merge 1 commit intooras-project:mainfrom
Open
Add auth headers to request when using BasicAuth#215corin33 wants to merge 1 commit intooras-project:mainfrom
corin33 wants to merge 1 commit intooras-project:mainfrom
Conversation
Signed-off-by: corin <corin@duckster.net>
vsoch
reviewed
Jun 26, 2025
|
|
||
| # Make the request and return to calling function, but attempt to use auth token if previously obtained | ||
| if isinstance(self.auth, oras.auth.TokenAuth) and self.auth.token is not None: | ||
| if ( |
Contributor
There was a problem hiding this comment.
I think generally speaking we want to add auth headers only after the registry requests it.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
I'm currently using
oras-pyas client library for a Zot OCI registry. In my current (rather simple) setup, I'm only usingBasicAuthwith username and password, noTokenAuth.I noticed that when pushing a blob (by calling
registry.upload_blob()), there is no authentication header, and thus Zot sometimes rejects the push.I say sometimes, because other times Zot seems fine without the auth header, and accepts the push. It's really hard to debug...
When adding the auth header to every request, Zot is happy.
I saw that there's a test for pushing using basic auth oras/tests/test_oras.py#L168 which I would expect to fail as well, so I really don't know...
Proposed Solution
Add the auth headers to the request, just like it's done with
TokenAuth.NB: I have no clue if this is the right way, or if I'm misusing
oras-pyand should solve this a completely different waySteps to reproduce
my client script essentially looks like this:
relevant parts of Zot configuration: