Class: Auth::AuthorizationHeader

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

Constant Summary collapse

AUTHORIZATION_HEADER_FORMAT =
/\ASigningAlgorithm=([[-a-z0-9]]+), SignedHeaders=([[-a-z0-9;]]+), Signature=([[a-f0-9]]+)\Z/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header) ⇒ AuthorizationHeader

Returns a new instance of AuthorizationHeader.

Raises:



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

def initialize(header)
  match = AUTHORIZATION_HEADER_FORMAT.match(header)
  raise HeaderParseError, 'Unsupported Gladly-Authorization header format' if match.nil?

  @signing_algorithm_name = match[1]
  @signing_algorithm = parse_signing_algorithm!(@signing_algorithm_name.gsub('hmac-', ''))
  @signed_headers = parse_headers!(match[2])
  @signature = match[3]
end

Instance Attribute Details

#signatureObject (readonly)

Returns the value of attribute signature.



8
9
10
# File 'app/services/auth/authorization_header.rb', line 8

def signature
  @signature
end

#signed_headersObject (readonly)

Returns the value of attribute signed_headers.



8
9
10
# File 'app/services/auth/authorization_header.rb', line 8

def signed_headers
  @signed_headers
end

#signing_algorithmObject (readonly)

Returns the value of attribute signing_algorithm.



8
9
10
# File 'app/services/auth/authorization_header.rb', line 8

def signing_algorithm
  @signing_algorithm
end

#signing_algorithm_nameObject (readonly)

Returns the value of attribute signing_algorithm_name.



8
9
10
# File 'app/services/auth/authorization_header.rb', line 8

def signing_algorithm_name
  @signing_algorithm_name
end