Class: Rack::BearerAuth::Request
- Inherits:
-
Object
- Object
- Rack::BearerAuth::Request
- 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
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#via ⇒ Object
readonly
Returns the value of attribute via.
Instance Method Summary collapse
-
#initialize(env) ⇒ Request
constructor
A new instance of Request.
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/rack/bearer_auth/request.rb', line 12 def path @path end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
12 13 14 |
# File 'lib/rack/bearer_auth/request.rb', line 12 def token @token end |
#via ⇒ Object (readonly)
Returns the value of attribute via.
12 13 14 |
# File 'lib/rack/bearer_auth/request.rb', line 12 def via @via end |