Mercurial > hg
diff mercurial/hgweb/common.py @ 50439:4077d6222cf1
hgweb: add support to explicitly access hidden changesets
This changeset adds a "global" `access-hidden` argument to hgweb. This argument
lift the "hidden" filtering. This means the request has access to hidden (eg:
obsolete) changesets. Secret changesets remains filtered.
This feature has multiple applications. The first main use case is to allow the
hgweb interface to display more obsolescence related data, such as the Anton
Shestakov work to add `obslog` support to hgweb.
The second foreseen usecase is support for a `--remote-hidden` argument to `hg
pull` and `hg clone`. This flag will make it possible to retrieve hidden
(typically obsolete) changeset under some conditions. This is useful when
digging up obsolescence history or when doing full mirroring. More on this
feature coming in later changesets.
To avoid exposing information by mistake, access to this feature is currently
controlled with the `experimental.server.allow-hidden-access` config option. The
option works the same way as `web.allow-push`. The current default is to not
allow any hidden access. However we might change it before the feature stop
being experimental.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 13 Apr 2019 01:17:56 +0200 |
parents | 642e31cb55f0 |
children | 4bddc2f72879 |
line wrap: on
line diff
--- a/mercurial/hgweb/common.py Tue Mar 14 05:30:34 2023 +0100 +++ b/mercurial/hgweb/common.py Sat Apr 13 01:17:56 2019 +0200 @@ -13,6 +13,7 @@ import os import stat +from ..i18n import _ from ..pycompat import ( getattr, open, @@ -49,6 +50,32 @@ return userlist == [b'*'] or username in userlist +def hashiddenaccess(repo, req): + if bool(req.qsparams.get(b'access-hidden')): + # Disable this by default for now. Main risk is to get critical + # information exposed through this. This is expecially risky if + # someone decided to make a changeset secret for good reason, but + # its predecessors are still draft. + # + # The feature is currently experimental, so we can still decide to + # change the default. + ui = repo.ui + allow = ui.configlist(b'experimental', b'server.allow-hidden-access') + user = req.remoteuser + if allow and ismember(ui, user, allow): + return True + else: + msg = ( + _( + b'ignoring request to access hidden changeset by ' + b'unauthorized user: %r\n' + ) + % user + ) + ui.warn(msg) + return False + + def checkauthz(hgweb, req, op): """Check permission for operation based on request data (including authentication info). Return if op allowed, else raise an ErrorResponse