Module: ProxyAuthentication::Cipher
Instance Method Summary collapse
- #decode_data_from_url_token(token_base64, separator = "\n") ⇒ Object
- #encode_data_as_url_token(data, separator = "\n") ⇒ Object
Instance Method Details
#decode_data_from_url_token(token_base64, separator = "\n") ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/proxy_authentication/cipher.rb', line 13 def decode_data_from_url_token token_base64, separator = "\n" raw_data = decode64 token_base64 return nil if raw_data.nil? data = raw_data.split separator actual_signature = data.pop expected_signature = signature_for data.join(separator) return nil if actual_signature != expected_signature data end |
#encode_data_as_url_token(data, separator = "\n") ⇒ Object
7 8 9 10 11 |
# File 'lib/proxy_authentication/cipher.rb', line 7 def encode_data_as_url_token data, separator = "\n" data = data.join separator string = [ data, signature_for(data) ].join separator Base64.urlsafe_encode64 string end |