Module: Roda::RodaPlugins::TokenAuth

Defined in:
lib/roda/plugins/token_auth/version.rb,
lib/roda/plugins/token_auth.rb

Defined Under Namespace

Modules: RequestMethods

Constant Summary collapse

VERSION =
"0.1.2".freeze
DEFAULTS =
{
  token_variable: "X-Token",
  secret_variable: "X-Secret",
  unauthorized_headers: proc do |_opts|
    { "Content-Type" => "application/json" }
  end,
  unauthorized_body: proc do |_opts|
    { errors: "Invalid Credentials", success: false}
  end
}.freeze

Class Method Summary collapse

Class Method Details

.configure(app, opts = {}) ⇒ Object



19
20
21
22
23
# File 'lib/roda/plugins/token_auth.rb', line 19

def self.configure(app, opts = {})
  plugin_opts = (app.opts[:token_auth] ||= DEFAULTS)
  app.opts[:token_auth] = plugin_opts.merge(opts)
  app.opts[:token_auth].freeze
end