Class: Rack::AuthenticationBearer

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/authentication_bearer.rb,
lib/rack/authentication_bearer/version.rb

Constant Summary collapse

EXPRESSION =
/^Bearer\s+/
RACK_KEY =
"rack.authentication"
AUTHENTICATION_KEY =
"HTTP_AUTHENTICATION"
AUTHORIZATION_KEY =
"HTTP_AUTHORIZATION"
VERSION =
"1.0.0"

Instance Method Summary collapse

Constructor Details

#initialize(stack, &process) ⇒ AuthenticationBearer

Returns a new instance of AuthenticationBearer.



12
13
14
15
# File 'lib/rack/authentication_bearer.rb', line 12

def initialize(stack, &process)
  @stack = stack
  @process = process if block_given?
end

Instance Method Details

#call(previous_state) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rack/authentication_bearer.rb', line 17

def call(previous_state)
  @state = previous_state

  if token && process
    state[RACK_KEY] = process.call(token)
  else
    state[RACK_KEY] = token
  end

  stack.call(state)
end