Module: Hadley::Authz::Bearer::ConfigExtension
- Defined in:
- lib/hadley/authz/bearer.rb
Overview
This module provides the configuration extension to Warden allowing for ease of configuration for bearer token based authorization strategies via the following syntax:
use Warden::Manager do |manager|
manager.bearer(:server) do |bearer|
bearer.token_store token_store
bearer.anonymous_allowed true
end
end
Instance Method Summary collapse
-
#bearer(name, &block) ⇒ Object
Configures and registers and new bearer token based authorization strategy.
Instance Method Details
#bearer(name, &block) ⇒ Object
Configures and registers and new bearer token based authorization strategy.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/hadley/authz/bearer.rb', line 79 def bearer(name, &block) config = Hadley::Config.new( realm: 'Access Tokens', fail_message: 'Authorization Failed', anonymous_allowed: false ) if block_given? if block.arity == 1 yield config else config.instance_eval(&block) end end Hadley::Authz::Bearer::Strategy.build(name, config) unless config.token_store.nil? end |