BanditoBunny
BanditoBunny

Reputation: 3896

Mercurial web user authorization

We installed Mercurial on the server which we use to synchronize developer's local repositories. We use stand alone mercurial web server (hg serve), what we want is to grant access to the web server only to the authorized users, right now it is accessible to all.

Is there any way to configure authorization for Mercurial stand alone web server?

In the configuration file (hgrc) there is a section called [auth] where a list of users can be defined, but it seems it is used for something else, not for web server.

Upvotes: 1

Views: 1245

Answers (1)

Helgi
Helgi

Reputation: 5436

hg serve allows you to set up authorization rules in [auth], but doesn't handle authentication on its own. It should be provided by a web server.

You have at least these two options for authentication handling:

  1. Configure the hgweb script with Apache, lighttpd, or another web server of your choice.
  2. Put hg serve behind nginx.

Edit. Here's an excerpt from my nginx config file (requests auth for both read and write):

location / {
    auth_basic            "hg-server";
    auth_basic_user_file  /path/to/htpasswd/file;
    proxy_pass            http://127.0.0.1:8000;
    proxy_set_header      REMOTE_USER $remote_user;
}

Upvotes: 2

Related Questions