Nov
27
2011
How to setup Http Authentication on a mercurial project

Mercurial has an excellent built-in extension for serving your code to other via http.

hg help serve

but hasnt have any authentication method.

You can, of course, use ssh to control access to your project, a http server (or wsgi).

Searching on Extensions wiki page, i’ve came up with hg-textauth!

In a few minutes i had textauth extension in my linux box.

Lets get started with:

A.

~/.hgrc


[extensions]
textauth = /FULL_PATH/textauth.py

[textauth] 
file= /FULL_PATH/text.auth

B.


touch /FULL_PATH/text.auth
hg authedit -v -c ebal

Enter password: ******
Verify password: ******

That’s it!
Now test it

C.


hg serve

And in another shell (machine/whatever):

D.


hg clone http://example.com:8000 myproject.hg
requesting all changes
http authorization required
realm: mercurial

user: ebal
password: ******

adding changesets
adding manifests
adding file changes
added 1 changesets with 4 changes to 4 files
updating to branch default
resolving manifests

getting ToDo
getting help.html
getting image.png
getting myproject.py
4 files updated, 0 files merged, 0 files removed, 0 files unresolved

Tag(s): mercurial