If you want to apply this or any other extractor to every request, one option is to compose pattern matching expressions. This is pretty common on a small scale in unfiltered but it could also be done effectively in a bigger way. Here's some code I won't try to compile but that should be basically right:

Or you could compose in many other ways. It might be interesting to have an object that extends unfiltered.filter.Plan.Intent directly and does the processing in apply(), but I can't say offhand if that would even work.

The other way to handle this is as the servlet filter api would traditionally have you do it. Create one filter just for authorization, return Pass on successful authorization and NotAuthorized on any failure. Add another filter to the chain after that which would be similar to AuthorizedApp above, except that it would be an actual Filter by extending unfiltered.filter.Plan.

Re: apply BasicAuth to all matchers

I've generally followed the second approach in a few apps I've worked on. I usually have a class that I use just for Auth and take advantage of the filter chain so I can reuse the same code in other apps. I just put this auth plan before other plans in the filter chain. I think this is generally a good practice because it helps keep concerns separated and allows you to more easily swap out implementations of how you choose to handle authentication in one place.

Re: apply BasicAuth to all matchers

Also keep in mind most of unfiltered response handlers can be combined with ~>.

I probably should have also mentioned n cases where you are handling basic auth you wanted to combine Unauthorized with the WWW-Authenticate header. You can do this with unfiltered by returning something like

Unauthorized ~> WWWAuthenticate("Basic realm=\"/\"")

So thing I might suggest augmenting my example above with something like

Re: apply BasicAuth to all matchers

I use unfiltered for a few internal tools at work using the unfiltered Http server abstraction but I am using what unfiltered.jetty does internally in java projects that are in production. Internally unfiltered.jetty.Http is just setting up a connector to listen on a port and a builds up a set of servlet context handlers.

I'll try to write up an example app and post to github with an example of how you can use basic auth tonight and post back here