soar-authentication-identity_uuid_translator 1.0.0
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 +7 -0
- data/.gemspec +16 -0
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/Dockerfile.dynamo_db +5 -0
- data/Dockerfile.features +7 -0
- data/Dockerfile.rspec +6 -0
- data/Gemfile +10 -0
- data/README.md +86 -0
- data/Rakefile +14 -0
- data/config/config.ci.dynamo_db.yml +15 -0
- data/config/config.ci.ldap.yml +17 -0
- data/config/config.ci.mysql.yml +18 -0
- data/config/config.dynamo_db.yml +15 -0
- data/config/config.ldap.yml +17 -0
- data/config/config.mysql.yml +18 -0
- data/docker-compose.ci.customer_client_number.yml +34 -0
- data/docker-compose.ci.customer_email.yml +34 -0
- data/docker-compose.ci.factory.yml +16 -0
- data/docker-compose.ci.role_generator.yml +27 -0
- data/docker-compose.ci.staff.yml +37 -0
- data/docker-compose.customer.yml +18 -0
- data/docker-compose.dynamo_db.yml +8 -0
- data/docker-compose.staff.yml +21 -0
- data/lib/soar/authentication/identity_uuid_translator.rb +13 -0
- data/lib/soar/authentication/identity_uuid_translator/error.rb +11 -0
- data/lib/soar/authentication/identity_uuid_translator/factory.rb +23 -0
- data/lib/soar/authentication/identity_uuid_translator/model.rb +24 -0
- data/lib/soar/authentication/identity_uuid_translator/provider/customer.rb +54 -0
- data/lib/soar/authentication/identity_uuid_translator/provider/staff.rb +33 -0
- data/lib/soar/authentication/identity_uuid_translator/role_generator.rb +21 -0
- data/lib/soar/authentication/identity_uuid_translator/test/fixtures/client_table.sql +91 -0
- data/lib/soar/authentication/identity_uuid_translator/test/fixtures/roles_table.json +27 -0
- data/lib/soar/authentication/identity_uuid_translator/test/fixtures/staff.json +18 -0
- data/lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/base.rb +78 -0
- data/lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/customer.rb +50 -0
- data/lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/customer_client_number.rb +52 -0
- data/lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/customer_email.rb +52 -0
- data/lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb +79 -0
- data/lib/soar/authentication/identity_uuid_translator/test/orchestrator.rb +55 -0
- data/lib/soar/authentication/identity_uuid_translator/uuid_generator.rb +13 -0
- metadata +145 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'soar/authentication/identity_uuid_translator/test/orchestration_provider/base'
|
2
|
+
|
3
|
+
module Soar
|
4
|
+
module Authentication
|
5
|
+
module IdentityUuidTranslator
|
6
|
+
module Test
|
7
|
+
module OrchestrationProvider
|
8
|
+
class Customer < Base
|
9
|
+
|
10
|
+
def given_existing_role_and_attributes
|
11
|
+
@roles_directory.put({
|
12
|
+
"identity_uuid" => Soar::Authentication::IdentityUuidTranslator::UuidGenerator.generate("#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}"),
|
13
|
+
"identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Customer::ROLE,
|
14
|
+
"identity_role_attributes" => [Faker::Number.unique.number(10)].compact
|
15
|
+
})
|
16
|
+
end
|
17
|
+
|
18
|
+
def role?
|
19
|
+
begin
|
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
|
+
identity['identity_role'] == Soar::Authentication::IdentityUuidTranslator::Provider::Customer::ROLE
|
26
|
+
return identity['identity_role_attributes'].include?(@identity[:Client_Number])
|
27
|
+
rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def uuid?
|
33
|
+
@uuid == Soar::Authentication::IdentityUuidTranslator::UuidGenerator.generate("#{Soar::Authentication::IdentityUuidTranslator::Provider::Customer::PREFIX}#{@identity[:ID]}")
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
##
|
39
|
+
# Execute command using mysql client on terminal
|
40
|
+
##
|
41
|
+
def recreate_table(host:, username:, password:, filepath:)
|
42
|
+
`mysql -h #{host} -u#{username} -p#{password} konsoleh_genie < '#{filepath}'`
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'soar/authentication/identity_uuid_translator/test/orchestration_provider/customer'
|
2
|
+
|
3
|
+
module Soar
|
4
|
+
module Authentication
|
5
|
+
module IdentityUuidTranslator
|
6
|
+
module Test
|
7
|
+
module OrchestrationProvider
|
8
|
+
class CustomerClientNumber < Customer
|
9
|
+
|
10
|
+
def given_identity_registry
|
11
|
+
|
12
|
+
directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
|
13
|
+
|
14
|
+
recreate_table({
|
15
|
+
host: directory_configuration['config']['config']['host'],
|
16
|
+
username: directory_configuration['config']['credentials']['username'],
|
17
|
+
password: directory_configuration['config']['credentials']['password'],
|
18
|
+
filepath: "lib/soar/authentication/identity_uuid_translator/test/fixtures/client_table.sql"
|
19
|
+
})
|
20
|
+
|
21
|
+
@directory = Soar::Registry::Directory.new(
|
22
|
+
Soar::Registry::Directory::Provider::Mysql.new(Hashie.symbolize_keys(directory_configuration['config']))
|
23
|
+
)
|
24
|
+
|
25
|
+
@identity_registry = Soar::Registry::Identity.new(
|
26
|
+
Soar::Registry::Identity::Provider::Customer::ClientNumber.new({
|
27
|
+
directory: @directory,
|
28
|
+
fetch_index: 'ID',
|
29
|
+
search_index: 'Client_Number'
|
30
|
+
})
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def given_existing_identity
|
35
|
+
@identity = {
|
36
|
+
ID: Faker::Number.number(4),
|
37
|
+
"Notifyemail_Invoice": Faker::Internet.email,
|
38
|
+
"Client_Number": @identifier
|
39
|
+
}
|
40
|
+
@directory.put(@identity)
|
41
|
+
end
|
42
|
+
|
43
|
+
def given_authenticated_identifier
|
44
|
+
@identifier = "C#{Faker::Number.unique.number(10)}"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/customer_email.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'soar/authentication/identity_uuid_translator/test/orchestration_provider/customer'
|
2
|
+
|
3
|
+
module Soar
|
4
|
+
module Authentication
|
5
|
+
module IdentityUuidTranslator
|
6
|
+
module Test
|
7
|
+
module OrchestrationProvider
|
8
|
+
class CustomerEmail < Customer
|
9
|
+
|
10
|
+
def given_identity_registry
|
11
|
+
|
12
|
+
directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
|
13
|
+
|
14
|
+
recreate_table({
|
15
|
+
host: directory_configuration['config']['config']['host'],
|
16
|
+
username: directory_configuration['config']['credentials']['username'],
|
17
|
+
password: directory_configuration['config']['credentials']['password'],
|
18
|
+
filepath: "lib/soar/authentication/identity_uuid_translator/test/fixtures/client_table.sql"
|
19
|
+
})
|
20
|
+
|
21
|
+
@directory = Soar::Registry::Directory.new(
|
22
|
+
Soar::Registry::Directory::Provider::Mysql.new(Hashie.symbolize_keys(directory_configuration['config']))
|
23
|
+
)
|
24
|
+
|
25
|
+
@identity_registry = Soar::Registry::Identity.new(
|
26
|
+
Soar::Registry::Identity::Provider::Customer::Email.new({
|
27
|
+
directory: @directory,
|
28
|
+
fetch_index: 'ID',
|
29
|
+
search_index: 'Notifyemail_Invoice'
|
30
|
+
})
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def given_existing_identity
|
35
|
+
@identity = {
|
36
|
+
ID: Faker::Number.number(4),
|
37
|
+
"Notifyemail_Invoice": @identifier,
|
38
|
+
"Client_Number": "C#{Faker::Number.unique.number(10)}"
|
39
|
+
}
|
40
|
+
@directory.put(@identity)
|
41
|
+
end
|
42
|
+
|
43
|
+
def given_authenticated_identifier
|
44
|
+
@identifier = Faker::Internet.email
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'soar/authentication/identity_uuid_translator/test/orchestration_provider/base'
|
2
|
+
|
3
|
+
module Soar
|
4
|
+
module Authentication
|
5
|
+
module IdentityUuidTranslator
|
6
|
+
module Test
|
7
|
+
module OrchestrationProvider
|
8
|
+
class Staff < Base
|
9
|
+
|
10
|
+
def given_authenticated_identifier
|
11
|
+
@identifier = "#{Faker::Name.first_name.downcase}.#{Faker::Name.last_name.downcase}@hetzner.co.za"
|
12
|
+
end
|
13
|
+
|
14
|
+
def given_existing_identity
|
15
|
+
begin
|
16
|
+
@identity = {
|
17
|
+
dn: "cn=John Smith,#{@identity_directory_configuration['config']['base']}",
|
18
|
+
attributes: {
|
19
|
+
cn: "John Smith",
|
20
|
+
mail: @identifier,
|
21
|
+
objectclass: ["inetOrgPerson", "top"],
|
22
|
+
sn: "Smith"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
@identity_directory.provider.delete(@identity[:dn])
|
26
|
+
@identity_directory.put(@identity)
|
27
|
+
rescue Soar::Registry::Directory::Error::DuplicateEntryError => e
|
28
|
+
true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
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
|
+
@identity_directory_configuration = YAML.load_file("config/#{ENV['IDENTITY_DIRECTORY_CONFIG_FILE']}")
|
43
|
+
|
44
|
+
@identity_directory = Soar::Registry::Directory.new(
|
45
|
+
Soar::Registry::Directory::Provider::Ldap.new(Hashie.symbolize_keys(@identity_directory_configuration['config']))
|
46
|
+
)
|
47
|
+
|
48
|
+
@identity_registry = Soar::Registry::Identity.new(
|
49
|
+
Soar::Registry::Identity::Provider::Staff::Email.new({
|
50
|
+
directory: @identity_directory,
|
51
|
+
fetch_index: 'entryuuid',
|
52
|
+
search_index: 'mail'
|
53
|
+
})
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def role?
|
58
|
+
begin
|
59
|
+
primary_key = {
|
60
|
+
"identity_uuid" => @uuid,
|
61
|
+
"identity_role" => Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
|
62
|
+
}
|
63
|
+
identity = @roles_directory.fetch(primary_key)
|
64
|
+
identity['identity_role'] == Soar::Authentication::IdentityUuidTranslator::Provider::Staff::ROLE
|
65
|
+
rescue Soar::Registry::Directory::Error::NoEntriesFoundError => e
|
66
|
+
return false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def uuid?
|
71
|
+
@uuid == @identity_registry.get_identifiers(@identifier)[0]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Soar
|
2
|
+
module Authentication
|
3
|
+
module IdentityUuidTranslator
|
4
|
+
module Test
|
5
|
+
class Orchestrator
|
6
|
+
|
7
|
+
def initialize(provider)
|
8
|
+
@provider = provider
|
9
|
+
end
|
10
|
+
|
11
|
+
def given_roles_directory
|
12
|
+
@provider.given_roles_directory
|
13
|
+
end
|
14
|
+
|
15
|
+
def given_role_generator
|
16
|
+
@provider.given_role_generator
|
17
|
+
end
|
18
|
+
|
19
|
+
def given_authenticated_identifier
|
20
|
+
@provider.given_authenticated_identifier
|
21
|
+
end
|
22
|
+
|
23
|
+
def given_identity_uuid_translator
|
24
|
+
@provider.given_identity_uuid_translator
|
25
|
+
end
|
26
|
+
|
27
|
+
def given_existing_role_and_attributes
|
28
|
+
@provider.given_existing_role_and_attributes
|
29
|
+
end
|
30
|
+
|
31
|
+
def given_identity_registry
|
32
|
+
@provider.given_identity_registry
|
33
|
+
end
|
34
|
+
|
35
|
+
def given_existing_identity
|
36
|
+
@provider.given_existing_identity
|
37
|
+
end
|
38
|
+
|
39
|
+
def request_identity_uuid
|
40
|
+
@provider.request_identity_uuid
|
41
|
+
end
|
42
|
+
|
43
|
+
def role?
|
44
|
+
@provider.role?
|
45
|
+
end
|
46
|
+
|
47
|
+
def uuid?
|
48
|
+
@provider.uuid?
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soar-authentication-identity_uuid_translator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Charles Mulder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: soar-registry-identity
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.0.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.0.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: object_selector
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.0.1
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.1
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: uuidtools
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '2.1'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.1.5
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.1'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.1.5
|
73
|
+
description:
|
74
|
+
email:
|
75
|
+
- charles.mulder@hetzner.co.za
|
76
|
+
executables: []
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- ".gemspec"
|
81
|
+
- ".gitignore"
|
82
|
+
- ".rspec"
|
83
|
+
- ".ruby-gemset"
|
84
|
+
- ".ruby-version"
|
85
|
+
- Dockerfile.dynamo_db
|
86
|
+
- Dockerfile.features
|
87
|
+
- Dockerfile.rspec
|
88
|
+
- Gemfile
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- config/config.ci.dynamo_db.yml
|
92
|
+
- config/config.ci.ldap.yml
|
93
|
+
- config/config.ci.mysql.yml
|
94
|
+
- config/config.dynamo_db.yml
|
95
|
+
- config/config.ldap.yml
|
96
|
+
- config/config.mysql.yml
|
97
|
+
- docker-compose.ci.customer_client_number.yml
|
98
|
+
- docker-compose.ci.customer_email.yml
|
99
|
+
- docker-compose.ci.factory.yml
|
100
|
+
- docker-compose.ci.role_generator.yml
|
101
|
+
- docker-compose.ci.staff.yml
|
102
|
+
- docker-compose.customer.yml
|
103
|
+
- docker-compose.dynamo_db.yml
|
104
|
+
- docker-compose.staff.yml
|
105
|
+
- lib/soar/authentication/identity_uuid_translator.rb
|
106
|
+
- lib/soar/authentication/identity_uuid_translator/error.rb
|
107
|
+
- lib/soar/authentication/identity_uuid_translator/factory.rb
|
108
|
+
- lib/soar/authentication/identity_uuid_translator/model.rb
|
109
|
+
- lib/soar/authentication/identity_uuid_translator/provider/customer.rb
|
110
|
+
- lib/soar/authentication/identity_uuid_translator/provider/staff.rb
|
111
|
+
- lib/soar/authentication/identity_uuid_translator/role_generator.rb
|
112
|
+
- lib/soar/authentication/identity_uuid_translator/test/fixtures/client_table.sql
|
113
|
+
- lib/soar/authentication/identity_uuid_translator/test/fixtures/roles_table.json
|
114
|
+
- lib/soar/authentication/identity_uuid_translator/test/fixtures/staff.json
|
115
|
+
- lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/base.rb
|
116
|
+
- lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/customer.rb
|
117
|
+
- lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/customer_client_number.rb
|
118
|
+
- lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/customer_email.rb
|
119
|
+
- lib/soar/authentication/identity_uuid_translator/test/orchestration_provider/staff.rb
|
120
|
+
- lib/soar/authentication/identity_uuid_translator/test/orchestrator.rb
|
121
|
+
- lib/soar/authentication/identity_uuid_translator/uuid_generator.rb
|
122
|
+
homepage: https://github.com/hetznerZA/soar-authentication-identity
|
123
|
+
licenses: []
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.5.1
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Translate an identifier into a UUID
|
145
|
+
test_files: []
|