Skip to content
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

Token Auth Backend: Token request function didn`t set Authorization Header #153

Merged
merged 6 commits into from
Sep 6, 2024

Conversation

mariusbertram
Copy link
Contributor

In the Token Auth Backend the functin request_token were missing the Authorization Header which failed in not receiving a Bearer Token.

Signed-off-by: Marius Bertram <[email protected]>
Signed-off-by: Marius Bertram <[email protected]>
Signed-off-by: Marius Bertram <[email protected]>
Signed-off-by: Marius Bertram <[email protected]>
oras/auth/token.py Outdated Show resolved Hide resolved
oras/auth/token.py Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
Signed-off-by: Marius Bertram <[email protected]>
@vsoch vsoch merged commit 5d7b80d into oras-project:main Sep 6, 2024
5 checks passed
tarilabs added a commit to tarilabs/oras-py that referenced this pull request Sep 23, 2024
tarilabs added a commit to tarilabs/oras-py that referenced this pull request Sep 23, 2024
vsoch pushed a commit that referenced this pull request Sep 24, 2024
* core: TokenAuth request_token fix missing auth

the method is intended to request authenticated
token, per pydocs, but was passing an headers
which was always missing Authorization.

* core: use token in auth in subsequent requests

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

* core: if 401 on 2nd attempt, avoid anon tokens

in the first flow using auth backend for token:
1. try do_request with no auths at all
2. the attempt to gain an anon token is success,
but then the request fails with 401
3. at this point, in the third attempt, give
chance to the flow to request a token but avoid
any anon tokens.

Please note: this happens effectively only on the
first run of the flow. Subsequent do_request flow
invocations should just succeed now on the 1st
request by re-using the token --simplified
behaviour introduced with this proposal

* guard as headers is Optional
* implement review request

* Revert "implement review request"

This reverts commit 102381c.
This reverts commit 1e891d2.
This reverts commit 6e22667.

this was taken care in #153

This reverts commit 10e010b.

* implement review comment about anon/req token

from: #148 (comment)

> And if the basic auth is there, skip over asking for an anon token

as it stands, in case the basic auth are present,
these are exchanged for the request token.

Signed-off-by: tarilabs <[email protected]>

---------

Signed-off-by: tarilabs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants