Author |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Wed 17 Aug '11 9:35 Post subject: Variable in directives? |
|
|
I would like to have a "Require group" depending on the URL.
The content is handled by a cgi-script so I cannot use .htaccess files...
domain.tld/dirname -> Require group dirname
domain.tld/dirname/subdir(s) -> Require group dirname
domain.tld/seconddir -> Require group seconddir
domain.tld/seconddir/subdir(s) -> Require group seconddir
...
Is that possible?
Can I get I variable from a "LocationMatch"? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Wed 17 Aug '11 10:23 Post subject: |
|
|
I think you can work with Directory. Than all subdirs will have that too. Like with the .htaccess
<Directory "/Apache22/htdocs/dirname">
</Directory> |
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Wed 17 Aug '11 10:46 Post subject: |
|
|
Well, currently I have this in my config:
Code: | <Location "/">
AuthType Basic
...
Deny from all
</Location>
<Location "/dirname">
Allow from all
Require group dirname
</Location>
<Location "/seconddir">
Allow from all
Require group seconddir
</Location> |
But I'd prefer not to have a Location Block for every dir... |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Wed 17 Aug '11 10:53 Post subject: |
|
|
If you can't do it differently, but are lazy than you should take a look at mod_macro. It makes it realy easy so set uo such a thing and keeping the overview. |
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Wed 17 Aug '11 14:43 Post subject: |
|
|
Thanks, but isn't there a way to do this automatically for each existing dir? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Thu 18 Aug '11 9:25 Post subject: |
|
|
OK, I did RTFM and it might be possible with the env REQUEST_URI and SetEnvIf.
Don't ask me for a regex doing this. I'm not good into that |
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Thu 18 Aug '11 10:06 Post subject: |
|
|
This looks promising!
I'll test it later today... |
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Thu 18 Aug '11 14:53 Post subject: |
|
|
The Require directive does not understand the env= param... |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Thu 18 Aug '11 15:52 Post subject: |
|
|
From the docs it shoud... argh! I found that on the new 2.3 aka 2.4 apache...
See http://httpd.apache.org/docs/2.3/mod/mod_authz_core.html#requiredirectives
Maybe this could work (haven't tested). Ok there is the regex missing
Code: |
Order Deny,Allow
Satisfy any
SetEnvIf REQUEST_URI "/api/" allow_all
Deny from all
Require valid-user
Allow from env=allow_all
|
|
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Thu 18 Aug '11 22:21 Post subject: |
|
|
I also found the manualpage, but "Require Env" checks only if the var is defined and I am using Apache 2.2
The Regex would be "^/(.+)/?", but parsing would result in "Allow from dirname"...
I need to check the group - Only members of the group "dirname" are allowed to access domain.tld/dirname |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
|
Back to top |
|
Virsacer
Joined: 16 Jan 2010 Posts: 108 Location: Germany, Darmstadt
|
Posted: Fri 19 Aug '11 10:30 Post subject: |
|
|
I'll probably have to stick with the config from my second post.
If the number of directories grows I'll use a script to generate the config...
Thanks for trying to help! |
|
Back to top |
|