-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
401 Unauthorized on some API endpoints when using OIDC #16647
Comments
Probably related: #16398 |
Please refer to this #16398 (comment) |
For anyone else getting confused by this: search for just "OIDC", not "API OIDC", on that Wiki page. |
That's clearly not true. You don't have to use the OIDC token. That is only required sometimes, depending on which API endpoint is used for the call. |
Correction: search for |
Why has this issue been closed when neither point of concern below has been addressed?
|
This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days. |
Please keep this open. |
This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days. |
This issue is still relevant, please keep it open |
Still an issue on 2.5.1 |
When I ran into this yesterday, it was on a Docker API. Can that be a clue? |
This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days. |
Ping |
Same error, is this a bug or no bug? When I log into Harbor via browser and go to API docs, it gives me an option to authorize, and I do this using basic auth. Once authorized, I can run example requests on the Swagger part. When I try something similar with a command line client or with Go, I am stuck with |
So this seems like a bug: I was trying to do a |
I think this is clearly a bug. |
This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days. |
Same issue. After an hour of debugging why requesting artifacts works fine but I cannot get tags of a specific one I end up here. I have a user in Jenkins credential storage I use to make the curl requests. This is not for just people to login and play around with postman or something. This is programmatic use in pipeline. It should have a single credential/api key you can use to access API, stored securely with credentials. That excess requirement here makes ZERO sense - you can access ALL artifacts with user:password but not individual? |
This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days. |
Please un-stale. |
IIRC, unfortunately not. I changed jobs a few weeks after creating this issue and haven't used Harbor since. |
still an issue - v2.7.1-6015b3ef |
YEt again i end up on this very same issue trying to deal with getting actual image version for latest tag from harbor. All i can do is query ALL artifacts and loop through every time just to find the 'latest' tag. But it looks like noone in Harbor team cares at all. Zero response. |
Still an issue |
Would be nice to try this now after #8723 was purportedly resolved. I don't have a Harbor instance available right now, but if someone could test it that would be nice. |
This is still broken on harbor 2.10.0 |
Still a problem! Please address |
still an issue |
still a problem! |
Another year and again i end up on the same problem. |
There are misunderstandings in the discussion on this issue and I can't answer each of them. But I'll try to clarify in general: When Harbor is configured to authenticate via OIDC provider, it is by design that you should use the ID token to access the API have the same permission as the authenticated user. Therefore, the suggestion in this comment remains valid. CLI secret was designed to help CLI tools to push and pull artifacts so we allow using CLI secret to access a few API endpoints to fulfill the workflow for artifact push and pull, but not other APIs. There is a proposal to extend the scope of CLI secret which may solve the problem, but in internal discussion, there are other ideas like introducing a concept "API-token" that is not restricted in OIDC mode. We feel we may not reach a quick decision before "feature freeze" in v2.13.0, so we are moving it out, but I'll follow up with the discussion in the proposal. |
Expected behavior and actual behavior
I expect to be able to access all API endpoints that my user has access to via e.g. curl, using my CLI secret for authentication.
However, when using an OIDC user account, I cannot access some endpoints:
GET
the list of projects, but I cannotGET
a specific project.GET
the list of repositories in a project, but I cannotGET
a specific repository.GET
the list of artifacts in a repository, but I cannotGET
a specific artifact (or e.g. its vulnerabilities).Specifically, when using curl, I get a 401 response with this body:
I can access all endpoints with curl using a robot account or the admin account (which do not use OIDC).
I can also access all endpoints in the web GUI and the API Explorer (
/devcenter-api-2.0
) using my OIDC account.Steps to reproduce the problem
Output:
Lines like this one show up in the log:
The error is thrown here.
Additional information
Notably, it turns out that in the web GUI and the API Explorer, a cookie named
sid
is included in each request. That cookie alone turns out to be enough for authentication and authorization – theAuthorization
header (i.e. curl's-u
flag) is not even needed:As previously stated, the cookie is necessary for some endpoints (when accessed by an OIDC user). However, the API Explorer generates commands like this one, without any cookie:
All in all, there seems to be some inconsistency regarding OIDC authentication:
/projects/foo
) require an OIDC cookie, while others (e.g./projects
) do not.Versions
The text was updated successfully, but these errors were encountered: