load securityHandlers from api/swagger/securityHandlers.js
load securityHandlers from api/swagger/securityHandlers.js

    Example of sails swagger security handler file: api/swagger/securityHandlers.js

      module.exports.securityHandlers = {
        mybasic:function securityHandler1(req, authOrSecDef, scopesOrApiKey, cb) {
            // your security code
            cb();
            },
      };

    Extract of api/swagger/swagger.yaml
    ...
    securityDefinitions:
      mybasic:
         type: basic
    paths:
      /hello:
         # binds a127 app logic to a route
         x-swagger-router-controller: hello_world
         get:
           security:
             - mybasic: []
    ...

cgalibern/swagger-sails