Role based custom security schemes


#1

Hello i am trying to implement a role based custom securityScheme i have been googling around and ended up empty handed i would like to have something like the oauth_2 has
what i would like to achieve is:

securitySchemes:
  custom_auth:
    type: x-custom
    settings:
      scopes:
        enum: [ user, admin, root ]
/test:
  get:
    securedBy: [custom_auth: { scopes: [ admin ] }]
  post:
    ....

the only way that i could achieve this is having different schemass for each role, which is not exactly what i was looking fore

securitySchemes:
  user_auth:
    type: x-custom
  admin_auth:
    type: x-custom
/test:
  get:
    securedBy: [user_auth]
  post:
    securedBy: [admin_auth]

is there different way to achieve this?


#2

Have you seen the last example of the “Applying Security Schemes” section of the Specs?

#%RAML 1.0
title: GitHub API
version: v3
baseUri: https://api.github.com
securitySchemes:
  oauth_2_0: !include securitySchemes/oauth_2_0.raml
/users/{userid}/gists:
  get:
    securedBy: [null, oauth_2_0: { scopes: [ ADMINISTRATOR ] } ]

Isn’t it what you’re looking to do?