module Xenon::Routing::SecurityDirectives

Public Instance Methods

authenticate(authenticator) { |user| ... } click to toggle source
# File lib/xenon/routing/security_directives.rb, line 8
def authenticate(authenticator)
  extract_request(authenticator) do |user|
    if user
      yield user
    else
      reject :unauthorized, { scheme: authenticator.scheme }.merge(authenticator.auth_params)
    end
  end
end
authorize(check) { || ... } click to toggle source
# File lib/xenon/routing/security_directives.rb, line 24
def authorize(check)
  if check.respond_to?(:call)
    extract_request(check) do |authorized|
      authorize(authorized) do
        yield
      end
    end
  elsif check
    yield
  else
    reject :forbidden
  end
end
optional_authenticate(authenticator) { |user| ... } click to toggle source
# File lib/xenon/routing/security_directives.rb, line 18
def optional_authenticate(authenticator)
  extract_request(authenticator) do |user|
    yield user
  end
end