Adding authentication to hg serve

363 views
Skip to first unread message

hjazz6

unread,
Dec 30, 2010, 12:42:24 AM12/30/10
to merc...@selenic.com

Hi,

I've published my repositories using the command "hg serve --webdir-conf
/var/hg/hgwebdir.config" and I can see all my repositories on <ip
address>:8000. I would like to add authentication so that users will have to
enter their username and password before they can see the repositories.

After some Googling, I see that I need to create a .htacess file that is to
be placed in the folder where the html files are, a .htpasswd that contains
the username and password, and modify the /etc/httpd/conf/httpd.conf file.

My questions are:
1) Where should I put the .htaccess file? I don't know where the html files
are located at.
2) I'm not sure where to modify the httpd.conf file. I know I have to
include the following lines:
AuthName “Authorized Users Only.”
AuthType Basic
AuthUserFile <path>/.htpasswd
<Limit GET POST>
require valid-user
</Limit>

But where do I add these lines?

Please advise.

Thank you.
--
View this message in context: http://mercurial.808500.n3.nabble.com/Adding-authentication-to-hg-serve-tp2166270p2166270.html
Sent from the General mailing list archive at Nabble.com.
_______________________________________________
Mercurial mailing list
Merc...@selenic.com
http://selenic.com/mailman/listinfo/mercurial

Matt Mackall

unread,
Dec 30, 2010, 12:52:25 AM12/30/10
to hjazz6, merc...@selenic.com
On Wed, 2010-12-29 at 21:42 -0800, hjazz6 wrote:
> Hi,
>
> I've published my repositories using the command "hg serve --webdir-conf
> /var/hg/hgwebdir.config" and I can see all my repositories on <ip
> address>:8000. I would like to add authentication so that users will have to
> enter their username and password before they can see the repositories.

'hg serve' does not (and will never) support any form of authentication.
We are intentionally avoiding turning 'hg serve' into a full-featured
web server as so many already exist. So if you want a feature that 'hg
serve' doesn't have (like authentication, proper SSL, virtual hosting,
etc.), you need to use a proper web server.

--
Mathematics is the supreme nostalgia of our time.

hjazz6

unread,
Dec 30, 2010, 1:39:11 AM12/30/10
to merc...@selenic.com

I understand that the .htaccess, .htpasswd, httpd.conf files have to do with
Apache. Do you mean that because I'm using hg serve, it doesn't look at all
these Apache files? What is the Apache alternative to hg serve, then?
--
View this message in context: http://mercurial.808500.n3.nabble.com/Adding-authentication-to-hg-serve-tp2166270p2166367.html

Sent from the General mailing list archive at Nabble.com.

Matt Mackall

unread,
Dec 30, 2010, 1:52:55 AM12/30/10
to hjazz6, merc...@selenic.com
On Wed, 2010-12-29 at 22:39 -0800, hjazz6 wrote:
> I understand that the .htaccess, .htpasswd, httpd.conf files have to do with
> Apache. Do you mean that because I'm using hg serve, it doesn't look at all
> these Apache files?

Right. hg serve uses Mercurial's built-in webserver, and has nothing at
all to do with Apache or its configuration.

> What is the Apache alternative to hg serve, then?

It's called 'hgweb'. Start here:

http://mercurial.selenic.com/wiki/PublishingRepositories

--
Mathematics is the supreme nostalgia of our time.

Martin Geisler

unread,
Dec 30, 2010, 4:23:55 AM12/30/10
to hjazz6, hst...@hstuart.dk, merc...@selenic.com
hjazz6 <hja...@ymail.com> writes:

> Hi,
>
> I've published my repositories using the command "hg serve --webdir-conf
> /var/hg/hgwebdir.config" and I can see all my repositories on <ip
> address>:8000. I would like to add authentication so that users will have to
> enter their username and password before they can see the repositories.

As Matt writes, there is no built-in support for authentication in 'hg
serve'. However, Henrik Stuart has made an extension for this:

https://bitbucket.org/hstuart/hg-textauth

I have not tried it recently, but please give it a go and let us know
what you think of it.

--
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/

hjazz6

unread,
Dec 30, 2010, 10:57:16 PM12/30/10
to merc...@selenic.com

Hi,

I included the extension, textauth, in my repo hgrc file.
When I did a hg authedit -c username, I get an error "no authentication file
is specified".
Is this the right command to create the authentication file?
What are the steps after this?

Please advise. Thank you.
--

View this message in context: http://mercurial.808500.n3.nabble.com/Adding-authentication-to-hg-serve-tp2166270p2170800.html


Sent from the General mailing list archive at Nabble.com.

Martin Geisler

unread,
Jan 3, 2011, 3:40:51 AM1/3/11
to hjazz6, merc...@selenic.com
hjazz6 <hja...@ymail.com> writes:

> Hi,
>
> I included the extension, textauth, in my repo hgrc file. When I did a
> hg authedit -c username, I get an error "no authentication file is
> specified". Is this the right command to create the authentication
> file? What are the steps after this?

Yeah, that is a bit cryptic... The error means that you have to setup
textauth.file -- that is, put

[textauth]
file = /some/path/to/my/password/file

into the .hg/hgrc file. See 'hg help textauth' after enabling the
extension.

--
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/

Reply all
Reply to author
Forward
0 new messages