Rest API for User Management

42 views
Skip to first unread message

praveen mummasani

unread,
Dec 13, 2018, 4:15:34 PM12/13/18
to harbor-dev
Hello Team,

We have installed goharbor and we have integrated with Ldap.Now we want to use Rest API for user management so that we can add users to project with out logging into UI.
I tried from the link https://confluence.csiro.au/display/SC/Harbor+API where i can use only role/groups can be added to project via API but not individual users.

Could some one please help me on providing API reference for Add/Remove user from the Project

Thanks
Praveen

Steven Zou

unread,
Dec 13, 2018, 7:12:44 PM12/13/18
to praveen mummasani, harbor-dev, Wenkai Yin, Yan Wang

Praveen,

 

  Thanks for reaching us. You can refer the latest swaager API doc : https://github.com/goharbor/harbor/blob/master/docs/swagger.yaml.

 

@Wenkai Yin@Yan Wang

 

  Please help Praveen if necessary. Thanks!

 

thanks&regards

-- 

Steven (邹佳)

 

Engineer, CNA, VMware R&D

 

Cell: +8618600021252

Addr: 9F Tower C, Raycom Info Tech Park, No. 2 Kexueyuan South Road Haidian District, Beijing 100738 China

 

--
You received this message because you are subscribed to the Google Groups "harbor-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbor-dev+...@googlegroups.com.
To post to this group, send email to harbo...@googlegroups.com.
Visit this group at https://groups.google.com/group/harbor-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbor-dev/553a5e01-5258-4123-affd-95e3293c5700%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yan Wang

unread,
Dec 13, 2018, 9:24:51 PM12/13/18
to praveen mummasani, harbor-dev

Hi Praveen,

 

You can just refer to the swagger document in the goharbor repo.

https://github.com/goharbor/harbor/blob/master/docs/swagger.yaml

 

Thanks,

Yan

 

From: <harbo...@googlegroups.com> on behalf of praveen mummasani <mummasan...@gmail.com>
Date: Friday, 14 December 2018 at 5:15 AM
To: harbor-dev <harbo...@googlegroups.com>
Subject: [harbor-dev] Rest API for User Management

 

Hello Team,

--

praveen mummasani

unread,
Dec 14, 2018, 1:13:51 AM12/14/18
to Yan Wang, harbor-dev
Hi Yan,

Thanks for your reply.
I tried all from the link already.
Could you please give me exact API call for adding user into project.

Thanks
Praveen

Atlas Kerr

unread,
Dec 14, 2018, 1:26:18 AM12/14/18
to mummasan...@gmail.com, wan...@vmware.com, harbo...@googlegroups.com
POST /projects/{project_id}/members

Yan Wang

unread,
Dec 14, 2018, 1:35:00 AM12/14/18
to praveen mummasani, harbor-dev

Just try with POST /projects/{project_id}/members

 

praveen mummasani

unread,
Dec 14, 2018, 1:42:43 AM12/14/18
to harbor-dev
I Tried below command and used verbose for capturing the output,could you please check what is the issue here.

curl -v -u admin:Harbor12345 -d ‘{“project_id”:”7”,”user_id”:”11”,"roles":"1"}’ -H "Content-Type: application/json" -X POST https://<go-harbor-server-url>/api/projects/7/members




Note: Unnecessary use of -X or --request, POST is already inferred.

* Rebuilt URL to: ‘”user_id”:”11”’/

* Port number ended with '?'

* Closing connection -1

curl: (3) Port number ended with '?'

Note: Unnecessary use of -X or --request, POST is already inferred.

* Rebuilt URL to: ‘roles:1’/

* Port number ended with '?'

* Closing connection -1

curl: (3) Port number ended with '?'

Note: Unnecessary use of -X or --request, POST is already inferred.

*   Trying <go-harbor-server>...

* TCP_NODELAY set

