I have a Node.js API in which I want to add swagger documentation. Clients authorize via JWT, so I added this to security:
securityDefinitions:
UserSecurity:
type: apiKey
description: User is logged in
in: header
name: Authorization
Than I can add this to different paths to tell the client, to do this you need to be logged in.
/user/{userId}
get:
security:
- UserSecurity: []
But how do I add more specific security constrains? Like, the user can only edit the profile if logged as that user. Or a user can edit a comment if he has superadmin status OR if he is admin for the board the comment is posted at OR is logged as the user that created this comment.