Class: Rack::BearerAuth::MatchPattern

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

Defined Under Namespace

Classes: Base, Path, Token, Via

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, via, token) ⇒ MatchPattern

Returns a new instance of MatchPattern.

Raises:

  • (ArgumentError)


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

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/rack/bearer_auth/match_pattern.rb', line 6

def path
  @path
end

#tokenObject (readonly)

Returns the value of attribute token.



6
7
8
# File 'lib/rack/bearer_auth/match_pattern.rb', line 6

def token
  @token
end

#viaObject (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