Module: ProxyAuthentication::AuthenticationCipher

Extended by:
AuthenticationCipher
Included in:
AuthenticationCipher
Defined in:
lib/proxy_authentication/authentication_cipher.rb

Instance Method Summary collapse

Instance Method Details

#decode(token, request = nil) ⇒ Object



14
15
16
17
18
# File 'lib/proxy_authentication/authentication_cipher.rb', line 14

def decode token, request = nil
  data = Cipher.decode_data_from_url_token token
  return nil if data.nil? || !valid_request?(data, request)
  extract_user data.last
end

#encode(user, request = nil) ⇒ Object



9
10
11
12
# File 'lib/proxy_authentication/authentication_cipher.rb', line 9

def encode user, request = nil
  data = request_info(request) << user.to_authentication_hash.to_json
  Cipher.encode_data_as_url_token data
end