-
Notifications
You must be signed in to change notification settings - Fork 459
Using krakenjs middleware config for whitelisting and blacklisting routes
Matt Edelman edited this page Apr 13, 2015
·
10 revisions
This pattern will require authentication for all routes namespaced under /auth
.
Building from the kraken-js default of mounting routes from /routes/index.js
:
- the
lib/auth
module (see here) will check authentication before the built-in router for all/auth/*
routes. - Any protected routes will be mounted via
/routes/auth.js
(see here)
{
"middleware": {
"auth": {
"enabled": true,
"priority": 119, // just before the built-in router
"route": "/auth",
"module": {
"name": "path:./lib/auth",
"arguments": [ "admin", "password" ]
}
},
"auth-router": {
"enabled": true,
"priority": 121, // just after the build-in router
"route": "/auth",
"module": {
"name": "express-enrouten",
"arguments": [{ "index": "path:./routes/auth" }]
}
}
}
}
Any routes defined under different namespaces will not require authentication per this configuration.
Clone middleware-patterns and run the whitelist pattern.