Module: Hadley::Authz::Basic::ConfigExtension

Defined in:
lib/hadley/authz/basic.rb

Overview

This module provides the configuration extension to Warden allowing for ease of configuration for basic auth strategies via the following syntax:

use Warden::Manager do |manager|
  manager.basic(:server) do |basic|
    basic.hash_credentials true
    basic.lookup do |id, secret|
      [ id, secret] == [ 'client_identity', 'client_secret' ] ? id : nil
    end
  end
end

Instance Method Summary collapse

Instance Method Details

#basic(name, &block) ⇒ Object

Configures and registers and new basic authorization strategy.

Parameters:

  • name (Symbol)

    The unqualified name for the new basic authorization strategy.

  • config (Hadley::Config)

    The configuration specific to the new basic authorization strategy.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/hadley/authz/basic.rb', line 59

def basic(name, &block)
  config = Hadley::Config.new(
    realm: 'Access Tokens',
    fail_message: 'Authorization Failed',
    hash_credentials: false
  )
  if block_given?
    if block.arity == 1 
      yield config
    else
      config.instance_eval(&block)
    end
  end
  Hadley::Authz::Basic::Strategy.build(name, config) unless config.lookup.nil?
end