Clojure - Luminus - Enabling basic auth for specific routes
Aug 15, 2015
The ring-basic-authentication library makes it easy to add http auth to your Luminus web app; however, I wanted auth to only apply to certain routes. I ended up wrapping the HTTP auth wrapper with a simple check to enable this. I added the following to middleware.clj:
Once the wrapper function is defined, the function can be added to the wrap-base chain.
Now the basic auth wrapper will only run on routes that match the condition. Obviously, you can customize this to whatever criteria you want.