-
Notifications
You must be signed in to change notification settings - Fork 6
Sails.js policy handling? #1
Comments
Hi @DEX3 - I'm definitely not an expert on swagger tools, but looks like what's happening is that the hook is applying the routes manually. One way you could work around this problem is by adding another hook. I'll put together an example momentarily. |
Hm, I see. I think I might fork the swagger-sails-hook project and adapt it to better suit my needs. Thanks for the help! |
If there's a better way to handle this, please let us know or offer a PR. We want this to be a proper integration for Sails folks! |
@DEX3 definitely- if you're running up against something broadly applicable, let's fold it in 👍 |
Doing this at the sails level means that you can't use 'security' definitions in swagger.yaml, which could be preferred because it makes clear to users what is and isn't protected. In an attempt to make swagger's security configuration sails-y I've added
Seems to work although it will fall over if the file doesn't exist. Happy to submit a pull request if someone can suggest the neatest way to resolve that. |
I have the same issue as @DEX3. How can I use sails policies with Swagger/sails? It appears to be skipping the policies. |
There's something going on with the way the Sails Hook works that Policies are not run that I don't understand. I'm hoping @mikermcneil could shed some light on this. |
@mikermcneil I have your gist hook, but it fails finding policy function. then it work as expected. Many thanks |
Hello,
I've found that sails-policies aren't called when using swagger-sails.
Minimum example to reproduce:
Change line in
config/policies.js
fromto
This will actually break startup, because now sails is looking for a policy that does not yet exist. Now, create the file
api/policies/testpolicy.js
:The application will now start up again:
But the policy is not called when accessing the default controller via "localhost:10010/hello"! Is this the expected behaviour? Is there another way of implementing policy-like semantics with
swagger-node
?The text was updated successfully, but these errors were encountered: