You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Josh Gilkerson <jw...@google.com> on 2007/03/27 16:47:21 UTC
"SVNAuthorizationShortCircuit or something similar"
This message is in response to one posted by Justin Erenkrantz on
2007-03-14 06:35:14 CET with the subject Re: svn commit: r23806 -
branches/artem-soc-work/subversion/mod_dav_svn
Is anyone planning on pursuing the route described in the message? In
short the idea is to allow a site administrator to reduce mod_dav_svn
overhead by bypassing the generation of an http subreqeust to check
permissions when using mod_auth_svn.
I am planning to implement this feature and would like to avoid
duplication of effort if someone else is already working on it.
Any input is welcome.
Thanks,
Josh Gilkerson
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Josh Gilkerson <jw...@google.com>.
Latest patch. I am fairly certain that this is functioning properly.
For configuration, I have overloaded the SVNPathAuthz. The values on
and off and the default value(on) have retained their meaning, so
configurations shouldn't be broken (Are there other apache will parse
as on or off for a boolean option?). There is then another value,
currently 'dangerous_direct', that indicates that mod_dav_svn should
authorize directly to mod_authz_svn.
I'm very willing to take suggestions on what this third configuration
value should be.
Josh Gilkerson
On 4/13/07, Josh Gilkerson <jw...@google.com> wrote:
> There are some very obvious bugs in the previous patch, but with
> fixes, it seems to work. I still want to do more correctness testing
> and post the patch this weekend. Performance seems to be vastly
> improved.
>
> Getting the log for a commit with ~25000 additions:
> "stock" ubuntu module: 12.6 s
> patched module, default: 12.6 s
> patched module, bypass: 0.9 s
>
> So it looks like a speed up of >10x on this size operation.
>
> Regarding caching the provider lookup, I want to run this by you guys
> and make sure I'm not doing something I shouldn't be. I added a
> static variable in mod_dav_svn.c that holds the pointer. In the
> configuration callback, if bypass is configured and it is still NULL,
> I do the lookup and set it. Seems to work, but I'm not an apache
> guru.
>
> Another point I am not completely sure about, using the subrequest
> builds a uri with escaping, etc. The authz handler then splits the
> uri, but it doesn't appear that it does any unescaping. Does the
> subrequest mechanism do this or does the lower authz function expect
> an uri-escaped path? And a related note, it seems that the revision
> is ignored by the authz mechanism. This makes sense given the authz
> file format, but again, I want to make sure.
>
> --
> Josh Gilkerson
> Software Engineer
> Google, Inc · MV-1600 Plymouth (HQ)
> +1 (650) 253-1667 direct
> +1 (859) 608-7827 cell
> jwg@google.com
>
--
Josh Gilkerson
Software Engineer
Google, Inc · MV-1600 Plymouth (HQ)
+1 (650) 253-1667 direct
+1 (859) 608-7827 cell
jwg@google.com
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Josh Gilkerson <jw...@google.com>.
There are some very obvious bugs in the previous patch, but with
fixes, it seems to work. I still want to do more correctness testing
and post the patch this weekend. Performance seems to be vastly
improved.
Getting the log for a commit with ~25000 additions:
"stock" ubuntu module: 12.6 s
patched module, default: 12.6 s
patched module, bypass: 0.9 s
So it looks like a speed up of >10x on this size operation.
Regarding caching the provider lookup, I want to run this by you guys
and make sure I'm not doing something I shouldn't be. I added a
static variable in mod_dav_svn.c that holds the pointer. In the
configuration callback, if bypass is configured and it is still NULL,
I do the lookup and set it. Seems to work, but I'm not an apache
guru.
Another point I am not completely sure about, using the subrequest
builds a uri with escaping, etc. The authz handler then splits the
uri, but it doesn't appear that it does any unescaping. Does the
subrequest mechanism do this or does the lower authz function expect
an uri-escaped path? And a related note, it seems that the revision
is ignored by the authz mechanism. This makes sense given the authz
file format, but again, I want to make sure.
--
Josh Gilkerson
Software Engineer
Google, Inc · MV-1600 Plymouth (HQ)
+1 (650) 253-1667 direct
+1 (859) 608-7827 cell
jwg@google.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 4/12/07, Josh Gilkerson <jw...@google.com> wrote:
> When we can do the lookup was one question that I had. Is it
> guaranteed that the authz register_hooks(where the provider is
> registered) is called before the dav configuration? Or should I be
> registering the provider somewhere else?
register_hooks is called when the modules are loaded into memory - it
is indeed the right place to register hooks.
So, by the time the configuration is processed, the providers should
already be registered - so you should be able to do a lookup and get
the associated vtable back and store that in mod_dav_svn's config
structure. So when mod_dav_svn needs to do authz, the config
structure should have the vtable available for invocation.
> In the patch, I do the lookup each time because it seemed the safest
> thing to do without knowing the order of these calls and it should be
> fast.
Safe, but not optimal. =) -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Josh Gilkerson <jw...@google.com>.
When we can do the lookup was one question that I had. Is it
guaranteed that the authz register_hooks(where the provider is
registered) is called before the dav configuration? Or should I be
registering the provider somewhere else?
In the patch, I do the lookup each time because it seemed the safest
thing to do without knowing the order of these calls and it should be
fast.
On 4/12/07, Justin Erenkrantz <ju...@erenkrantz.com> wrote:
>
> Without looking at Josh's patch, you should be able to do the provider
> lookup at config time (2 hash tables lookups) and then you'd invoke
> the function pointer each time. So, it should be the same as a
> regular function call. The point is that you are bypassing Apache's
> sub-req creation overhead which is why the performance can suck. It
> should reduce to an identical call profile as artem's approach, but
> keeping the modules distinct. -- justin
>
--
Josh Gilkerson
Software Engineer
Google, Inc · MV-1600 Plymouth (HQ)
+1 (650) 253-1667 direct
+1 (859) 608-7827 cell
jwg@google.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 4/12/07, David James <ja...@cs.toronto.edu> wrote:
> Hi Josh,
>
> With your patch, a request for a log message would still generate 1
> lookup per file affected in the revision. If a revision affects, say,
> a hundred thousand files, your patch would still trigger a hundred
> thousand provider lookups and a hundred thousand calls to said
> provider when a user requests to look at the log message.
>
> What is the overhead of a provider lookup and call as compared to a
> regular function call? If it's not a lot more expensive then maybe
> this is not an issue.
Without looking at Josh's patch, you should be able to do the provider
lookup at config time (2 hash tables lookups) and then you'd invoke
the function pointer each time. So, it should be the same as a
regular function call. The point is that you are bypassing Apache's
sub-req creation overhead which is why the performance can suck. It
should reduce to an identical call profile as artem's approach, but
keeping the modules distinct. -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Josh Gilkerson <jw...@google.com>.
The default method does much more than just a function call. It has
to create the subrequest, which does some data conversion, go through
the apache handler chain, then undo the data conversion. The same
step is replaced with a lookup (should be very fast) and a function
call.
I'm planning on testing something very similar to what you suggest.
On 4/12/07, David James <ja...@cs.toronto.edu> wrote:
> Hi Josh,
>
> With your patch, a request for a log message would still generate 1
> lookup per file affected in the revision. If a revision affects, say,
> a hundred thousand files, your patch would still trigger a hundred
> thousand provider lookups and a hundred thousand calls to said
> provider when a user requests to look at the log message.
>
> What is the overhead of a provider lookup and call as compared to a
> regular function call? If it's not a lot more expensive then maybe
> this is not an issue.
>
> Try importing a hundred thousand files in a single revision into a
> repository, and then running 'svn log' on any file on the repository.
> If you do this using ra_svn you'll find that there are no performance
> issues, even with authz enabled. Without your patch, ra_dav takes
> about 30-90 minutes to calculate all of the authz lookups in this
> scenario.
>
> I'd be curious to see how much your patch helps.
>
> Cheers,
>
> David
>
--
Josh Gilkerson
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by David James <ja...@cs.toronto.edu>.
On 4/12/07, Josh Gilkerson <jw...@google.com> wrote:
> Since some sites need the performance soon, I have written a first
> draft of a change that will add a mechanism to bypass the generation
> of apache subrequests. I have not had time to test it except to make
> sure it compiles.
>
> Any comments/criticisms are more than welcome. I will update this
> thread concerning the testing and debugging once I have time to do
> some.
Hi Josh,
With your patch, a request for a log message would still generate 1
lookup per file affected in the revision. If a revision affects, say,
a hundred thousand files, your patch would still trigger a hundred
thousand provider lookups and a hundred thousand calls to said
provider when a user requests to look at the log message.
What is the overhead of a provider lookup and call as compared to a
regular function call? If it's not a lot more expensive then maybe
this is not an issue.
Try importing a hundred thousand files in a single revision into a
repository, and then running 'svn log' on any file on the repository.
If you do this using ra_svn you'll find that there are no performance
issues, even with authz enabled. Without your patch, ra_dav takes
about 30-90 minutes to calculate all of the authz lookups in this
scenario.
I'd be curious to see how much your patch helps.
Cheers,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Josh Gilkerson <jw...@google.com>.
For the impatient, Max might have a point, but I have attached an
untested patch that implements the use of a provider to eliminate the
subrequests. I am working on doing some testing, but I'd like comment
now if there is something obviously wrong with the way I am
proceeding.
Max definitely makes some good points and merging the two modules
might be a good long term solution, but a change like that should
probably wait for a major release, since it would probably break
current configurations and would require much more code.
Since some sites need the performance soon, I have written a first
draft of a change that will add a mechanism to bypass the generation
of apache subrequests. I have not had time to test it except to make
sure it compiles.
Any comments/criticisms are more than welcome. I will update this
thread concerning the testing and debugging once I have time to do
some.
--
Josh Gilkerson
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Max Bowsher <ma...@ukf.net>.
OK, here's my perspective on this topic.
Currently, mod_dav_svn 'explodes' a request that involves multiple paths
into a subrequest for each path in order to "call through" the Apache
infrastructure to mod_authz_svn.
The negative consequences of this are that it doesn't support a way to
do recursive access checking, and that it involves a fair amount of
conversion of data that is redundant in the very common case of only
mod_authz_svn doing any sort of within-repository authz.
The direction that I think we should take to solve this is:
mod_authz_svn becomes deprecated *entirely*. It ceases to exist in 2.0.
Aside from the efficiency concerns, I'd also like to see this happen in
order to resolve the disparity between the authz implementations for
http and svnserve access. For svnserve access, authz policy is enforced
mostly at the svn_repos layer. For http access, large parts of the authz
policy are defined not in terms of svn_repos operations, but in terms of
DAV HTTP requests. I dislike very much that we essentially have two
different implementations of authz enforcement, varying by access
method. Enforcing at the HTTP request layer was a neat trick, back when
the svn_repos layer didn't have any authz support, but now that the
svn_repos layer has been enhanced in this way (to allow svnserve to have
authz too), I view the continued use of enforcement at the HTTP request
layer as being akin to the use of a deprecated API.
Justin is right - this will completely break anything that is trying to
enforce authz via the interpretation of /!svn/ URLs at the Apache layer.
To continue to support that, mod_authz_svn will need to continue to
exist during Subversion 1.x. Users of such methods will need to migrate
to some other system, come 2.0. Bear in mind that there are very few
such users:
* custom modules
* Direct <LocationMatch> involving /!svn/
The first can become either patches to the authz code, or we might
consider creating a DSO system in the spirit of the FS and RA modules if
there is enough interest.
The second, should migrate to using real Subversion authz rules. I
don't think that using /!svn/ in <LocationMatch> is really a valid
use-case anyway - we have *never* made promises about those URLs - we
could add additional namespaces under /!svn/ at any time which would
utterly invalidate any such <LocationMatch> constructs.
Max.
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Eric Gillespie <ep...@pretzelnet.org>.
"Justin Erenkrantz" <ju...@erenkrantz.com> writes:
> On 5/10/07, Eric Gillespie <ep...@pretzelnet.org> wrote:
> > Justin, you're far more familiar with this than i am: Last
> > chance to comment before i commit later today :)
>
> Go commit it already. =) -- justin
Committed revision 24991.
--
Eric Gillespie <*> epg@pretzelnet.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 5/10/07, Eric Gillespie <ep...@pretzelnet.org> wrote:
> Justin, you're far more familiar with this than i am: Last
> chance to comment before i commit later today :)
Go commit it already. =) -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Eric Gillespie <ep...@pretzelnet.org>.
"Josh Gilkerson" <jw...@google.com> writes:
> Good to see someone else is still watching. I was getting ready to
> prod the list if there was no activity in the next day or so.
>
> Your patch is missing the addition of "subversion/include/mod_authz_svn.h".
Oops, patch created your file, but i did not notice. svn added.
> Draft log message:
Looks fine to me, except for minor formatting, e.g.
> Added authz optimization to mod_dav_svn that skips apache authz for
> parent paths.
>
> * subversion/mod_authz_svn/mod_authz_svn.c: Added a provider that will do
> a quick read access check.
* subversion/mod_authz_svn/mod_authz_svn.c
Added a provider that will do a quick read access check.
Justin, you're far more familiar with this than i am: Last
chance to comment before i commit later today :)
--
Eric Gillespie <*> epg@pretzelnet.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Josh Gilkerson <jw...@google.com>.
Good to see someone else is still watching. I was getting ready to
prod the list if there was no activity in the next day or so.
Your patch is missing the addition of "subversion/include/mod_authz_svn.h".
Draft log message:
Added authz optimization to mod_dav_svn that skips apache authz for
parent paths.
* subversion/mod_authz_svn/mod_authz_svn.c: Added a provider that will do
a quick read access check.
(subreq_bypass): new method. This is the implementation of a provider
that will be called from mod_dav_svn to bypass the apache authz process.
(get_access_conf): new method. This is a cut and paste from existing
code that that is needed in subreq_bypass. It was pulled out to
eliminate duplication.
(register_hooks): was modified to register the new provider.
* subversion/include/mod_authz_svn.h: Provides the symbols that need to be
shared with mod_dav_svn.
(AUTHZ_SVN__SUBREQ_BYPASS_PROV_GRP,
AUTHZ_SVN__SUBREQ_BYPASS_PROV_NAME,
AUTHZ_SVN__SUBREQ_BYPASS_PROV_VER): Provider lookup info.
(authz_svn__subreq_bypass_func_t): Signature of the provider method.
* subversion/mod_dav_svn/mod_dav_svn.c:
(PATHAUTHZ_BYPASS_ARG): string argument to SVNPathAuthz directive that will
enable bypassing apache's authz mechanism.
(enum path_authz_conf): configuration type. For this directive, which
is now a tri-state instead of a boolean.
(dir_conf_t): changed do_path_authz to path_authz_method. The name was
changed to denote the new meaning of the variable.
(pathauthz_bypass_func): a new function pointer variable. The
bypass provider is
cached here.
(merge_dir_config, SVNPathAuthz_cmd,cmds, dav_svn__get_pathauthz_flag):
Changed to interact with the new config.
(dav_svn__get_pathauthz_bypass): new method.
* subversion/mod_dav_svn/dav_svn.h
(dav_svn__get_pathauthz_bypass): new function to get the bypass provider if
configured.
* subversion/mod_dav_svn/authz.c
(allow_read): Uses the new method if configured.
--
Josh Gilkerson
Software Engineer
Google, Inc
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Eric Gillespie <ep...@pretzelnet.org>.
Eric Gillespie <ep...@pretzelnet.org> writes:
> I think we've waited long enough for people to object :). I'm
> going to commit this change today or tomorrow. I'll fix what
> formatting issues i find, but i'm not the biggest expert on
> Subversion style either ;->.
Here's an updated patch. I changed the option value to
"short_circuit" and corrected the style problems i found.
Compiles without warnings, davautocheck running now.
Josh, all we lack now is a log message. Take a look at
<http://svn.collab.net/repos/svn/trunk/www/hacking.html#log-messages>.
Thanks.
Index: subversion/mod_authz_svn/mod_authz_svn.c
===================================================================
--- subversion/mod_authz_svn/mod_authz_svn.c (revision 24955)
+++ subversion/mod_authz_svn/mod_authz_svn.c (working copy)
@@ -26,6 +26,7 @@
#include <http_protocol.h>
#include <http_log.h>
#include <ap_config.h>
+#include <ap_provider.h>
#include <apr_uri.h>
#include <mod_dav.h>
#if AP_MODULE_MAGIC_AT_LEAST(20060110,0)
@@ -34,6 +35,7 @@
#endif
#include "mod_dav_svn.h"
+#include "mod_authz_svn.h"
#include "svn_path.h"
#include "svn_config.h"
#include "svn_string.h"
@@ -95,6 +97,48 @@
{ NULL }
};
+/*
+ * Get the, possibly cached, svn_authz_t for this request.
+ */
+static svn_authz_t *get_access_conf(request_rec *r,
+ authz_svn_config_rec *conf)
+{
+ const char *cache_key = NULL;
+ void *user_data = NULL;
+ svn_authz_t *access_conf = NULL;
+ svn_error_t *svn_err;
+ char errbuf[256];
+
+ cache_key = apr_pstrcat(r->pool, "mod_authz_svn:",
+ conf->access_file, NULL);
+ apr_pool_userdata_get(&user_data, cache_key, r->connection->pool);
+ access_conf = user_data;
+ if (access_conf == NULL) {
+ svn_err = svn_repos_authz_read(&access_conf, conf->access_file,
+ TRUE, r->connection->pool);
+ if (svn_err) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR,
+ /* If it is an error code that APR can make sense
+ of, then show it, otherwise, pass zero to avoid
+ putting "APR does not understand this error code"
+ in the error log. */
+ ((svn_err->apr_err >= APR_OS_START_USERERR &&
+ svn_err->apr_err < APR_OS_START_CANONERR) ?
+ 0 : svn_err->apr_err),
+ r, "Failed to load the AuthzSVNAccessFile: %s",
+ svn_err_best_message(svn_err,
+ errbuf, sizeof(errbuf)));
+ svn_error_clear(svn_err);
+ access_conf = NULL;
+ } else {
+ /* Cache the open repos for the next request on this connection */
+ apr_pool_userdata_set(access_conf, cache_key,
+ NULL, r->connection->pool);
+ }
+ }
+ return access_conf;
+}
+
/* Check if the current request R is allowed. Upon exit *REPOS_PATH_REF
* will contain the path and repository name that an operation was requested
* on in the form 'name:path'. *DEST_REPOS_PATH_REF will contain the
@@ -121,8 +165,6 @@
svn_boolean_t authz_access_granted = FALSE;
svn_authz_t *access_conf = NULL;
svn_error_t *svn_err;
- const char *cache_key;
- void *user_data;
char errbuf[256];
switch (r->method_number) {
@@ -239,34 +281,12 @@
}
/* Retrieve/cache authorization file */
- cache_key = apr_pstrcat(r->pool, "mod_authz_svn:", conf->access_file, NULL);
- apr_pool_userdata_get(&user_data, cache_key, r->connection->pool);
- access_conf = user_data;
- if (access_conf == NULL) {
- svn_err = svn_repos_authz_read(&access_conf, conf->access_file,
- TRUE, r->connection->pool);
- if (svn_err) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR,
- /* If it is an error code that APR can make sense
- of, then show it, otherwise, pass zero to avoid
- putting "APR does not understand this error code"
- in the error log. */
- ((svn_err->apr_err >= APR_OS_START_USERERR &&
- svn_err->apr_err < APR_OS_START_CANONERR) ?
- 0 : svn_err->apr_err),
- r, "Failed to load the AuthzSVNAccessFile: %s",
- svn_err_best_message(svn_err,
- errbuf, sizeof(errbuf)));
- svn_error_clear(svn_err);
-
+ access_conf = get_access_conf(r,conf);
+ if(access_conf == NULL)
+ {
return DECLINED;
}
- /* Cache the open repos for the next request on this connection */
- apr_pool_userdata_set(access_conf, cache_key,
- NULL, r->connection->pool);
- }
-
/* Perform authz access control.
*
* First test the special case where repos_path == NULL, and skip
@@ -408,6 +428,70 @@
}
/*
+ * This function is used as a provider to allow mod_dav_svn to bypass the
+ * generation of an apache request when checking GET access from
+ * "mod_dav_svn/authz.c" .
+ */
+static int subreq_bypass(request_rec *r,
+ const char *repos_path,
+ const char *repos_name)
+{
+ svn_error_t *svn_err = NULL;
+ svn_authz_t *access_conf = NULL;
+ authz_svn_config_rec *conf = NULL;
+ svn_boolean_t authz_access_granted = FALSE;
+ char errbuf[256];
+
+ conf = ap_get_module_config(r->per_dir_config,
+ &authz_svn_module);
+
+ /* If configured properly, this should never be true, but just in case. */
+ if (!conf->anonymous || !conf->access_file) {
+ log_access_verdict(APLOG_MARK, r, 0, repos_path, NULL);
+ return HTTP_FORBIDDEN;
+ }
+
+ /* Retrieve authorization file */
+ access_conf = get_access_conf(r,conf);
+ if(access_conf == NULL)
+ return HTTP_FORBIDDEN;
+
+ /* Perform authz access control.
+ * See similarly labeled comment in req_check_access.
+ */
+ if (repos_path) {
+ svn_err = svn_repos_authz_check_access(access_conf, repos_name,
+ repos_path, r->user,
+ svn_authz_none|svn_authz_read,
+ &authz_access_granted,
+ r->pool);
+ if (svn_err) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR,
+ /* If it is an error code that APR can make
+ sense of, then show it, otherwise, pass
+ zero to avoid putting "APR does not
+ understand this error code" in the error
+ log. */
+ ((svn_err->apr_err >= APR_OS_START_USERERR &&
+ svn_err->apr_err < APR_OS_START_CANONERR) ?
+ 0 : svn_err->apr_err),
+ r, "Failed to perform access control: %s",
+ svn_err_best_message(svn_err, errbuf, sizeof(errbuf)));
+ svn_error_clear(svn_err);
+ return HTTP_FORBIDDEN;
+ }
+ if (!authz_access_granted) {
+ log_access_verdict(APLOG_MARK, r, 0, repos_path, NULL);
+ return HTTP_FORBIDDEN;
+ }
+ }
+
+ log_access_verdict(APLOG_MARK, r, 1, repos_path, NULL);
+
+ return OK;
+}
+
+/*
* Hooks
*/
@@ -552,6 +636,11 @@
#if AP_MODULE_MAGIC_AT_LEAST(20060110,0)
ap_hook_optional_fn_retrieve(import_ap_satisfies, NULL, NULL, APR_HOOK_MIDDLE);
#endif
+ ap_register_provider(p,
+ AUTHZ_SVN__SUBREQ_BYPASS_PROV_GRP,
+ AUTHZ_SVN__SUBREQ_BYPASS_PROV_NAME,
+ AUTHZ_SVN__SUBREQ_BYPASS_PROV_VER,
+ (void*)subreq_bypass);
}
module AP_MODULE_DECLARE_DATA authz_svn_module =
Index: subversion/mod_dav_svn/mod_dav_svn.c
===================================================================
--- subversion/mod_dav_svn/mod_dav_svn.c (revision 24955)
+++ subversion/mod_dav_svn/mod_dav_svn.c (working copy)
@@ -33,12 +33,16 @@
#include "mod_dav_svn.h"
#include "dav_svn.h"
+#include "mod_authz_svn.h"
/* This is the default "special uri" used for SVN's special resources
(e.g. working resources, activities) */
#define SVN_DEFAULT_SPECIAL_URI "!svn"
+/* This is the value to be given to SVNPathAuthz to bypass the apache
+ * subreq mechanism and make a call directly to mod_authz_svn. */
+#define PATHAUTHZ_BYPASS_ARG "short_circuit"
/* per-server configuration */
typedef struct {
@@ -55,6 +59,13 @@
CONF_FLAG_OFF
};
+/* An enum used for the per directory configuration path_authz_method. */
+enum path_authz_conf {
+ CONF_PATHAUTHZ_DEFAULT,
+ CONF_PATHAUTHZ_ON,
+ CONF_PATHAUTHZ_OFF,
+ CONF_PATHAUTHZ_BYPASS
+};
/* per-dir configuration */
typedef struct {
@@ -63,7 +74,7 @@
const char *xslt_uri; /* XSL transform URI */
const char *fs_parent_path; /* path to parent of SVN FS'es */
enum conf_flag autoversioning; /* whether autoversioning is active */
- enum conf_flag do_path_authz; /* whether GET subrequests are active */
+ enum path_authz_conf path_authz_method; /* how GET subrequests are handled */
enum conf_flag list_parentpath; /* whether to allow GET of parentpath */
const char *root_dir; /* our top-level directory */
const char *master_uri; /* URI to the master SVN repos */
@@ -77,6 +88,8 @@
extern module AP_MODULE_DECLARE_DATA dav_svn_module;
+/* The authz_svn provider for bypassing path authz. */
+static authz_svn__subreq_bypass_func_t pathauthz_bypass_func = NULL;
static int
init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
@@ -162,7 +175,7 @@
newconf->xslt_uri = INHERIT_VALUE(parent, child, xslt_uri);
newconf->fs_parent_path = INHERIT_VALUE(parent, child, fs_parent_path);
newconf->autoversioning = INHERIT_VALUE(parent, child, autoversioning);
- newconf->do_path_authz = INHERIT_VALUE(parent, child, do_path_authz);
+ newconf->path_authz_method = INHERIT_VALUE(parent, child, path_authz_method);
newconf->list_parentpath = INHERIT_VALUE(parent, child, list_parentpath);
/* Prefer our parent's value over our new one - hence the swap. */
newconf->root_dir = INHERIT_VALUE(child, parent, root_dir);
@@ -230,14 +243,23 @@
static const char *
-SVNPathAuthz_cmd(cmd_parms *cmd, void *config, int arg)
+SVNPathAuthz_cmd(cmd_parms *cmd, void *config, const char *arg1)
{
dir_conf_t *conf = config;
- if (arg)
- conf->do_path_authz = CONF_FLAG_ON;
+ if (apr_strnatcasecmp("off", arg1) == 0)
+ conf->path_authz_method = CONF_PATHAUTHZ_OFF;
+ else if (apr_strnatcasecmp(PATHAUTHZ_BYPASS_ARG,arg1) == 0)
+ {
+ conf->path_authz_method = CONF_PATHAUTHZ_BYPASS;
+ if (pathauthz_bypass_func == NULL)
+ pathauthz_bypass_func=ap_lookup_provider(
+ AUTHZ_SVN__SUBREQ_BYPASS_PROV_GRP,
+ AUTHZ_SVN__SUBREQ_BYPASS_PROV_NAME,
+ AUTHZ_SVN__SUBREQ_BYPASS_PROV_VER);
+ }
else
- conf->do_path_authz = CONF_FLAG_OFF;
+ conf->path_authz_method = CONF_PATHAUTHZ_ON;
return NULL;
}
@@ -447,16 +469,33 @@
}
+/* FALSE if path authorization should be skipped.
+ * TRUE if either the bypass or the apache subrequest methods should be used.
+ */
svn_boolean_t
dav_svn__get_pathauthz_flag(request_rec *r)
{
dir_conf_t *conf;
conf = ap_get_module_config(r->per_dir_config, &dav_svn_module);
- return conf->do_path_authz != CONF_FLAG_OFF;
+ return conf->path_authz_method != CONF_PATHAUTHZ_OFF;
}
+/* Function pointer if we should use the bypass directly to mod_authz_svn.
+ * NULL otherwise. */
+authz_svn__subreq_bypass_func_t
+dav_svn__get_pathauthz_bypass(request_rec *r)
+{
+ dir_conf_t *conf;
+ conf = ap_get_module_config(r->per_dir_config, &dav_svn_module);
+
+ if(conf->path_authz_method==CONF_PATHAUTHZ_BYPASS)
+ return pathauthz_bypass_func;
+ return NULL;
+}
+
+
svn_boolean_t
dav_svn__get_list_parentpath_flag(request_rec *r)
{
@@ -630,9 +669,11 @@
ACCESS_CONF|RSRC_CONF, "turn on deltaV autoversioning."),
/* per directory/location */
- AP_INIT_FLAG("SVNPathAuthz", SVNPathAuthz_cmd, NULL,
+ AP_INIT_TAKE1("SVNPathAuthz", SVNPathAuthz_cmd, NULL,
ACCESS_CONF|RSRC_CONF,
- "control path-based authz by enabling/disabling subrequests"),
+ "control path-based authz by enabling subrequests(On,default), "
+ "disabling subrequests(Off), or"
+ "querying mod_authz_svn directly(" PATHAUTHZ_BYPASS_ARG ")"),
/* per directory/location */
AP_INIT_FLAG("SVNListParentPath", SVNListParentPath_cmd, NULL,
Index: subversion/mod_dav_svn/dav_svn.h
===================================================================
--- subversion/mod_dav_svn/dav_svn.h (revision 24955)
+++ subversion/mod_dav_svn/dav_svn.h (working copy)
@@ -31,6 +31,7 @@
#include "svn_repos.h"
#include "svn_path.h"
#include "svn_xml.h"
+#include "mod_authz_svn.h"
#ifdef __cplusplus
extern "C" {
@@ -255,6 +256,11 @@
/* for the repository referred to by this request, are subrequests active? */
svn_boolean_t dav_svn__get_pathauthz_flag(request_rec *r);
+/* for the repository referred to by this request, are subrequests bypassed?
+ * A function pointer if yes, NULL if not.
+ */
+authz_svn__subreq_bypass_func_t dav_svn__get_pathauthz_bypass(request_rec *r);
+
/* for the repository referred to by this request, is a GET of
SVNParentPath allowed? */
svn_boolean_t dav_svn__get_list_parentpath_flag(request_rec *r);
Index: subversion/mod_dav_svn/authz.c
===================================================================
--- subversion/mod_dav_svn/authz.c (revision 24955)
+++ subversion/mod_dav_svn/authz.c (working copy)
@@ -22,6 +22,7 @@
#include "svn_pools.h"
#include "svn_path.h"
+#include "mod_authz_svn.h"
#include "dav_svn.h"
@@ -41,6 +42,7 @@
request_rec *subreq;
enum dav_svn__build_what uri_type;
svn_boolean_t allowed = FALSE;
+ authz_svn__subreq_bypass_func_t allow_read_bypass = NULL;
/* Easy out: if the admin has explicitly set 'SVNPathAuthz Off',
then this whole callback does nothing. */
@@ -49,6 +51,20 @@
return TRUE;
}
+ /* If bypass is specified and authz has exported the provider.
+ Otherwise, we fall through to the full version. This should be
+ safer than allowing or disallowing all accesses if there is a
+ configuration error.
+ XXX: Is this the proper thing to do in this case? */
+ allow_read_bypass = dav_svn__get_pathauthz_bypass(r);
+ if (allow_read_bypass != NULL)
+ {
+ if (allow_read_bypass(r,path, repos->repo_name) == OK)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
/* If no revnum is specified, assume HEAD. */
if (SVN_IS_VALID_REVNUM(rev))
uri_type = DAV_SVN__BUILD_URI_VERSION;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Eric Gillespie <ep...@pretzelnet.org>.
"David James" <ja...@cs.toronto.edu> writes:
> On 4/16/07, Josh Gilkerson <jw...@google.com> wrote:
> > Latest patch. I am fairly certain that this is functioning properly.
> >
> > For configuration, I have overloaded the SVNPathAuthz. The values on
> > and off and the default value(on) have retained their meaning, so
> > configurations shouldn't be broken (Are there other apache will parse
> > as on or off for a boolean option?). There is then another value,
> > currently 'dangerous_direct', that indicates that mod_dav_svn should
> > authorize directly to mod_authz_svn.
>
> How about "short_circuit"? I think that this is a good name.
I like that, too. Josh, can you make that change? Or i could
make it and then commit.
> Please don't include the word "dangerous" in the option name as I find
> the use of that word here to be confusing.
>
> I haven't tested your patch yet, but, in general, your patch looks
> very good. This new approach is much better than the approach that
> Artem took on the artem-soc-work branch, because it requires so many
> fewer changes.
>
> I see a few spots where the formatting could be improved, but this is
> minor and can be fixed at commit time if everyone is otherwise happy
> with the patch.
I think we've waited long enough for people to object :). I'm
going to commit this change today or tomorrow. I'll fix what
formatting issues i find, but i'm not the biggest expert on
Subversion style either ;->.
> On 4/16/07, Justin Erenkrantz <ju...@erenkrantz.com> wrote:
> > > You also pointed out that "mod_authz_svn doesn't handle host-based
> > > authorization at all." Are you implying that the new short circuit
> > > authz option might break Apache's host-based authorization? If so,
> > > how?
> >
> > Yes. Because you're only going to be using mod_authz_svn instead of
> > permitting httpd to run through its normal authorization mechanisms -
> > which include *all* authorization modules.
>
> Isn't this fearmongering? Apache still runs through all of its normal
> authorization mechanisms for the initial request -- the only
> difference with "short circuit" authorization is that we don't
> fabricate artificial subrequests to account for all of the internal
> subversion repository paths which are referenced in a given report.
>
> I do get your point, though, and I agree that "short circuit" is a
> better name than "native", so I won't argue this point further.
>
> Cheers,
>
> David
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>
--
Eric Gillespie <*> epg@pretzelnet.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by David James <ja...@cs.toronto.edu>.
On 4/16/07, Josh Gilkerson <jw...@google.com> wrote:
> Latest patch. I am fairly certain that this is functioning properly.
>
> For configuration, I have overloaded the SVNPathAuthz. The values on
> and off and the default value(on) have retained their meaning, so
> configurations shouldn't be broken (Are there other apache will parse
> as on or off for a boolean option?). There is then another value,
> currently 'dangerous_direct', that indicates that mod_dav_svn should
> authorize directly to mod_authz_svn.
How about "short_circuit"? I think that this is a good name.
Please don't include the word "dangerous" in the option name as I find
the use of that word here to be confusing.
I haven't tested your patch yet, but, in general, your patch looks
very good. This new approach is much better than the approach that
Artem took on the artem-soc-work branch, because it requires so many
fewer changes.
I see a few spots where the formatting could be improved, but this is
minor and can be fixed at commit time if everyone is otherwise happy
with the patch.
On 4/16/07, Justin Erenkrantz <ju...@erenkrantz.com> wrote:
> > You also pointed out that "mod_authz_svn doesn't handle host-based
> > authorization at all." Are you implying that the new short circuit
> > authz option might break Apache's host-based authorization? If so,
> > how?
>
> Yes. Because you're only going to be using mod_authz_svn instead of
> permitting httpd to run through its normal authorization mechanisms -
> which include *all* authorization modules.
Isn't this fearmongering? Apache still runs through all of its normal
authorization mechanisms for the initial request -- the only
difference with "short circuit" authorization is that we don't
fabricate artificial subrequests to account for all of the internal
subversion repository paths which are referenced in a given report.
I do get your point, though, and I agree that "short circuit" is a
better name than "native", so I won't argue this point further.
Cheers,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 4/16/07, David James <ja...@cs.toronto.edu> wrote:
> Okay, let's see if I understand now: You're saying that it's dangerous
> for us to change the way that Subversion processes special URIs
> because there are users who depend on their behaviour in LocationMatch
> directives.
Yes - or other mechanisms.
> To demonstrate your point, could you give a working and secure example
> of such a LocationMatch directive? Your existing LocationMatch rule
> doesn't work because it doesn't block baseline-collection URIs.
>
> You could, as you say, add mod_authz_svn into the mix, and teach
> mod_authz_svn to block the baseline collection URIs, but, if you do
> that, you will have to teach mod_authz_svn to block all the same URLs
> that your LocationMatch is blocking. In that case, the LocationMatch
> directive is redundant and serves no purpose.
Sure it does. Why do you think it doesn't? It uses a wild
card...just expand the regex as needed. It's trivial.
> You also pointed out that "mod_authz_svn doesn't handle host-based
> authorization at all." Are you implying that the new short circuit
> authz option might break Apache's host-based authorization? If so,
> how?
Yes. Because you're only going to be using mod_authz_svn instead of
permitting httpd to run through its normal authorization mechanisms -
which include *all* authorization modules.
> I do agree with you that there are some users who might be affected by
> the special URI change. CollabNet, for example, wrote a custom authz
> module, which will need to be updated if they want to support
> short-circuit authentication.
Again, no, this is all about what you can do with a stock httpd
configuration and install.
> Does this fact itself make the authz change dangerous? I don't think
> so -- I think that any users who wrote custom authz modules will
> understand that, if they switch Subversion to use short-circuit
> authentication, that they will also need to update their custom authz
> module to also support this feature.
Yes, I think it does make it dangerous.
My point is that if you give an option like 'native', folks will think
it's doing something of little consequence - users should understand
what it is when they enable this feature so that if they might be
doing it. Making the assumption that *no one* is using LocationMatch
or other default authorization mechanims is rife with trouble. If I
can do it with a stock httpd install and have that configuration break
silently with this short circuit, then we need to put major blinking
lights around the enabling of it. I think you are greatly
underestimating the creativity of httpd admins. I never cease to be
amazed at what httpd admins can come up with. =) -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by David James <ja...@cs.toronto.edu>.
On 4/3/07, Justin Erenkrantz <ju...@erenkrantz.com> wrote:
> > Some users have tried to setup LocationMatch directives, but they know
> > well that is not 100% secure and that the details about Subversion's
> > special URIs may change in the future. See the following post, for
> > example, in which the user setup an insecure LocationMatch directive
> > instead of setting up mod_authz_svn:
> > http://svn.haxx.se/users/archive-2007-04/0035.shtml .
> >
> > Given this, do you still think it is "dangerous" for Subversion to
> > authorize requests on a per-request basis, instead of on a
> > pathrev-pair basis?
>
> Yes, it is dangerous.
>
> Once again (because I think you're missing my point entirely), I'm not
> against such dangerous optimizations as it can help folks - but I *am*
> strongly advocating that we not name this feature so it sounds like an
> innocent feature that an admin can tweak without understanding what it
> is really doing.
Okay, let's see if I understand now: You're saying that it's dangerous
for us to change the way that Subversion processes special URIs
because there are users who depend on their behaviour in LocationMatch
directives.
To demonstrate your point, could you give a working and secure example
of such a LocationMatch directive? Your existing LocationMatch rule
doesn't work because it doesn't block baseline-collection URIs.
You could, as you say, add mod_authz_svn into the mix, and teach
mod_authz_svn to block the baseline collection URIs, but, if you do
that, you will have to teach mod_authz_svn to block all the same URLs
that your LocationMatch is blocking. In that case, the LocationMatch
directive is redundant and serves no purpose.
You also pointed out that "mod_authz_svn doesn't handle host-based
authorization at all." Are you implying that the new short circuit
authz option might break Apache's host-based authorization? If so,
how?
I do agree with you that there are some users who might be affected by
the special URI change. CollabNet, for example, wrote a custom authz
module, which will need to be updated if they want to support
short-circuit authentication.
Does this fact itself make the authz change dangerous? I don't think
so -- I think that any users who wrote custom authz modules will
understand that, if they switch Subversion to use short-circuit
authentication, that they will also need to update their custom authz
module to also support this feature.
Cheers,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 4/3/07, David James <ja...@cs.toronto.edu> wrote:
> Is that configuration really secure? It doesn't look like you handle
> all the details. What about baseline URIs, or baseline collection
> URIs, or even public URIs?
mod_authz_svn doesn't handle host-based authorization at all. I'm
just pointing out one facet of the authorization scheme that can't be
handled by us - and can be broken by a native authz scheme in that
httpd handles it far better than Subversion would.
> I believe that Subversion currently assumes that, if apache says "yes"
> to a URI, then it is safe for the user to access said URI. For
> example, if a user asks for
> http://svn.collab.net/repos/svn/!svn/bc/1100/trunk/IDEAS, and Apache
> says yes, then Subversion assumes that it is OK to send that file to
> the user. So you need to handle all of the cases in your LocationMatch
> directives.
You can combine mod_authz_svn with the LocationMatch.
> Currently, the Subversion "special uris" have been described as an
> "undocumented implementation detail and is liable to change at any
> time". See http://svn.haxx.se/dev/archive-2004-10/0510.shtml .
Frankly, that's a cheap cop-out. We haven't changed it and we're
likely not to change it in the forseeable future.
> Some users have tried to setup LocationMatch directives, but they know
> well that is not 100% secure and that the details about Subversion's
> special URIs may change in the future. See the following post, for
> example, in which the user setup an insecure LocationMatch directive
> instead of setting up mod_authz_svn:
> http://svn.haxx.se/users/archive-2007-04/0035.shtml .
>
> Given this, do you still think it is "dangerous" for Subversion to
> authorize requests on a per-request basis, instead of on a
> pathrev-pair basis?
Yes, it is dangerous.
Once again (because I think you're missing my point entirely), I'm not
against such dangerous optimizations as it can help folks - but I *am*
strongly advocating that we not name this feature so it sounds like an
innocent feature that an admin can tweak without understanding what it
is really doing.
"native" doesn't sound like something that is dangerous - IMO, "short
circuit" does. Call it "dangerous" or
"i-have-read-the-documentation-about-native-auth" or something - but
just don't make it sound like this is a good idea to enable blindly if
something's not working right. -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by David James <ja...@cs.toronto.edu>.
On 4/3/07, Justin Erenkrantz <ju...@erenkrantz.com> wrote:
> On 4/3/07, David James <ja...@cs.toronto.edu> wrote:
> > Hi Justin,
> >
> > As far as I am aware, the SVNAuthzShortCircuit flag isn't naughty at
> > all. Correct me if I am wrong, but I believe that Apache always checks
> > every request that every user makes against its authz system
> > regardless of how Subversion implements its authorization internally.
> > If a user-written authorization module wants to block a Subversion
> > request, it should block the initial Subversion request from user,
> > rather than depending on the implementation details of our internal
> > authorization system.
>
> My point is that we haven't been using our own internal authorization
> system - we have always allowed standard Apache modules and directives
> to control the authorization sequence.
>
> > Currently, Subversion splits up each REPORT request into a potentially
> > unbounded number of internal "GET" subrequests in order to facilitate
> > its authorization checks. If you issue one request to access a log
> > message for a single revision, Subversion would send an unbounded
> > number of GET subrequests to mod_authz_svn to check whether each and
> > every path referenced by that revision is accessible. For example, if
> > a particular revision affects a million files, then Subversion will
> > send a million subrequests to mod_authz_svn. These unnecessary
> > subrequests are and should remain an internal implementation detail of
> > mod_dav_svn and mod_authz_svn. Any users who went through the trouble
> > to write a authz module which parses private Subversion URLs and takes
> > advantage of internal Subversion implementation details will likely be
> > well aware of the impact of the SVNAuthzShortCircuit flag, regardless
> > of whether it is named "native authorization" or "short circuit
> > authorization".
> >
> > Could you explain, in a bit more detail, a scenario in which a user
> > with a secure installation might become confused, and expose a
> > security hole by enabling this flag?
>
> With the current setup, I can set up authorization blocks on
> lower-level directories with httpd alone, like so:
>
> <Location /repos/svn>
> ...blah blah...
> </Location>
>
> <LocationMatch "/repos/svn/(!svn/ver/[0-9]*)/A/B*">
> Allow from 127.0.0.1 ::1
> Deny from all
> </LocationMatch>
>
> With the current code (as svn defers wholly to httpd), this will work
> and will block access if I try to access the paths /A/B when I'm not
> coming from localhost. This is a quite simplistic example, but I can
> expand on the syntax and type of directives greatly if I desired.
> Now, if I add in the short-circuit to the /repos/svn configuration,
> this config will silently break and the admin won't know why. This is
> why I want the directive name to not sound innocent!
Is that configuration really secure? It doesn't look like you handle
all the details. What about baseline URIs, or baseline collection
URIs, or even public URIs?
I believe that Subversion currently assumes that, if apache says "yes"
to a URI, then it is safe for the user to access said URI. For
example, if a user asks for
http://svn.collab.net/repos/svn/!svn/bc/1100/trunk/IDEAS, and Apache
says yes, then Subversion assumes that it is OK to send that file to
the user. So you need to handle all of the cases in your LocationMatch
directives.
Currently, the Subversion "special uris" have been described as an
"undocumented implementation detail and is liable to change at any
time". See http://svn.haxx.se/dev/archive-2004-10/0510.shtml .
Some users have tried to setup LocationMatch directives, but they know
well that is not 100% secure and that the details about Subversion's
special URIs may change in the future. See the following post, for
example, in which the user setup an insecure LocationMatch directive
instead of setting up mod_authz_svn:
http://svn.haxx.se/users/archive-2007-04/0035.shtml .
Given this, do you still think it is "dangerous" for Subversion to
authorize requests on a per-request basis, instead of on a
pathrev-pair basis?
Cheers,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 4/3/07, David James <ja...@cs.toronto.edu> wrote:
> Hi Justin,
>
> As far as I am aware, the SVNAuthzShortCircuit flag isn't naughty at
> all. Correct me if I am wrong, but I believe that Apache always checks
> every request that every user makes against its authz system
> regardless of how Subversion implements its authorization internally.
> If a user-written authorization module wants to block a Subversion
> request, it should block the initial Subversion request from user,
> rather than depending on the implementation details of our internal
> authorization system.
My point is that we haven't been using our own internal authorization
system - we have always allowed standard Apache modules and directives
to control the authorization sequence.
> Currently, Subversion splits up each REPORT request into a potentially
> unbounded number of internal "GET" subrequests in order to facilitate
> its authorization checks. If you issue one request to access a log
> message for a single revision, Subversion would send an unbounded
> number of GET subrequests to mod_authz_svn to check whether each and
> every path referenced by that revision is accessible. For example, if
> a particular revision affects a million files, then Subversion will
> send a million subrequests to mod_authz_svn. These unnecessary
> subrequests are and should remain an internal implementation detail of
> mod_dav_svn and mod_authz_svn. Any users who went through the trouble
> to write a authz module which parses private Subversion URLs and takes
> advantage of internal Subversion implementation details will likely be
> well aware of the impact of the SVNAuthzShortCircuit flag, regardless
> of whether it is named "native authorization" or "short circuit
> authorization".
>
> Could you explain, in a bit more detail, a scenario in which a user
> with a secure installation might become confused, and expose a
> security hole by enabling this flag?
With the current setup, I can set up authorization blocks on
lower-level directories with httpd alone, like so:
<Location /repos/svn>
...blah blah...
</Location>
<LocationMatch "/repos/svn/(!svn/ver/[0-9]*)/A/B*">
Allow from 127.0.0.1 ::1
Deny from all
</LocationMatch>
With the current code (as svn defers wholly to httpd), this will work
and will block access if I try to access the paths /A/B when I'm not
coming from localhost. This is a quite simplistic example, but I can
expand on the syntax and type of directives greatly if I desired.
Now, if I add in the short-circuit to the /repos/svn configuration,
this config will silently break and the admin won't know why. This is
why I want the directive name to not sound innocent!
HTH. -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by David James <ja...@cs.toronto.edu>.
On 4/3/07, Justin Erenkrantz <ju...@erenkrantz.com> wrote:
> > I remember that in the past we've discussed extending SVNPathAuthz to
> > accept <apache|native|off> (plus 'on' as an alias for 'apache').
>
> I think 'native' doesn't convey the badness that we're doing with this
> approach. It sounds all nice and cool to have it be 'native' - I
> think having the directive name be 'ShortCircuit' or something conveys
> that we're doing something very very naughty. IOW, the admin should
> realize that doing this has *major* implications on their authz
> scheme. Configs may suddenly break if they switch it on and expose
> their repositories in ways they didn't expect (i.e. what could have
> been blocked before is no longer blocked!).
Hi Justin,
As far as I am aware, the SVNAuthzShortCircuit flag isn't naughty at
all. Correct me if I am wrong, but I believe that Apache always checks
every request that every user makes against its authz system
regardless of how Subversion implements its authorization internally.
If a user-written authorization module wants to block a Subversion
request, it should block the initial Subversion request from user,
rather than depending on the implementation details of our internal
authorization system.
Currently, Subversion splits up each REPORT request into a potentially
unbounded number of internal "GET" subrequests in order to facilitate
its authorization checks. If you issue one request to access a log
message for a single revision, Subversion would send an unbounded
number of GET subrequests to mod_authz_svn to check whether each and
every path referenced by that revision is accessible. For example, if
a particular revision affects a million files, then Subversion will
send a million subrequests to mod_authz_svn. These unnecessary
subrequests are and should remain an internal implementation detail of
mod_dav_svn and mod_authz_svn. Any users who went through the trouble
to write a authz module which parses private Subversion URLs and takes
advantage of internal Subversion implementation details will likely be
well aware of the impact of the SVNAuthzShortCircuit flag, regardless
of whether it is named "native authorization" or "short circuit
authorization".
Could you explain, in a bit more detail, a scenario in which a user
with a secure installation might become confused, and expose a
security hole by enabling this flag?
Cheers,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 4/3/07, Malcolm Rowe <ma...@farside.org.uk> wrote:
> On Mon, Apr 02, 2007 at 04:03:37PM -0700, Josh Gilkerson wrote:
> > Are there suggestions for the directive name/syntax? Suggestions:
> > SVNAuthorizationShortCircuit [yes|no]
> > SVNDavAuthzDirect <provider_name>
>
> (Why would we need more than one provider?)
Probably don't.
> I remember that in the past we've discussed extending SVNPathAuthz to
> accept <apache|native|off> (plus 'on' as an alias for 'apache').
I think 'native' doesn't convey the badness that we're doing with this
approach. It sounds all nice and cool to have it be 'native' - I
think having the directive name be 'ShortCircuit' or something conveys
that we're doing something very very naughty. IOW, the admin should
realize that doing this has *major* implications on their authz
scheme. Configs may suddenly break if they switch it on and expose
their repositories in ways they didn't expect (i.e. what could have
been blocked before is no longer blocked!).
> (We even discussed making it mandatory (no default) because of the
> performance impact of the default behaviour. That would ensure that
> people knew what they were getting, and could switch it off if, as is
> most likely, it wasn't needed. That's probably going too far, though).
Yes, IMO, it goes too far as it'd break configs. -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Malcolm Rowe <ma...@farside.org.uk>.
On Mon, Apr 02, 2007 at 04:03:37PM -0700, Josh Gilkerson wrote:
> Are there suggestions for the directive name/syntax? Suggestions:
> SVNAuthorizationShortCircuit [yes|no]
> SVNDavAuthzDirect <provider_name>
(Why would we need more than one provider?)
I remember that in the past we've discussed extending SVNPathAuthz to
accept <apache|native|off> (plus 'on' as an alias for 'apache').
(We even discussed making it mandatory (no default) because of the
performance impact of the default behaviour. That would ensure that
people knew what they were getting, and could switch it off if, as is
most likely, it wasn't needed. That's probably going too far, though).
Regards,
Malcolm
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Josh Gilkerson <jw...@google.com>.
The main issues I have with the existing work are along the same lines
as Justin.
Most importantly, there seems to be a lot of duplication of code
between the dav and auth modules using the artem-soc-work method.
Less important practically, but still important is that including the
auth logic in the dav module breaks the separation of roles between
the two modules. Introducing an direct call to the auth module does
the same because it means that the dav module has some bit of
information about the auth handling, but to a lesser extent than if it
does major parts of the handling itself.
If anyone has objections to this area of exploration, please speak up.
I'm not proposing anyone else write the code, just hoping to get a
solution that is acceptable to everyone.
My plan for implementation is to:
- introduce a new configuration setting that determines whether the
optimization is used or not
- introduce a provider in mod_auth_svn that will export the function
or functions to be accessed from mod_dav_svn
I would like comments from anyone interested on any points that need
to be made and any pitfalls they see.
Are there suggestions for the directive name/syntax? Suggestions:
SVNAuthorizationShortCircuit [yes|no]
SVNDavAuthzDirect <provider_name>
Are there suggestions/requirements for the group and name of the
provider that mod_auth_svn will register. I am fairly new to apache
hacking and I don't want to violate any requirements in this regard.
I have been thinking of choosing a group name and then taking the
provider name from the configuration directive.
Josh
On 3/28/07, Justin Erenkrantz <ju...@erenkrantz.com> wrote:
> On 3/27/07, Max Bowsher <ma...@ukf.net> wrote:
> > out, exactly. At some point we're going to need to resolve the
> > philosophical differences in approach between Justin and I.
>
> I believe I've detailed quite clearly already why the approach taken
> in that branch is flawed. I really do hope that the approach I
> outlined would satisfy your requirements for a 'faster' authz - while
> not requiring a lot of inappropriately duplicated code. -- justin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>
>
--
Josh Gilkerson
Software Engineer
Google, Inc · MV-1600 Plymouth (HQ)
+1 (650) 253-1667 direct
+1 (859) 608-7827 cell
jwg@google.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 3/27/07, Max Bowsher <ma...@ukf.net> wrote:
> out, exactly. At some point we're going to need to resolve the
> philosophical differences in approach between Justin and I.
I believe I've detailed quite clearly already why the approach taken
in that branch is flawed. I really do hope that the approach I
outlined would satisfy your requirements for a 'faster' authz - while
not requiring a lot of inappropriately duplicated code. -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Daniel Rall <dl...@collab.net>.
On Tue, 27 Mar 2007, Max Bowsher wrote:
> Josh Gilkerson wrote:
> > This message is in response to one posted by Justin Erenkrantz on
> > 2007-03-14 06:35:14 CET with the subject Re: svn commit: r23806 -
> > branches/artem-soc-work/subversion/mod_dav_svn
> >
> > Is anyone planning on pursuing the route described in the message? In
> > short the idea is to allow a site administrator to reduce mod_dav_svn
> > overhead by bypassing the generation of an http subreqeust to check
> > permissions when using mod_auth_svn.
> >
> > I am planning to implement this feature and would like to avoid
> > duplication of effort if someone else is already working on it.
>
> I have it on my list of things to do to see the artem-soc-work branch
> merged to trunk, in one form or another. Not sure how things will turn
> out, exactly. At some point we're going to need to resolve the
> philosophical differences in approach between Justin and I.
>
> I've sort of promised myself to do my best to *try* and get this result
> of last year's GSoC merged before the end of *this* year's GSoC. I'm not
> going to promise any more than an attempt, though, because I'm still
> adjusting to being in a full-time job for the first time, and I don't
> yet know whether I'll be mentoring this year.
Josh, sounds like the best way to go about this is to discuss the
design and points of contention for the existing branch here on the
mailing list. Driving those discussions along would be a big help.
Re: "SVNAuthorizationShortCircuit or something similar"
Posted by Max Bowsher <ma...@ukf.net>.
Josh Gilkerson wrote:
> This message is in response to one posted by Justin Erenkrantz on
> 2007-03-14 06:35:14 CET with the subject Re: svn commit: r23806 -
> branches/artem-soc-work/subversion/mod_dav_svn
>
> Is anyone planning on pursuing the route described in the message? In
> short the idea is to allow a site administrator to reduce mod_dav_svn
> overhead by bypassing the generation of an http subreqeust to check
> permissions when using mod_auth_svn.
>
> I am planning to implement this feature and would like to avoid
> duplication of effort if someone else is already working on it.
I have it on my list of things to do to see the artem-soc-work branch
merged to trunk, in one form or another. Not sure how things will turn
out, exactly. At some point we're going to need to resolve the
philosophical differences in approach between Justin and I.
I've sort of promised myself to do my best to *try* and get this result
of last year's GSoC merged before the end of *this* year's GSoC. I'm not
going to promise any more than an attempt, though, because I'm still
adjusting to being in a full-time job for the first time, and I don't
yet know whether I'll be mentoring this year.
Max.