I am implementing a RESTful API with Express in Node and I am new to both. I would like to use basic authentication for access control.
I would like to apply it using something like a whitelist, but I'm not sure how to do this.
Blacklisting is easy, I can simply transfer my #VERB calls with a second argument:
app.get('/', asyncAuth, requestHandler);
I can do it even further, and blacklist with
app.all('*', asyncAuth, requestHandler);
But I want to apply my basicAuth to every route except for POST /users . Is there an elegant way to do this? Can I use the blacklist approach and then selectively remove it from the routes I need? I could not understand how.
source share