Class: Rack::BearerAuth::MatchPattern
- Inherits:
-
Object
- Object
- Rack::BearerAuth::MatchPattern
- Defined in:
- lib/rack/bearer_auth/match_pattern.rb
Defined Under Namespace
Classes: Base, Path, Token, Via
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(path, via, token) ⇒ MatchPattern
constructor
A new instance of MatchPattern.
- #match(req) ⇒ Object
Constructor Details
#initialize(path, via, token) ⇒ MatchPattern
Returns a new instance of MatchPattern.
8 9 10 11 12 13 14 |
# File 'lib/rack/bearer_auth/match_pattern.rb', line 8 def initialize(path, via, token) raise ArgumentError, "Token pattern is required" unless token @path = Path.new(path) @via = Via.new(via) @token = Token.new(token) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/rack/bearer_auth/match_pattern.rb', line 6 def path @path end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/rack/bearer_auth/match_pattern.rb', line 6 def token @token end |
#via ⇒ Object (readonly)
Returns the value of attribute via.
6 7 8 |
# File 'lib/rack/bearer_auth/match_pattern.rb', line 6 def via @via end |
Instance Method Details
#match(req) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rack/bearer_auth/match_pattern.rb', line 16 def match(req) return :skip unless match_route?(req) return :token_required unless req.token token.match?(req.token) ? :ok : :invalid_token end |