soar-authentication-identity_uuid_translator 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad31c2ba0758930b4216021ccf55279f0c276d38
4
- data.tar.gz: 5e0cbcb60fa6e0d87b8cb7b919f443541be544ab
3
+ metadata.gz: 62918fb1409f0b7fd6a28ba4c0e5d7e06a84fd0f
4
+ data.tar.gz: 154f26e6dba8e4841badb6219348beee137747b3
5
5
  SHA512:
6
- metadata.gz: ebe9e7fd20daea4f936af51e9499e9d053b304effba39f50944a943f5a646f3c14e0943adbe0e6b60c2f35c01c3a20a3f96f94ceaf20e07a781b08f02681068b
7
- data.tar.gz: 6f0903ab2cd8fbd4cf863e8a2d640cd01f4bfd50dc241e14b6d1ae7286268c799f6080b3596ec26599d059588e7d4e602b04309792f2e7317501dede9b67f2e9
6
+ metadata.gz: 5fe73df28bd768f251b1ba099fc92e7030c78f2e5b56ea6cf98f0e102451381d429feae83bf0336d0200ae8cd19237a5934873c6adec989af4224c5f7db3dc3e
7
+ data.tar.gz: 8b06e5067c6d8026865fa03be6eaf3da9db932b07b08efb826a253638c3fc2aec4034607fada8f89e677c2c068007a07c0449a6a0550020b6f9851732402c0dc
data/.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "soar-authentication-identity_uuid_translator"
3
- spec.version = "1.0.3"
3
+ spec.version = "1.0.4"
4
4
  spec.authors = ["Charles Mulder"]
5
5
  spec.email = ["charles.mulder@hetzner.co.za"]
6
6
 
data/Dockerfile.dynamo_db CHANGED
@@ -2,4 +2,4 @@ FROM openjdk:7
2
2
  WORKDIR /opt/dynamodb_local
3
3
  RUN wget -q -O - http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz | tar -xzf - -C /opt/dynamodb_local
4
4
  EXPOSE 8000
5
- ENTRYPOINT ["/usr/bin/java", "-Djava.library.path=/opt/dynamodb_local/DynamoDBLocal_lib", "-jar", "DynamoDBLocal.jar", "-inMemory"]
5
+ ENTRYPOINT ["/usr/bin/java", "-Djava.library.path=/opt/dynamodb_local/DynamoDBLocal_lib", "-jar", "DynamoDBLocal.jar"]
data/Dockerfile.features CHANGED
@@ -4,4 +4,4 @@ WORKDIR /usr/local/src
4
4
  ADD Gemfile .gemspec /usr/local/src/
5
5
  RUN bundle install --without development --with test
6
6
  ADD . /usr/local/src/
7
- CMD sleep 10; bundle exec cucumber;
7
+ CMD bundle exec cucumber;
@@ -6,7 +6,7 @@ config:
6
6
  partition_key: 'identity_uuid'
7
7
  sort_key: 'identity_role'
8
8
  configuration:
9
- region: 'us-west-2'
9
+ region: 'eu-west-1'
10
10
  endpoint: 'http://dynamodb:8000'
11
11
  http_read_timeout: 1,
12
12
  retry_limit: 0
@@ -8,7 +8,7 @@ module Soar
8
8
  class Customer
9
9
 
10
10
  ROLE = "customer_profile_administrator"
11
- PREFIX = "genie:client:id:"
11
+ PREFIX = "mysql:genie:client:id:"
12
12
 
13
13
  ##
14
14
  # @param [String] identifier
@@ -29,6 +29,7 @@ module Soar
29
29
  @uuid = @uuid_generator.nil? ? @identifiers[0] : @uuid_generator::generate("#{PREFIX}#{@identifiers[0]}")
