Skip to content

Using krakenjs middleware config for whitelisting and blacklisting routes

Matt Edelman edited this page Apr 13, 2015 · 10 revisions

Whitelisting

All routes with same starting path

This pattern will require authentication for all routes namespaced under /auth

{
  "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.

Try it yourself

Clone middleware-patterns and run the whitelist pattern.