Class: ApiSignature::AuthHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/api_signature/auth_header.rb

Constant Summary collapse

TOKEN_REGEX =
/^(API-HMAC-SHA256)\s+/.freeze
AUTHN_PAIR_DELIMITERS =
/(?:,|\t+)/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorization) ⇒ AuthHeader

Returns a new instance of AuthHeader.



10
11
12
# File 'lib/api_signature/auth_header.rb', line 10

def initialize(authorization)
  @authorization = authorization.to_s
end

Instance Attribute Details

#authorizationObject (readonly)

Returns the value of attribute authorization.



5
6
7
# File 'lib/api_signature/auth_header.rb', line 5

def authorization
  @authorization
end

Instance Method Details

#credentialObject



14
15
16
# File 'lib/api_signature/auth_header.rb', line 14

def credential
  data[0]
end

#optionsObject



28
29
30
# File 'lib/api_signature/auth_header.rb', line 28

def options
  @options ||= (data[1] || {})
end

#signatureObject



18
19
20
# File 'lib/api_signature/auth_header.rb', line 18

def signature
  options['Signature']
end

#signed_headersObject



22
23
24
25
26
# File 'lib/api_signature/auth_header.rb', line 22

def signed_headers
  return [] unless options['SignedHeaders']

  @signed_headers ||= options['SignedHeaders'].split(/;\s?/).map(&:strip)
end