Class: Auth::SignatureValidator

Inherits:
Object
  • Object
show all
Defined in:
app/services/auth/signature_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, threshold = nil) ⇒ SignatureValidator

Returns a new instance of SignatureValidator.



5
6
7
8
# File 'app/services/auth/signature_validator.rb', line 5

def initialize(key = nil, threshold = nil)
  @key = key
  @threshold = threshold
end

Instance Method Details

#validate(request) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'app/services/auth/signature_validator.rb', line 10

def validate(request)
  raise Auth::MissingKeyError, 'Signing Key is not set' unless @key.present?

  authorization_header = authorization_header(request)
  time_header = time_header(request)

  validate_time!(time_header)

  validate_signature!(request, authorization_header, time_header)
end