Class: HTTP::TokenAuth::AuthorizationHeaderParser
- Inherits:
-
Object
- Object
- HTTP::TokenAuth::AuthorizationHeaderParser
- Defined in:
- lib/http/token_auth/authorization_header_parser.rb
Instance Method Summary collapse
- #build_credentials(attributes) ⇒ Object
-
#initialize ⇒ AuthorizationHeaderParser
constructor
A new instance of AuthorizationHeaderParser.
- #parse(header) ⇒ Object
- #parse_coverage(string) ⇒ Object
- #parse_timestamp(string) ⇒ Object
Constructor Details
#initialize ⇒ AuthorizationHeaderParser
Returns a new instance of AuthorizationHeaderParser.
12 13 14 |
# File 'lib/http/token_auth/authorization_header_parser.rb', line 12 def initialize @scheme_parser = SchemeParser.new end |
Instance Method Details
#build_credentials(attributes) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/http/token_auth/authorization_header_parser.rb', line 20 def build_credentials(attributes) Credentials.new token: attributes[:token], coverage: parse_coverage(attributes[:coverage]), nonce: attributes[:nonce], auth: attributes[:auth], timestamp: (attributes[:timestamp]) rescue CredentialsArgumentError => e raise AuthorizationHeaderParsingError, e. end |
#parse(header) ⇒ Object
16 17 18 |
# File 'lib/http/token_auth/authorization_header_parser.rb', line 16 def parse(header) build_credentials @scheme_parser.parse(header) end |
#parse_coverage(string) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/http/token_auth/authorization_header_parser.rb', line 30 def parse_coverage(string) case string when nil when '' when 'none' then :none when 'base' then :base when 'base+body-sha-256' then :base_body_sha_256 else raise AuthorizationHeaderParsingError, %(Unsupported coverage "#{string}") end end |
#parse_timestamp(string) ⇒ Object
41 42 43 |
# File 'lib/http/token_auth/authorization_header_parser.rb', line 41 def (string) string.nil? ? nil : string.to_i end |