Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lighttpd: How to password-protect URLs matching regex

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

like image 894
Adam Matan Avatar asked Jan 31 '10 14:01

Adam Matan


1 Answers

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" 
        )
    )
}
like image 193
davethegr8 Avatar answered Sep 28 '22 07:09

davethegr8