soar-authentication-identity 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 921b00f418350cbcf3502a43b74e2092060ef9e9
4
+ data.tar.gz: bc6ed7553575ff5d8a46eda43d0bfd9f65794bc7
5
+ SHA512:
6
+ metadata.gz: 6d1af45bee7f55541161938a3f85bc07ba9464b18b7510af40c7bc5f63ab287af0fc1423eaa3f295ffcd1ae78ff48ec3c9facab9df1672ea76be9cfd196622b2
7
+ data.tar.gz: a74b19be7d9060c72aedad3ca20a1ef3922120d5ac34713a900071c4ec5559a5df2e7dee31178f696ead0df3961d33cb5ac75cc3808af6c8e44f9a64db2e7783
data/.gemspec ADDED
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "soar-authentication-identity"
3
+ spec.version = "0.0.1"
4
+ spec.authors = ["Charles Mulder"]
5
+ spec.email = ["charles.mulder@hetzner.co.za"]
6
+
7
+ spec.summary = %q{ Translate an identifier into a UUID}
8
+ spec.homepage = "https://github.com/hetznerZA/soar-authentication-identity"
9
+
10
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
11
+ spec.require_paths = ["lib"]
12
+
13
+ spec.add_runtime_dependency 'soar-registry-identity', '~> 1.0'
14
+ spec.add_runtime_dependency 'soar-registry-directory', '~> 1.0'
15
+ end
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.swp
2
+ *.swo
3
+ # Used by dotenv library to load environment variables.
4
+ # .env
5
+
6
+ ## Documentation cache and generated files:
7
+ /.yardoc/
8
+ /_yardoc/
9
+ /doc/
10
+ /rdoc/
11
+
12
+ ## Environment normalization:
13
+ /.bundle/
14
+ /vendor/bundle
15
+ /lib/bundler/man/
16
+
17
+ # for a library or gem, you might want to ignore these files since the code is
18
+ # intended to run in multiple environments; otherwise, check them in:
19
+ # Gemfile.lock
20
+ .ruby-version
21
+ .ruby-gemset
22
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ soar-authentication-identity
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/Dockerfile ADDED
@@ -0,0 +1,7 @@
1
+ FROM ruby:2.3
2
+ WORKDIR /usr/local/src
3
+ ADD Gemfile .gemspec /usr/local/src/
4
+ RUN bundle install --without development --with test
5
+ ADD . /usr/local/src/
6
+ CMD bundle exec cucumber
7
+
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in soar-uuid.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'cucumber', '~> 2.4'
8
+ gem 'rspec-expectations', '~> 3.5'
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ soar-authentication-identity (0.0.0)
5
+ soar-registry-directory (~> 1.0)
6
+ soar-registry-identity (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (3.2.22.5)
12
+ activesupport (= 3.2.22.5)
13
+ builder (~> 3.0.0)
14
+ activesupport (3.2.22.5)
15
+ i18n (~> 0.6, >= 0.6.4)
16
+ multi_json (~> 1.0)
17
+ aws-sdk (2.6.32)
18
+ aws-sdk-resources (= 2.6.32)
19
+ aws-sdk-core (2.6.32)
20
+ aws-sigv4 (~> 1.0)
21
+ jmespath (~> 1.0)
22
+ aws-sdk-resources (2.6.32)
23
+ aws-sdk-core (= 2.6.32)
24
+ aws-sigv4 (1.0.0)
25
+ builder (3.0.4)
26
+ cucumber (2.4.0)
27
+ builder (>= 2.1.2)
28
+ cucumber-core (~> 1.5.0)
29
+ cucumber-wire (~> 0.0.1)
30
+ diff-lcs (>= 1.1.3)
31
+ gherkin (~> 4.0)
32
+ multi_json (>= 1.7.5, < 2.0)
33
+ multi_test (>= 0.1.2)
34
+ cucumber-core (1.5.0)
35
+ gherkin (~> 4.0)
36
+ cucumber-wire (0.0.1)
37
+ diff-lcs (1.2.5)
38
+ gherkin (4.0.0)
39
+ hashie (3.4.6)
40
+ hashy_db (2.1.0)
41
+ i18n (0.7.0)
42
+ jmespath (1.3.1)
43
+ jsender (0.2.2)
44
+ mince (2.3.0)
45
+ activemodel (~> 3.0)
46
+ activesupport (~> 3.0)
47
+ multi_json (1.12.1)
48
+ multi_test (0.1.2)
49
+ rspec-expectations (3.5.0)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.5.0)
52
+ rspec-support (3.5.0)
53
+ soar-registry-directory (1.0.0)
54
+ aws-sdk (~> 2.6, >= 2.6.6)
55
+ aws-sdk-core (~> 2.6, >= 2.6.28)
56
+ hashie (~> 3.4, >= 3.4.6)
57
+ hashy_db (~> 2.1)
58
+ mince (~> 2.3)
59
+ soar-registry-identity (1.0.0)
60
+ soar-registry-directory (~> 1.0.0)
61
+ soar_idm (~> 0.0.2)
62
+ soar_idm (0.0.2)
63
+ jsender
64
+
65
+ PLATFORMS
66
+ ruby
67
+
68
+ DEPENDENCIES
69
+ cucumber (~> 2.4)
70
+ rspec-expectations (~> 3.5)
71
+ soar-authentication-identity!
72
+
73
+ BUNDLED WITH
74
+ 1.13.6
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # soar-authentication-identity
2
+ Used by authentication service to translate an identity identifier into an UUID
3
+
4
+ [Domain analysis](https://docs.google.com/a/hetzner.co.za/drawings/d/1b50Ml3PLQd25SYxKIiaZ7sIUxHwXx2c0muBZauYDnwA/edit?usp=sharing)
5
+
6
+ ## Quickstart
7
+
8
+ ### Staff identity provider
9
+ ```ruby
10
+ > identity = Soar::Authentication::Identity::Factory.create(authenticated_identifier: 'staff@hetzner.co.za')
11
+ > puts identity.uuid
12
+ "85777bfa-b743-4ba9-8308-e8a1e4d44fbe"
13
+ ```
14
+
15
+ ## Tests
16
+
17
+ ### Local
18
+
19
+ #### Stub identity provider
20
+ ```bash
21
+ $ TEST_ORCHESTRATION_PROVIDER=Stub cucumber
22
+ ```
23
+
24
+ #### Staff identity provider
25
+ ```bash
26
+ $ TEST_ORCHESTRATION_PROVIDER=Staff cucumber
27
+ ```
28
+
29
+ #### Customer identity provider
30
+ Not implemented
31
+
32
+ #### Domain identity provider
33
+ Not implemented
34
+
35
+ ### CI
36
+
37
+ #### Stub identity provider
38
+ ```bash
39
+ docker-compose --file docker-compose.stub.yml up --abort-on-container-exit --remove-orphans
40
+ EXIT_CODE=$(docker ps -a -f "name=soar-authentication-identity-provider-stub" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
41
+ exit $EXIT_CODE;
42
+ ```
43
+
44
+ #### Staff identity provider
45
+ ```bash
46
+ docker-compose --file docker-compose.staff.yml up --abort-on-container-exit --remove-orphans
47
+ EXIT_CODE=$(docker ps -a -f "name=soar-authentication-identity-provider-staff" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
48
+ exit $EXIT_CODE;
49
+ ```
50
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ task :default => :test
2
+
3
+ task :test do
4
+ Rake::Task['rspec'].execute
5
+ Rake::Task['cucumber'].execute
6
+ end
7
+
8
+ task :rspec do
9
+ `rspec`
10
+ end
11
+
12
+ task :cucumber do
13
+ `cucumber`
14
+ end
data/config/config.yml ADDED
@@ -0,0 +1,7 @@
1
+ provider:
2
+ class: 'Soar::Registry::Staff::Directory::Stub'
3
+ config:
4
+ endpoint: 'stub'
5
+ credentials:
6
+ username: 'username'
7
+ password: 'secret'
@@ -0,0 +1,13 @@
1
+ version: "2"
2
+ services:
3
+ tests:
4
+ build:
5
+ context: .
6
+ image: soar-authentication-identity-provider-staff
7
+ container_name: soar-authentication-identity-provider-staff
8
+ environment:
9
+ - TEST_ORCHESTRATION_PROVIDER=Staff
10
+
11
+
12
+
13
+
@@ -0,0 +1,13 @@
1
+ version: "2"
2
+ services:
3
+ tests:
4
+ build:
5
+ context: .
6
+ image: soar-authentication-identity-provider-stub
7
+ container_name: soar-authentication-identity-provider-stub
8
+ environment:
9
+ - TEST_ORCHESTRATION_PROVIDER=Stub
10
+
11
+
12
+
13
+
@@ -0,0 +1,13 @@
1
+
2
+ module Soar
3
+ module Authentication
4
+ module Identity
5
+ module Error
6
+ class UnknownIdentityError < StandardError
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+
@@ -0,0 +1,41 @@
1
+ require 'soar/authentication/identity'
2
+
3
+ module Soar
4
+ module Authentication
5
+ module Identity
6
+ module Factory
7
+
8
+ ##
9
+ # @param authenticated_identifier [String]
10
+ # @raise [ArgumentError]
11
+ # @return [Soar::Authentication::Identity::Model]
12
+ ##
13
+ def self.create(directory: nil, authenticated_identifier: nil)
14
+ raise ArgumentError if authenticated_identifier.nil? or directory.nil?
15
+ provider = get_provider(directory, authenticated_identifier)
16
+ Soar::Authentication::Identity.new(provider)
17
+ end
18
+
19
+ private
20
+
21
+ def self.get_provider(directory, authenticated_identifier)
22
+ case authenticated_identifier
23
+ when /@hetzner.co.za\z/
24
+ Soar::Authentication::Identity::Provider::Staff.new({
25
+ directory: directory,
26
+ authenticated_identifier: authenticated_identifier
27
+ })
28
+ when /D\d*$/
29
+ raise NotImplementedError, 'Domain identities require an implementation'
30
+ when /^[CF]{0,1}\d*$/
31
+ raise NotImplementedError, 'Customer identities require an implementation'
32
+ else
33
+ raise Soar::Authentication::Identity::Error::UnknownIdentityError, 'Unknown identity'
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,21 @@
1
+ require 'soar/authentication/identity/error'
2
+ require 'soar/authentication/identity/provider/staff'
3
+ require 'soar/authentication/identity/provider/stub'
4
+
5
+ module Soar
6
+ module Authentication
7
+ module Identity
8
+ class Model
9
+
10
+ def initialize(provider)
11
+ @provider = provider
12
+ end
13
+
14
+ def uuid
15
+ @provider.uuid
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ require 'soar/registry/identity'
2
+
3
+ module Soar
4
+ module Authentication
5
+ module Identity
6
+ module Provider
7
+ class Staff
8
+
9
+ def initialize(directory: nil, authenticated_identifier: nil)
10
+ @directory = directory
11
+ identity_provider = Soar::Registry::Identity::Provider::Staff::Email.new(directory: @directory)
12
+ identity_registry = Soar::Registry::Identity.new(identity_provider)
13
+ @attributes = identity_registry.get_attributes(authenticated_identifier)
14
+ end
15
+
16
+ def uuid
17
+ primary_key = @directory.index[0]
18
+ @attributes[primary_key]
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ require 'soar/registry/identity'
2
+
3
+ module Soar
4
+ module Authentication
5
+ module Identity
6
+ module Provider
7
+ class Stub
8
+
9
+ def initialize(directory: nil, authenticated_identifier: nil)
10
+ @directory = directory
11
+ @entries = @directory.search("identifier", authenticated_identifier)
12
+ end
13
+
14
+ def uuid
15
+ primary_key = @directory.index[0]
16
+ @entries[0][primary_key]
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,65 @@
1
+ require 'soar/authentication/identity/factory'
2
+ require 'soar/registry/directory'
3
+ require 'securerandom'
4
+
5
+ module Soar
6
+ module Authentication
7
+ module Identity
8
+ module Test
9
+ module OrchestrationProvider
10
+ class Staff
11
+
12
+ def initialize()
13
+ directory_provider = Soar::Registry::Directory::Provider::Stub.new({
14
+ table: "mytable",
15
+ primary_key: "uuid",
16
+ index: ["uuid", "email"]
17
+ })
18
+ @directory = Soar::Registry::Directory.new(directory_provider)
19
+
20
+ end
21
+
22
+ ##
23
+ # @return [Nil]
24
+ ##
25
+ def given_existing_identity
26
+
27
+ @entry = {
28
+ "uuid" => SecureRandom.uuid,
29
+ "email" => 'test@hetzner.co.za'
30
+ }
31
+
32
+ @directory.put(@entry)
33
+
34
+ end
35
+
36
+ ##
37
+ # @return [Nil]
38
+ ##
39
+ def given_authenticated_identifier
40
+ @identity = Soar::Authentication::Identity::Factory.create({
41
+ directory: @directory,
42
+ authenticated_identifier: @entry["email"]
43
+ })
44
+ end
45
+
46
+ ##
47
+ # @return [Nil]
48
+ ##
49
+ def request_uuid
50
+ @identity.uuid
51
+ end
52
+
53
+ ##
54
+ # @return [Boolean]
55
+ ##
56
+ def uuid?
57
+ @entry["uuid"] == @identity.uuid
58
+ end
59
+
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,64 @@
1
+ require 'soar/registry/directory'
2
+ require 'soar/authentication/identity'
3
+ require 'securerandom'
4
+
5
+ module Soar
6
+ module Authentication
7
+ module Identity
8
+ module Test
9
+ module OrchestrationProvider
10
+ class Stub
11
+
12
+ def initialize()
13
+ directory_provider = Soar::Registry::Directory::Provider::Stub.new({
14
+ table: "mytable",
15
+ primary_key: "uuid",
16
+ index: ["uuid", "identifier"]
17
+ })
18
+ @directory = Soar::Registry::Directory.new(directory_provider)
19
+ end
20
+
21
+ ##
22
+ # @return [Nil]
23
+ ##
24
+ def given_existing_identity
25
+
26
+ @entry = {
27
+ "uuid" => SecureRandom.uuid,
28
+ "identifier" => 'test@hetzner.co.za'
29
+ }
30
+
31
+ @directory.put(@entry)
32
+ end
33
+
34
+ ##
35
+ # @return [Nil]
36
+ ##
37
+ def given_authenticated_identifier
38
+ identity_provider = Soar::Authentication::Identity::Provider::Stub.new({
39
+ directory: @directory,
40
+ authenticated_identifier: @entry['identifier']
41
+ })
42
+ @identity = Soar::Authentication::Identity::new(identity_provider)
43
+ end
44
+
45
+ ##
46
+ # @return [Nil]
47
+ ##
48
+ def request_uuid
49
+ @identity.uuid
50
+ end
51
+
52
+ ##
53
+ # @return [Boolean]
54
+ ##
55
+ def uuid?
56
+ @entry["uuid"] == @identity.uuid
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,45 @@
1
+ require 'securerandom'
2
+
3
+ module Soar
4
+ module Authentication
5
+ module Identity
6
+ module Test
7
+ class Orchestrator
8
+
9
+ def initialize(provider)
10
+ @provider = provider
11
+ end
12
+
13
+ ##
14
+ # @return [Nil]
15
+ ##
16
+ def given_existing_identity
17
+ @provider.given_existing_identity
18
+ end
19
+
20
+ ##
21
+ # @return [Nil]
22
+ ##
23
+ def given_authenticated_identifier
24
+ @provider.given_authenticated_identifier
25
+ end
26
+
27
+ ##
28
+ # @return [Nil]
29
+ ##
30
+ def request_uuid
31
+ @provider.request_uuid
32
+ end
33
+
34
+ ##
35
+ # @return [Boolean]
36
+ ##
37
+ def uuid?
38
+ @provider.uuid?
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,14 @@
1
+ require 'soar/authentication/identity/model'
2
+ require 'soar/authentication/identity/error'
3
+
4
+ module Soar
5
+ module Authentication
6
+ module Identity
7
+
8
+ def self.new(provider)
9
+ Soar::Authentication::Identity::Model.new(provider)
10
+ end
11
+
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soar-authentication-identity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Charles Mulder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-02 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: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: soar-registry-directory
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description:
42
+ email:
43
+ - charles.mulder@hetzner.co.za
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gemspec"
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".ruby-gemset"
52
+ - ".ruby-version"
53
+ - Dockerfile
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - README.md
57
+ - Rakefile
58
+ - config/config.yml
59
+ - docker-compose.staff.yml
60
+ - docker-compose.stub.yml
61
+ - lib/soar/authentication/identity.rb
62
+ - lib/soar/authentication/identity/error.rb
63
+ - lib/soar/authentication/identity/factory.rb
64
+ - lib/soar/authentication/identity/model.rb
65
+ - lib/soar/authentication/identity/provider/staff.rb
66
+ - lib/soar/authentication/identity/provider/stub.rb
67
+ - lib/soar/authentication/identity/test/orchestration_provider/staff.rb
68
+ - lib/soar/authentication/identity/test/orchestration_provider/stub.rb
69
+ - lib/soar/authentication/identity/test/orchestrator.rb
70
+ homepage: https://github.com/hetznerZA/soar-authentication-identity
71
+ licenses: []
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.5.1
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Translate an identifier into a UUID
93
+ test_files: []