optional authentication in apache

155 views
Skip to first unread message

Miklos Espak

unread,
May 5, 2012, 8:29:01 PM5/5/12
to gitolite
Hi,

sorry, an Apache question again.

I have set up a gitolite server with http and https with your great help.

I am wondering if it's possible to provide read-only access for those who don't provide a username/password when connect, and read-write access for those who authenticate themselves.

The repository entry:

repo testing
     R       =   daemon gitweb
     RW+     =   @admin
     RW      =   @me
     R       =   @all

The apache config (now it requires authentication):

<Location /git>
    AuthType Basic
    AuthName "Git Access"
    Require valid-user
    AuthUserFile /data/access/cmic.htpasswd
</Location>

So, this works, but I would like to allow both, but with ro and rw access, respectively:

$ git clone https://myhost.com/git/testing.git
and
$ git clone https://me:***@myhost.com/git/testing.git

Is it possible?

Thank you,
Miklos

Sitaram Chamarty

unread,
May 5, 2012, 10:30:17 PM5/5/12
to Miklos Espak, gitolite
On Sun, May 6, 2012 at 5:59 AM, Miklos Espak <esp...@gmail.com> wrote:

> I am wondering if it's possible to provide read-only access for those who
> don't provide a username/password when connect, and read-write access for
> those who authenticate themselves.

> $ git clone https://myhost.com/git/testing.git
> and
> $ git clone https://me:***@myhost.com/git/testing.git

I don't know how to do this with the same uri ("/git/reponame.git").
I don't think it is possible -- browsers don't send auth info unless
*asked to*, IIRC.

Anyway...

(1) If you followed the instructions you should also have a
scriptalias for 'gitmob'. Unauthenticated URLs would look like
https://myhost.com/gitmob/testing.git

(2) add a variable called HTTP_ANON_USER to the rc file, giving it
whatever value you want. I suggest "mob".

(3) in your conf file, add somewhere

repo @all
R = mob

(4) tell people the correct URLs to use.

Miklos Espak

unread,
May 5, 2012, 10:56:49 PM5/5/12
to Sitaram Chamarty, gitolite
Actually, I have removed that mob line, because I did not see what was it for. :)

It works great, thanks!

Miklos
Reply all
Reply to author
Forward
0 new messages