class Rack::AuthenticationBearer
Constants
- AUTHENTICATION_KEY
- AUTHORIZATION_KEY
- PATTERN
- RACK_KEY
- VERSION
Attributes
process[R]
stack[R]
state[R]
Public Class Methods
new(stack, &process)
click to toggle source
# File lib/rack/authentication_bearer.rb, line 18 def initialize(stack, &process) @stack = stack @process = process if block_given? end
Public Instance Methods
call(previous_state)
click to toggle source
# File lib/rack/authentication_bearer.rb, line 23 def call(previous_state) @state = previous_state return stack.call(state) unless state return stack.call(state) unless process unless present? return stack.call(state.merge(RACK_KEY => Rack::AuthenticationBearer::MissingBearerTokenError)) end unless matches? return stack.call(state.merge(RACK_KEY => Rack::AuthenticationBearer::InvalidBearerTokenError)) end stack.call(state.merge!(RACK_KEY => process.call(shared))) end
Private Instance Methods
matches?()
click to toggle source
# File lib/rack/authentication_bearer.rb, line 50 def matches? value.respond_to?(:match) && value.respond_to?(:length) && value.length > 0 && value.match?(PATTERN) end
present?()
click to toggle source
# File lib/rack/authentication_bearer.rb, line 46 def present? value.respond_to?(:length) && value.length > 0 end
value()
click to toggle source
# File lib/rack/authentication_bearer.rb, line 42 def value state[AUTHENTICATION_KEY] || state[AUTHORIZATION_KEY] end