class Grape::Kong::Authenticable

Public Instance Methods

before() click to toggle source
# File lib/grape/kong/authenticable.rb, line 11
def before
  authenticate!
  context.extend Grape::Kong::Methods
  context.resource_owner = resource_owner
  context.scopes = scopes
end
context() click to toggle source
# File lib/grape/kong/authenticable.rb, line 7
def context
  env['api.endpoint']
end

Private Instance Methods

authenticate!() click to toggle source
# File lib/grape/kong/authenticable.rb, line 20
def authenticate!
  fail Grape::Kong::ForbiddenError unless resource_owner_id
  fail Grape::Kong::ForbiddenError unless resource_owner
end
resource_owner() click to toggle source
# File lib/grape/kong/authenticable.rb, line 25
def resource_owner
  @resource_owner ||= Grape::Kong.config.resource_owner_finder.call(resource_owner_id)
end
resource_owner_id() click to toggle source

logged-in user ID who has granted permission to the client

# File lib/grape/kong/authenticable.rb, line 30
def resource_owner_id
  env['HTTP_X_AUTHENTICATED_USERID']
end
scopes() click to toggle source

TODO comma-separated list of scopes that the end user has authenticated (if available)

# File lib/grape/kong/authenticable.rb, line 36
def scopes
  env['HTTP_X_AUTHENTICATED_SCOPE'].to_s.split(',')
end