views:

222

answers:

1

Hi,

Is there a convenient way to password-protect URLs which match a certain pattern in Lighttpd?

I thought about matching regex, but any other creative solution will be nice.

NOTE : I'm not looking for a way to password-protect a directory, beacuse the URLs I want to protect aren't confined to a certain directory structure.

Adam

+2  A: 

Have you looked at the mod_auth plugin?

auth.debug = 0
auth.backend = "plain"
auth.backend.plain.userfile = "/full/path/to/auth-file.txt"
auth.require = ("example.com" =>
(
"method" => "basic",
"realm" => "Password protected area",
"require" => "user=username"
)

And the auth-file would contain (for basic authentication):

username:password

More info: http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModAuth

To filter / check a specific directory,

$HTTP["url"] =~ "^/download(s)?$" {
    auth.require = ( "" =>
        (
            "method"  => "basic",
            "realm"   => "Passworded Area",
            "require" => "user=username" 
        )
    )
}
davethegr8
That's cool, but where's the regex part?
Adam Matan
I added an example with a regex.
davethegr8
Thanks! This will get me going.
Adam Matan
great! glad it helped.
davethegr8