Skip to content

Commit

Permalink
core: use token in auth in subsequent requests
Browse files Browse the repository at this point in the history
if a token was saved in auth,
it shall be used in subsequent requests.

This avoid a situation where:
to upload a blob, first is done anonymously, then
retry with token
then upload a manifest, avoid the attempt to upload
anonymously if a token was present in the previous
flow

Signed-off-by: tarilabs <matteo.mortari@gmail.com>
  • Loading branch information
tarilabs committed Jul 6, 2024
1 parent 10e010b commit 2dcf321
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion oras/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,9 @@ def do_request(
:param stream: stream the responses
:type stream: bool
"""
# Make the request and return to calling function, unless requires auth
# Make the request and return to calling function, but attempt to use auth token if previously obtained
if isinstance(self.auth, oras.auth.TokenAuth):
headers.update(self.auth.get_auth_header())
response = self.session.request(
method,
url,
Expand Down

0 comments on commit 2dcf321

Please sign in to comment.