30
30
  @role_generator.generate({
31
31
  "identity_uuid" => uuid,
32
+ "identity_source" => "#{PREFIX}#{@identifiers[0]}",
32
33
  "identity_role" => ROLE,
33
34
  "identity_role_attributes" => {
34
35
  "profiles" => [client_number].compact
@@ -7,6 +7,7 @@ module Soar
7
7
  class Staff
8
8
 
9
9
  ROLE = "hetzner_staff_member"
10
+ PREFIX = "ldap:people:genieuser:entryuuid:"
10
11
 
11
12
  def initialize(identifier: , identity_registry: , role_generator: nil)
12
13
  @identifier = identifier
@@ -19,7 +20,8 @@ module Soar
19
20
  identifiers = @idr.get_identifiers(@identifier)
20
21
  @uuid = identifiers[0]
21
22
  @role_generator.generate({
22
- "identity_uuid" => uuid,
23
+ "identity_uuid" => @uuid,
24
+ "identity_source" => "#{PREFIX}#{@uuid}",
23
25
  "identity_role" => ROLE
24
26
  }) if not @role_generator.nil?
25
27
  return @uuid
@@ -13,8 +13,8 @@ module Soar
13
13
  module OrchestrationProvider
14
14
  class Base
15
15
 
16
- SLEEP_SECONDS = 1
17
- CONNECTION_RETRIES = 6
16
+ SLEEP_SECONDS = 5
17
+ CONNECTION_RETRIES = 10
18
18
 
19
19
  def initialize
20
20
  @connection_retries = CONNECTION_RETRIES
@@ -22,14 +22,14 @@ module Soar
22
22
 
23
23
  def given_roles_directory
24
24
  begin
25
- roles_directory_configuration = YAML.load_file("config/#{ENV['ROLES_DIRECTORY_CONFIG_FILE']}")
26
- @roles_directory = Soar::Registry::Directory.new(
27
- Soar::Registry::Directory::Provider::DynamoDb.new(Hashie.symbolize_keys(roles_directory_configuration['config']))
28
- )
29
- @roles_directory.provider.recreate_table({
30
- name: roles_directory_configuration['config']['table'][:name],
31
- structure: JSON.parse(File.read("lib/soar/authentication/identity_uuid_translator/test/fixtures/roles_table.json"))
32
- })
25
+ roles_directory_configuration = YAML.load_file("config/#{ENV['ROLES_DIRECTORY_CONFIG_FILE']}")
26
+ @roles_directory = Soar::Registry::Directory.new(
27
+ Soar::Registry::Directory::Provider::DynamoDb.new(Hashie.symbolize_keys(roles_directory_configuration['config']))
28
+ )
29
+ @roles_directory.provider.recreate_table({
30
+ name: roles_directory_configuration['config']['table'][:name],
31
+ structure: JSON.parse(File.read("lib/soar/authentication/identity_uuid_translator/test/fixtures/roles_table.json"))
32
+ })
33
33
  rescue Soar::Registry::Directory::Error::NetworkingError => e
34
34
  raise if @connection_retries == 0
35
35
  sleep(SLEEP_SECONDS)
@@ -10,11 +10,21 @@ module Soar
10
10
  def given_existing_role_and_attributes
11
11
  @roles_directory.put({
12
12
  "identity_uuid" => Soar::Authentication::IdentityUuidTranslator::UuidGenerator.generate("#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}"),
13
+ "identity_source" => "#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}",
13
14
  "identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Customer::ROLE,
14
15
  "identity_role_attributes" => [Faker::Number.unique.number(10)].compact
15
16
  })
16
17
  end
17
18
 
19
+ def source?
20
+ primary_key = {
21
+ "identity_uuid" => @uuid,
22
+ "identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Customer::ROLE
23
+ }
24
+ identity = @roles_directory.fetch(primary_key)
25
+ return identity['identity_source'] == "#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}"
26
+ end
27
+
18
28
  def role?
19
29
  begin
20
30
  primary_key = {
@@ -23,7 +33,7 @@ module Soar
23
33
  }
24
34
  identity = @roles_directory.fetch(primary_key)
25
35
  identity['identity_role'] == Soar::Authentication::IdentityUuidTranslator::Provider::Customer::ROLE
26
- return identity['identity_role_attributes'].include?(@identity[:Client_Number])
36
+ return identity['identity_role_attributes']['profiles'].include?(@identity[:Client_Number])
27
37
  rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
28
38
  return false
29
39
  end
@@ -28,7 +28,7 @@ module Soar
28
28
  )
29
29
  rescue Soar::Registry::Directory::Error::NetworkingError => e
30
30
  raise if @connection_retries == 0
31
- sleep(self::SLEEP_SECONDS)
31
+ sleep(SLEEP_SECONDS)
32
32
  @connection_retries -= 1
33
33
  given_identity_registry
34
34
  end
@@ -16,51 +16,56 @@ module Soar
16
16
  @identity = {
17
17
  dn: "cn=John Smith,#{@identity_directory_configuration['config']['base']}",
18
18
  attributes: {
19
- cn: "John Smith",
20
- mail: @identifier,
21
- objectclass: ["inetOrgPerson", "top"],
22
- sn: "Smith"
23
- }
19
+ cn: "John Smith",
20
+ mail: @identifier,
21
+ objectclass: ["inetOrgPerson", "top"],
22
+ sn: "Smith"
23
+ }
24
24
  }
25
25
  @identity_directory.provider.delete(@identity[:dn])
26
26
  @identity_directory.put(@identity)
27
27
  rescue Soar::Registry::Directory::Error::DuplicateEntryError => e
28
28
  true
29
+ rescue Soar::Registry::Directory::Error::NetworkingError => e
30
+ raise if @connection_retries == 0
31
+ sleep(SLEEP_SECONDS)
32
+ @connection_retries -= 1
33
+ given_existing_identity
29
34
  end
30
35
  end
31
36
 
32
37
 
33
38
  def given_existing_role_and_attributes
34
- @roles_directory.put({
35
- "identity_uuid" => @identity_registry.get_identifiers(@identifier)[0],
36
- "identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
37
- })
38
- end
39
-
40
- def given_identity_registry
41
-
42
39
  begin
43
- @identity_directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
44
-
45
- @identity_directory = Soar::Registry::Directory.new(
46
- Soar::Registry::Directory::Provider::Ldap.new(Hashie.symbolize_keys(@identity_directory_configuration['config']))
47
- )
48
-
49
- @identity_registry = Soar::Registry::Identity.new(
50
- Soar::Registry::Identity::Provider::Staff::Email.new({
51
- directory: @identity_directory,
52
- fetch_index: 'entryuuid',
53
- search_index: 'mail'
54
- })
55
- )
40
+ @roles_directory.put({
41
+ "identity_uuid" => @identity_registry.get_identifiers(@identifier)[0],
42
+ "identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
43
+ })
56
44
  rescue Soar::Registry::Directory::Error::NetworkingError => e
57
45
  raise if @connection_retries == 0
58
46
  sleep(SLEEP_SECONDS)
59
47
  @connection_retries -= 1
60
- given_identity_registry
48
+ given_existing_role_and_attributes
61
49
  end
62
50
  end
63
51
 
52
+ def given_identity_registry
53
+
54
+ @identity_directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
55
+
56
+ @identity_directory = Soar::Registry::Directory.new(
57
+ Soar::Registry::Directory::Provider::Ldap.new(Hashie.symbolize_keys(@identity_directory_configuration['config']))
58
+ )
59
+
60
+ @identity_registry = Soar::Registry::Identity.new(
61
+ Soar::Registry::Identity::Provider::Staff::Email.new({
62
+ directory: @identity_directory,
63
+ fetch_index: 'entryuuid',
64
+ search_index: 'mail'
65
+ })
66
+ )
67
+ end
68
+
64
69
  def role?
65
70
  begin
66
71
  primary_key = {
@@ -78,6 +83,15 @@ module Soar
78
83
  @uuid == @identity_registry.get_identifiers(@identifier)[0]
79
84
  end
80
85
 
86
+ def source?
87
+ primary_key = {
88
+ "identity_uuid" => @uuid,
89
+ "identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
90
+ }
91
+ identity = @roles_directory.fetch(primary_key)
92
+ identity['identity_source'] == "#{Soar::Authentication::IdentityUuidTranslator::Provider::Staff::PREFIX}#{@uuid}"
93
+ end
94
+
81
95
  end
82
96
  end
83
97
  end
@@ -48,6 +48,10 @@ module Soar
48
48
  @provider.uuid?
49
49
  end
50
50
 
51
+ def source?
52
+ @provider.source?
53
+ end
54
+
51
55
  end
52
56
  end
53
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar-authentication-identity_uuid_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Mulder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-03 00:00:00.000000000 Z
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: soar-registry-identity