* Connected to <go-harbor-server> port 443 (#0)

* ALPN, offering h2

* ALPN, offering http/1.1

* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH

* successfully set certificate verify locations:

*   CAfile: /etc/ssl/cert.pem

  CApath: none

* TLSv1.2 (OUT), TLS handshake, Client hello (1):

* TLSv1.2 (IN), TLS handshake, Server hello (2):

* TLSv1.2 (IN), TLS handshake, Certificate (11):

* TLSv1.2 (IN), TLS handshake, Server key exchange (12):

* TLSv1.2 (IN), TLS handshake, Server finished (14):

* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):

* TLSv1.2 (OUT), TLS change cipher, Client hello (1):

* TLSv1.2 (OUT), TLS handshake, Finished (20):

* TLSv1.2 (IN), TLS change cipher, Client hello (1):

* TLSv1.2 (IN), TLS handshake, Finished (20):

* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384

* ALPN, server did not agree to a protocol

* Server certificate:

 subject: C=US; ST=New York; L=Armonk; O=International Business Machines Corporation; CN=*.<go-harbor-server>

 start date: Feb  2 00:00:00 2018 GMT

 expire date: Apr  5 12:00:00 2021 GMT

*  subjectAltName: host "<go-harbor-server>

" matched cert's "*.<go-harbor-server>

t"

 issuer: C=US; O=DigiCert Inc; CN=DigiCert SHA2 Secure Server CA

 SSL certificate verify ok.

* Server auth using Basic with user 'admin'

> POST /api/projects/7/members/ HTTP/1.

> Authorization: Basic YWRtaW46SGFyYm9yMTIzNDU=

> User-Agent: curl/7.54.0

> Accept: */*

> Content-Type: application/json

> Content-Length: 30

* upload completely sent off: 30 out of 30 bytes

< HTTP/1.1 400 Bad Request

< X-Backside-Transport: FAIL FAIL

< Connection: Keep-Alive

< Transfer-Encoding: chunked

< Content-Type: text/plain; charset=utf-8

< Date: Fri, 14 Dec 2018 06:33:21 GMT

< Server: nginx

< Set-Cookie: beegosessionID=cbf09900d634127f8ad6a0ac956fbc31; Path=/; secure; HttpOnly

< X-Global-Transaction-ID: 78ff105c5c134eb10e69d513

Praveen

To post to this group, send email to harb...@googlegroups.com.

Atlas Kerr

unread,
Dec 14, 2018, 1:49:50 AM12/14/18
to praveen mummasani, harbor-dev
You're json structure is incorrect. Please refer to the screenshot Yan provided you.

To post to this group, send email to harbo...@googlegroups.com.

Yan Wang

unread,
Dec 14, 2018, 1:54:32 AM12/14/18
to Atlas Kerr, praveen mummasani, harbor-dev

Yes, you should correct the request data, one example for you: add user2 as a Developer into library

 

POST /api/projects/1/members

 

{ "role_id": 2, "member_user": { "username": "user2" } }

 

Thanks,

Yan

 

From: <harbo...@googlegroups.com> on behalf of Atlas Kerr <atla...@gmail.com>
Date: Friday, 14 December 2018 at 2:49 PM
To: praveen mummasani <mummasan...@gmail.com>
Cc: harbor-dev <harbo...@googlegroups.com>
Subject: Re: [harbor-dev] Rest API for User Management

 

You're json structure is incorrect. Please refer to the screenshot Yan provided you.

Image removed by sender.

praveen mummasani

unread,
Dec 14, 2018, 5:44:55 AM12/14/18
to Yan Wang, atla...@gmail.com, harbor-dev
Thanks Yan,Atlas..Sorry to bug again..i am getting same error even following the same format sent by Yan
curl -v -u admin:Harbor12345 -d '{"role_id":"2","member_user":"{"username”:"user1" }"}' -H "Content-Type: application/json" -X POST <server-url>/api/projects/7/members/
Could you please point me where i am missing.

Thanks
Praveen
Reply all
Reply to author
Forward
0 new messages