angus-remote 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmE1OGJhNmE2OTA2NDc5YjgwMWQ2ODhmNzExN2ZjYzhjMmI5YWRiOA==
4
+ MGVjNThjODQ3NDQ5YjQyOTU2NTYzZTQxYjAwMzU2YjViYTdjNjAwNw==
5
5
  data.tar.gz: !binary |-
6
- ZGVlNjc5Y2JhNThiYWQzNTkzYTA4Yjc0MGVkYzUxZDRmN2IyMzgxNQ==
6
+ YjMxNGVmZGM0YzdjOGI2M2NhNjQ0OWQ1ZmU3YWI2OTI2NDAwZWQ0Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDQ3NzUyZGMxOTI3NGM4ZWQ3Y2YzYWNhYzM5NGIzYTA3ZTNhZDFjNzVlNTRi
10
- MjY4MGM2N2NiNzkzMGU1YzRiNTdiM2ZkMzBjZTIwZjhiNjc2MmZhOWQ3ZDc1
11
- MGMyMjljNzRmODA0NzViNDhmNjhhOWIzYjA3MDYwZWZkZjJmNGY=
9
+ Njc4NjE5MjU1ODU4M2M3MGIwZTM5NzFiYjBmOWQwMWQ4MTIzMzY0ZTBiNmQ5
10
+ NzY0MTNiNWUxMGZmOWI4N2FkN2U2OWI4ZWY0NjlmOWJjOGNjMjhhNDI3MDEw
11
+ MDBlNzI1NDY5N2NjNzc3MjUzMDllNGFiOTFlOTQ0Y2I0NmI2ZTU=
12
12
  data.tar.gz: !binary |-
13
- OGE2NjNlMjdhYTJkMzhhMWViMjU5ODkyNjk1NjIwYzMwMDIxYTk1NDFjM2Fm
14
- YjlkOGQ1ZjNjZDI2M2Y5ODhlMjZjYjA5NDAxMDIyZTgzNjg0MDQyZTJkMzZi
15
- NmZlOWJkMjdjN2ZhYWQ5YTk1ODJiMWJjYTkzNjE3YjU5Nzk4ZTc=
13
+ NDg3NDY5YTg1MDRmNDUwYWRjMmNlNjI5N2Y4MWE3NTVkYzI2ZmFkOGNlZDNh
14
+ M2Q1YTAzMzVhZDNmZDVjODRkNWY5YWNjOGFjOWEyMjdhNTdlZTc4NzExM2M4
15
+ MDA5MmM0MzRjYTY4MzIzNmQwODdlNWY4NGRkYTVkZTEyYjFhYTY=
@@ -6,21 +6,28 @@ module Angus
6
6
  module Authentication
7
7
  class Client
8
8
 
9
- DEFAULT_PUBLIC_KEY = '1234567'
10
- DEFAULT_PRIVATE_KEY = 'CHANGE ME!!'
11
-
12
9
  AUTHENTICATION_HEADER = 'AUTHORIZATION'
13
10
  BAAS_AUTHENTICATION_HEADER = 'X-BAAS-AUTH'
14
11
  BAAS_SESSION_HEADER = 'X-Baas-Session-Seed'
15
12
  DATE_HEADER = 'DATE'
16
13
 
17
14
  def initialize(settings)
18
- @public_key = settings[:public_key] || DEFAULT_PUBLIC_KEY
19
- @private_key = settings[:private_key] || DEFAULT_PRIVATE_KEY
15
+ unless settings[:public_key] && settings[:private_key]
16
+ warn "No authentication info provided, angus-authentication has been disabled for: #{settings[:service_id]}"
17
+ @enabled = false
18
+ return
19
+ end
20
+
21
+ @enabled = true
22
+ @public_key = settings[:public_key]
23
+ @private_key = settings[:private_key]
24
+
20
25
  @store = RedisClient.new(settings[:store] || {})
21
26
  end
22
27
 
23
28
  def prepare_request(request, http_method, script_name)
29
+ return unless @enabled
30
+
24
31
  date = Date.today
25
32
 
26
33
  auth_token = generate_auth_token(date, http_method, script_name)
@@ -32,6 +39,8 @@ module Angus
32
39
  end
33
40
 
34
41
  def store_session_private_key(response)
42
+ return unless @enabled
43
+
35
44
  session_key_seed = extract_session_key_seed(response)
36
45
  return unless session_key_seed
37
46
 
@@ -31,6 +31,7 @@ module Angus
31
31
  store_namespace = "#{options['code_name']}.#{options['version']}"
32
32
  client_settings = { :public_key => options['public_key'],
33
33
  :private_key => options['private_key'],
34
+ :service_id => store_namespace,
34
35
  :store => Settings.redis.merge({ :namespace => store_namespace }) }
35
36
 
36
37
  @authentication_client = Authentication::Client.new(client_settings)
@@ -53,4 +53,4 @@ module Angus
53
53
  end
54
54
 
55
55
  end
56
- end
56
+ end
@@ -42,6 +42,12 @@ module Angus
42
42
  service_code_name, version
43
43
  )
44
44
 
45
+ self.build_from_definition(status_code, body, service_definition, operation_namespace,
46
+ operation_code_name)
47
+ end
48
+
49
+ def self.build_from_definition(status_code, body, service_definition, operation_namespace,
50
+ operation_code_name)
45
51
  representations = service_definition.representations
46
52
  glossary = service_definition.glossary
47
53
 
@@ -57,8 +63,8 @@ module Angus
57
63
  # TODO use constants
58
64
  response[:status_code] = status_code
59
65
  response[:body] = body
60
- response[:service_code_name] = service_code_name
61
- response[:service_version] = version
66
+ response[:service_code_name] = service_definition.code_name
67
+ response[:service_version] = service_definition.version
62
68
  response[:operation_namespace] = operation_namespace
63
69
  response[:operation_code_name] = operation_code_name
64
70
 
@@ -217,6 +217,7 @@ module Angus
217
217
 
218
218
  settings = { :public_key => service_settings['public_key'],
219
219
  :private_key => service_settings['private_key'],
220
+ :service_id => "#{code_name}.#{version}",
220
221
  :store => Settings.redis.merge({ :namespace => "#{code_name}.#{version}" }) }
221
222
 
222
223
  @authentication_clients[[code_name, version]] = Angus::Authentication::Client.new(settings)
@@ -1,7 +1,7 @@
1
1
  module Angus
2
2
  module Remote
3
3
 
4
- VERSION = '0.0.10'
4
+ VERSION = '0.0.11'
5
5
 
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angus-remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Gomez