Add authorizations property to route definition and support for third party authorizations plugin
This Pull Request addresses issue #11.
Usage / Implementation
-
You can optionally add an ‘authorizations’ parameter to each route with a space separated list of route-authorizations (Example: "admin super-admin").
server.get({url: '/test/method/:data', authorizations: 'account', swagger: { summary: 'Get', notes: '', nickname: 'getTest' }, validation: { data: { isRequired: true, description: 'Data', swaggerType: 'string', scope: 'path' } }}, function(req, res, next) { res.send( { data : "get" }); }); -
The authorizations are listed in the swagger resources.json.
"resourcePath": "/swagger/test", "apis": [ { "path": "/test/method/{data}", "description": "", "operations": [ { "notes": null, "nickname": "getTest", "produces": [ "application/json" ], "consumes": [ "application/json" ], "responseMessages": [ { "code": 500, "message": "Internal Server Error" } ], "parameters": [ { "type": "string", "dataType": "string", "name": "data", "description": "Data", "required": true, "paramType": "path" } ], "authorizations": { "type": "account" }, "summary": "Get", "httpMethod": "GET", "method": "GET" } ] } -
when swagger loads it will optionally call a third party plugin to verify the api_key (if provided) and user authorizations.
-
configuring the third party plugin is done by passing the 'authorizationsPlugin' in the configuration options.
restifySwagger.configure(server, { info: { contact: '[email protected]', description: 'Description text', license: 'MIT', licenseUrl: 'http://opensource.org/licenses/MIT', termsOfServiceUrl: 'http://opensource.org/licenses/MIT', title: 'Node Restify Swagger Demo' }, apiDescriptions: { 'get':'GET-Api Resourcen' }, authorizationsPlugin: swaggerAuthorizations });
Coverage decreased (-1.73%) when pulling b6a8496de7d8f4ac12bb3cda877d17b4df958145 on metasection:master into b405bcae11f8dc01a8201c4ada28cc1db9ab5e17 on z0mt3c:master.
Any word? Ready to pull?
Happy holidays!!!! You like the changes? Ready to pull?
Thanks! Looks better... could you please add some more information about your "swaggerAuthorizations interface"? And that should it be ;-)
@z0mt3c Any updates on this? Thanks!