Project

General

Profile

[Solved] auth.require based on HTTP method (PUT and GET)?

Added by dahlke over 6 years ago

Hi :)

On an API we use auth.require to restrict asses to certain methods. In our Lighttpd.conf we have something along the lines of the below.

auth.require = (
"/sys/api/net" => (
"method" => "digest",
"realm" => "Admin",
"require" => "valid-user" ))

That works like a charm but... we now need support both PUT and GET at /sys/api/net, and only the PUT is allowed to require authentication.

How would I go about doing that? :)

Moving GET and PUT to separate URLs is not an option :)

Running lighttpd/1.4.45


Replies (2)

RE: auth.require based on HTTP method (PUT and GET)? - Added by dahlke over 6 years ago

Do'h

Found a solution :)

$HTTP["request-method"] =~ "^PUT$" {
auth.require = (
"/sys/api/netc" => (
"method" => "digest",
"realm" => "Admin",
"require" => "valid-user" ),
)
}

RE: [Solved] auth.require based on HTTP method (PUT and GET)? - Added by gstrauss over 6 years ago

@dahlke, you don't need a regex in the condition. This will do: $HTTP["request-method"] == "PUT"

    (1-2/2)