Swagger RBAC middleware
Simple middleware with RBAC on JSON swagger document
swagger: "2.0" produces: "application/json" host: "localhost:3001" basePath: "/v1" paths: "/testfoo/:type/:id": get: tags: "/foo" rbac: "group1" "/testfoo/:foo/:foo/:foo": get: "x-swagger-router-controller": "foo" operationId: "fooControllerWithPage" tags: "/foo" rbac: "group1" "/testfoobar/:foo": get: "x-swagger-router-controller": "foobar" operationId: "foobarController" tags: "/foobar" ;
If the RABC role is defined in the route the middleware will match it with what's defined in req.groups
.
Example:
const swaggerDoc = swagger: "2.0" produces: "application/json" host: "localhost:3001" basePath: "/v1" paths: "/testfoo/:type/:id": get: tags: "/foo" rbac: "group1" "/testfoo/:foo/:foo/:foo": get: "x-swagger-router-controller": "foo" operationId: "fooControllerWithPage" tags: "/foo" rbac: "group1" "/testfoobar/:foo": get: "x-swagger-router-controller": "foobar" operationId: "foobarController" tags: "/foobar" ; const config = ; app; // setting middlewareapp; app; const response = await ;
For all the endpoints that have no rbac defined the middleware will make the request got through. Please check the tests for more examples.