Gitblit API ?

950 views
Skip to first unread message

Amelie

unread,
Jul 18, 2013, 9:36:30 PM7/18/13
to git...@googlegroups.com
Hi,

I was looking for a tool to manage git projects, repositories and their accessibility and I found that Gitblit answer very good to my requirements.

But now, I am looking to use the API to get informations about a certain user from a PHP application. I have installed Gitblit on Tomcat 6.0, running at http://localhost:8080/gitblit and I also installed PHP-Java Bridge so I can call Java Gitblit API methods from a PHP script (running on lamp, apache 2.2).

It is working almost well, but since I can not find a lot of information about the gitblit API on the Internet (except the javadoc included in the API zip I downloaded), I was wondering if I can get the information below thanks to this API :
  • all the repositories of a user with the rights associated
  • user's information ( I've seen that a Gravatar class exists, but I have issues to use it right)

These data are required to be shown in my PHP script, so is there any way to get them through the API that Gitblit provide ?


Thank you for your help !

Amelie.

James Moger

unread,
Jul 19, 2013, 9:10:56 AM7/19/13
to git...@googlegroups.com
Hi Amelie,

There is some documentation about the RPC interface here: http://www.gitblit.com/rpc.html

There is a unit test which exercises all RPC methods: https://demo-gitblit.rhcloud.com/blob/gitblit.git/HEAD/src!test!java!com!gitblit!tests!RpcTests.java

You can get the user's permitted repositories by requesting the list of repositories.
https://next-gitblit.rhcloud.com/rpc?req=LIST_REPOSITORIES

This request, however, does not include the user's access permissions.  There isn't an API to get the current user's information and permissions.  There probably should be.

I'll put this on the todo list.

-J​

Amelie

unread,
Jul 22, 2013, 9:18:22 PM7/22/13
to git...@googlegroups.com
Hi James,

Thank you for your answer.

I have another question concerning the API.
I have an application that uses LDAP authentication. In this application, I want to use Gitblit API to show user's associated account information on Gitblit (such as the number of commit, repositories ...). The template code I use is the following :

reg = new GitblitRegistration( "admin", "http://localhost:8080/gitblit/", "admin", "password");
client = new GitblitClient(reg);
client.login();

With this method I can get some data (like repositories information). But, because I do not have access to non-encrypted password, I can not use the GitblitRegistration constructor above. So the problem is about the LDAP authentication : is there any way to use such a method to login through the API ?

Thank you again,
Amelie.


James Moger

unread,
Jul 23, 2013, 7:44:26 AM7/23/13
to git...@googlegroups.com
Hmm.  I'm not sure I understand your question.

Previously you had asked about getting a specific users's info.  I have added a new RPC request type for getting either the current user (requested user matches authentication credentials) or any user (if authentication credentials are for an administrator).  This will be available in 1.3.1.

If you are asking if Gitblit can authenticate against LDAP: yes it can.  You still need a username & password, though.

-J

Amelie

unread,
Jul 23, 2013, 9:14:32 PM7/23/13
to git...@googlegroups.com
I am sorry for not being very clear. I am not even sure that my question is relevant, so sorry if it sounds stupid.

Although my situation is simple. I have an application (not Gitblit) that uses LDAP authentication. In this application I am going to use the API to show some information about the user (who have been previously created on Gitblit through his LDAP authentication). The problem is that I do not know how to use the API / RPC methods because most of them need the password of the user, and I only have the encrypted password in my database.

For instance, I do not know how to do
Map<String, RepositoryModel> repositories = RpcUtils.getRepositories(url, account,
               password.toCharArray());
since I do not have user's password.

However, Gitblit is a very great tool, thank you for developing it, and for updating the RPC.
Thank you for your answers also.

Amelie.


James Moger

unread,
Jul 24, 2013, 7:56:58 AM7/24/13
to git...@googlegroups.com
Hi Amelie,

The Gitblit API requires valid user credentials so your encrypted password won't do.  Perhaps you could create a local bot account in your Gitblit install with admin privileges and use that account to grab the user information?

-J
Reply all
Reply to author
Forward
0 new messages