-
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
API call doesn't work with OIDC auth in harbor #10869
Comments
Same issue here. I noticed that using the Admin user, the API works as usual even with OIDC enabled, but for OIDC users they can only access public stuff.
This might be exactly what you mean, but I noticed I can access all the stuff via the API Explorer, which somehow makes it feel even weirder. |
It is by design you can't use CLI secret to call the API, that's why it's called "CLI" secret |
Thanks for your reply. It works with Database and LDAP auth mode, I can use the username and password to call the API without any problem. But as for OIDC mode, how can I make API call with the ID token you mentioned? |
#10597 seems related. |
@drehpehs This cli secret is basically created for you (OIDC user) to interact with Harbor on the command line and is only available for OIDC because that's the design we've taken. By token, he is referring to the ID token that OIDC spec leverages which is where the real authentication takes place. The secret (generated by Harbor for you) just fronts as your key because native docker can't handle redirection. |
@xaleeks Unless we bring the cookie in Header. related: #10563 |
Basic auth is not supported in OIDC mode you have to call the the api like this |
@reasonerjt |
I believe @reasonerjt means that the behavior changes according to the configured login mechanism. For OIDC is better to understand how it works, here is some useful documentation. |
Hi I'm closing seems there was some misunderstanding on the mechanism in OIDC. Feel free to add more comments if you need more help |
Just wanted to note that, as drehpehs says, using the Authorization header with the ID Token from the OIDC provider does indeed authenticate the user and grant access to private data through the API. |
But also, if I'm reading the OIDC/OAuth2 specs correctly, it should be the access_token that grants access to the API, not the id_token. |
If you are reporting a problem, please make sure the following information are provided:
Expected behavior and actual behavior:
I would like to use API call with OIDC user account to retrieve the project data, however, OIDC user account can get "public" projects only. Even I have the project admin role or was set as admin account. It still can get "public" projects.
Steps to reproduce the problem:
Regarding to https://github.com/goharbor/harbor/wiki/Harbor-FAQs#api
$ curl -X GET -u '<USER>:<CLI_secret>' -H "Content-type: application/json" -k -i 'https://<HOST>/api/projects'
Return public projects only
decode(base64) _xsrf=xxxxxx of the Set-Cookie in header.
$ curl -X GET -u '<USER>:<CLI_secret>' -H "Content-type: application/json" -H 'X-Xsrftoken:<_xsrf raw value>' -k -i 'https://<HOST>/api/projects'
Still public projects only
Versions:
Please specify the versions of following systems.
Additional context:
However, I found it works and can get all authorized projects in the UI. Then I try to use the cookie of the browser, then make the API call.
$ curl -X GET -u '<USER>:<CLI_secret>' -H "Content-type: application/json" -H 'X-Xsrftoken:<_xsrf raw value>' -k -i 'https://<HOST>/api/projects' -H 'Cookie: sid=xxxx; _xsrf=xxxxxx'
Can get all authorized projects for this OIDC user.
harbor.yml
and files in the same directory, including subdirectory./var/log/harbor/core.log
[ERROR] [/core/filter/security.go:430]: failed to authenticate <USER>: Not supported
The text was updated successfully, but these errors were encountered: