-
Notifications
You must be signed in to change notification settings - Fork 4
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
add support for harbor2 OpenID Connect (OIDC) users #10
Comments
I tried now the api explorer and the generated CURL, It works for the user vad1mo. It seems to be an issue on the docker- pushrm side rather than harbor. I didn't see any curl -X PUT "https://c8n.io/api/v2.0/projects/c8n/repositories/portal" -H "accept: application/json" -H "X-Request-Id: 8ju7378fh3f834h8" -H "authorization: Basic XXXXXXXX" -H "Content-Type: application/json" -H "X-Harbor-CSRF-Token: XXXXXX" -d "{ \"description\": \"TEST WORKS\"}" |
thanks, that’s a good catch. I’ve indeed only tested against local harbor users so far. (Just tried on demo.goharbor.io and a local instance and it worked there). Most likely we need a csrf header. I’ll sign up on c8n.io tonight and test it. |
@Vad1mo what kind of user/pass are you using in the above curl command (in the basic auth header)? is this a local user or an oidc user? what do you use as password? the cli secret? something else? thanks |
Yes the user is OIDC but I am using the users This is also how I used it on the API Portal to login with |
hmm...strange, on the c8n.io api portal I don't seem to be able to make any authenticated api calls (i.e. I'm logging in with user |
ok, it now works after I have changed the cli secret to a manually generated shorter one. Also oddly I can't change it back to the old auto-generated password (getting an error in the UI). First guess is there's a problem with the length? (UI only accepts 31 characters when setting the password but the auto-generated one was 32 characters long). |
ok, I've played around a bit and I have the impression that there's a server side issue that I can't work around client side (glad if you prove me wrong 😃). It appears to me that you can only get a valid csrf token by logging into c8n.io in the browser (via auth0). Then - and only for the session (also time limited) - you're possessing 3 cookies, of which you need two to be able to make a successful HTTP call:
When you copy them from a browser session you're able to make a curl call like:
where
Having said that, you can get all three cookies also using basic auth, but they don't allow you to make an api call that requires auth: ( Make a request and we get a
Make another request and send the stored cookie:
The server responds with the
But when we try to use them (in exactly the same request as with the cookies from the browser session before), they don't work:
So, why does it work with the API Explorer (Harbor bundled Swagger UI)? Because it runs in the browser and sends the cookies if they exist. If you try to use the API Explorer from a browser session where you haven't logged in with auth0 (or in which the cookies have expired) it doesn't work either (even if you put the username + cli secret in the swagger "login" form). An API call with the API Explorer looks like (not as simple as the curl command that it generates):
I'm not really familiar with harbor OIDC but from googling I believe to use the API with an OIDC provider you would need an OIDC token from the OIDC provider:
Here's some infos in the FAQ. And there's also an example how to get it from the Keycload OIDC provider: Looks like an API request against Keycloak's api. So I assume that if c8n.io would somehow show users their OIDC token then users could use it with I'm not sure if fetching the OIDC token is a standardized thing that is the same for all OIDC providers? (if so it might be possible to add it to @Vad1mo do you maybe have any idea how I could fetch the OIDC token for my c8n.io user? |
documented this as known limitation and changed issue label from bug to enhancement |
Thank you @christian-korneck for your investigation. Thats a bummer! "Service accounts" are on the roadmap. In some issue comment it noted that this will contain some sort of API Keys. Nevertheless, I will investigate further on how to get it working with AUTH0 for a normal user, The requested scopes |
API Keys are on the Roadmap for 2.2 see goharbor/harbor#13093 |
looks like harbor v2.2.0-rc1 has been released today, with 8 new APIs for robot accounts. I’ll try it soon. |
Yes, I have seen it this morning. Recalling the last demo I have seen regarding 2.2 it might still not work to update the Docs via the Robot account. However it will be quite easy to extend the permission, as they plan it to make it more flexible allowing to define custom permission. What we could do is to setup a test 2.2 instance quickly and see if it is working and if not crete a PR to harbor adding this capability. |
some related links (will look into this again soon'ish) |
Hi, there are any news or updates about this topic? Is the development still on going? |
yes, this project is still maintained. Regarding this issue: Not sure. There has been a lot of development in Harbor but I haven't tracked it. Are you are Harbor user? Can you test? |
quick update: This issue has likely been resolved by improvments made in Harbor. I just tried on the https://demo.goharbor.io demo instance and can confirm that a robot account with the "new" So we probably can update the docs and close this issue. The only reason why I'm leaving this issue open for now is that |
Harbor robot accounts are completely independent of the underlying auth system. |
…more OIDC issues), see #10
Thanks, Vadim! I've now also updated the docs: link . |
Hi, We are using harbor 2.11 but the permission "Update repository" is not available. In our case our robot account has these permissions: we can set these permissions (as you can see there is no "Update repository") Moreover, both in version 2.10 and 2.9 we can't see that permission. Which harbor version did you use in your example? |
Not all permission are exposed in the UI, also some UI permissions are combined of low level permissions. Take a look at the REST API docs. And maybe code to truly assess the situation. I don't want to tell something wrong here. |
@giosava94 Ive tried on the public demo server of the Harbor project. You can try and see for yourself. Maybe it helps you to figure out what's different with your system. Login infos are here: The "update repo" permissions are definitely visible in the UI (see screenshots above). Version of the demo server is always the latest (currently 2.11.0). |
Thank you very much. I will give it a try. |
I am trying out again docker-pushrm with now more realistic scenario.
My user
vad1mo
isProject Admin
on Project c8n. This Role is needed in Harbor to be able to edit the Project Info in the UI.However it seems that this role is not sufficient to update the project info via the API.
It might be also the case that we are using Harbor2 with OIDC, I verified in the API explorer that the user is able to do operations with the username/password, where password is the one taken from harbor->user->profile and not OIDC.
The text was updated successfully, but these errors were encountered: