Class: Rack::BearerAuth::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/bearer_auth/request.rb

Constant Summary collapse

BEARER_TOKEN_REGEXP =

tools.ietf.org/html/rfc6750#section-2.1 b64token = 1*( ALPHA / DIGIT /

"-" / "." / "_" / "~" / "+" / "/" ) *"="

credentials = “Bearer” 1*SP b64token

%r{\ABearer +([A-Za-z0-9\-._~+/]+=*)\z}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



14
15
16
17
18
19
20
# File 'lib/rack/bearer_auth/request.rb', line 14

def initialize(env)
  @path = env["PATH_INFO"]
  @via = env["REQUEST_METHOD"].downcase.to_sym

  authz = env["HTTP_AUTHORIZATION"]
  @token = Regexp.last_match(1) if authz&.match(BEARER_TOKEN_REGEXP)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



12
13
14
# File 'lib/rack/bearer_auth/request.rb', line 12

def path
  @path
end

#tokenObject (readonly)

Returns the value of attribute token.



12
13
14
# File 'lib/rack/bearer_auth/request.rb', line 12

def token
  @token
end

#viaObject (readonly)

Returns the value of attribute via.



12
13
14
# File 'lib/rack/bearer_auth/request.rb', line 12

def via
  @via
end