Class: Angus::Authentication::Client
- Inherits:
-
Object
- Object
- Angus::Authentication::Client
- Defined in:
- lib/angus/authentication/client.rb
Constant Summary collapse
- DEFAULT_PUBLIC_KEY =
'1234567'- DEFAULT_PRIVATE_KEY =
'CHANGE ME!!'- AUTHENTICATION_HEADER =
'AUTHORIZATION'- BAAS_AUTHENTICATION_HEADER =
'X-BAAS-AUTH'- BAAS_SESSION_HEADER =
'X-Baas-Session-Seed'- DATE_HEADER =
'DATE'
Instance Method Summary collapse
-
#initialize(settings) ⇒ Client
constructor
A new instance of Client.
- #prepare_request(request, http_method, script_name) ⇒ Object
- #store_session_private_key(response) ⇒ Object
Constructor Details
#initialize(settings) ⇒ Client
Returns a new instance of Client.
17 18 19 20 21 |
# File 'lib/angus/authentication/client.rb', line 17 def initialize(settings) @public_key = settings[:public_key] || DEFAULT_PUBLIC_KEY @private_key = settings[:private_key] || DEFAULT_PRIVATE_KEY @store = RedisClient.new(settings[:store] || {}) end |
Instance Method Details
#prepare_request(request, http_method, script_name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/angus/authentication/client.rb', line 23 def prepare_request(request, http_method, script_name) date = Date.today auth_token = generate_auth_token(date, http_method, script_name) request[DATE_HEADER] = date.httpdate request[AUTHENTICATION_HEADER] = generate_auth_header(auth_token) session_auth_token = generate_session_auth_token(date, http_method, script_name) request[BAAS_AUTHENTICATION_HEADER] = generate_auth_header(session_auth_token) end |
#store_session_private_key(response) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/angus/authentication/client.rb', line 34 def store_session_private_key(response) session_key_seed = extract_session_key_seed(response) return unless session_key_seed session_key = generate_session_private(session_key_seed) @store.store_session_key(@public_key, session_key) end |