soar-authentication-identity 0.0.1 → 0.0.2
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 +4 -4
- data/.gemspec +1 -1
- data/.gitignore +2 -0
- data/Dockerfile +1 -1
- data/Gemfile +1 -1
- data/README.md +22 -1
- data/lib/soar/authentication/identity/error.rb +1 -3
- data/lib/soar/authentication/identity/factory.rb +26 -7
- data/lib/soar/authentication/identity/model.rb +6 -0
- data/lib/soar/authentication/identity/provider/staff.rb +6 -3
- data/lib/soar/authentication/identity/provider/stub.rb +2 -0
- data/lib/soar/authentication/identity/test/orchestration_provider/staff.rb +21 -20
- data/lib/soar/authentication/identity.rb +1 -0
- metadata +2 -4
- data/Gemfile.lock +0 -74
- data/config/config.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8914d86bf3c5ca1985aef4f44b3a9350d6d3d5
|
4
|
+
data.tar.gz: db528744d5b6cffd9cd4184138eb4c80ef20f73f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5475f3261b034b1eeac56233f669c4a8162db6e162b541b8fd4297cc71486cd122992f11fc0bf79c4d7b71d88d90f54623d79595ab4c7ec8142722ae453f392d
|
7
|
+
data.tar.gz: 942a55d59f9b2fce174699c6cd44d7d71278a9a5e01973843c6cde062be9d1b3c6aaf042dd34b4b427efc6fe0dc9b9357a8875ffc38ee87bf2a7e2ff2032a62d
|
data/.gemspec
CHANGED
data/.gitignore
CHANGED
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,8 +6,24 @@ Used by authentication service to translate an identity identifier into an UUID
|
|
6
6
|
## Quickstart
|
7
7
|
|
8
8
|
### Staff identity provider
|
9
|
+
|
10
|
+
Example using the factory.
|
9
11
|
```ruby
|
10
|
-
> identity = Soar::Authentication::Identity::Factory.create(
|
12
|
+
> identity = Soar::Authentication::Identity::Factory.create({
|
13
|
+
authenticated_identifier: 'the authenticated identifier goes here',
|
14
|
+
directory_configurations: {
|
15
|
+
"staff" => {
|
16
|
+
"provider" => 'Soar::Registry::Directory::Provider::Stub',
|
17
|
+
"config" => {
|
18
|
+
"table" => "identity",
|
19
|
+
"primary_key" =>"uuid",
|
20
|
+
"index" => ["uuid", "email"]
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"customer" => {},
|
24
|
+
"domain" => {}
|
25
|
+
}
|
26
|
+
})
|
11
27
|
> puts identity.uuid
|
12
28
|
"85777bfa-b743-4ba9-8308-e8a1e4d44fbe"
|
13
29
|
```
|
@@ -16,6 +32,11 @@ Used by authentication service to translate an identity identifier into an UUID
|
|
16
32
|
|
17
33
|
### Local
|
18
34
|
|
35
|
+
#### Identity factory
|
36
|
+
```bash
|
37
|
+
$ bundle exec rspec
|
38
|
+
```
|
39
|
+
|
19
40
|
#### Stub identity provider
|
20
41
|
```bash
|
21
42
|
$ TEST_ORCHESTRATION_PROVIDER=Stub cucumber
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'soar/authentication/identity'
|
2
|
+
require 'soar/registry/directory'
|
2
3
|
|
3
4
|
module Soar
|
4
5
|
module Authentication
|
@@ -6,23 +7,41 @@ module Soar
|
|
6
7
|
module Factory
|
7
8
|
|
8
9
|
##
|
10
|
+
# @param directory_configurations [Hash]
|
9
11
|
# @param authenticated_identifier [String]
|
12
|
+
# @return [Soar::Authentication::Identity]
|
10
13
|
# @raise [ArgumentError]
|
11
|
-
# @return [Soar::Authentication::Identity::Model]
|
12
14
|
##
|
13
|
-
def self.create(
|
14
|
-
raise ArgumentError
|
15
|
-
|
15
|
+
def self.create(directory_configurations: nil, authenticated_identifier: nil)
|
16
|
+
raise ArgumentError, 'Missing required directory configuration' if directory_configurations.nil?
|
17
|
+
raise ArgumentError, 'Missing required authenticated identifier' if authenticated_identifier.nil?
|
18
|
+
provider = get_provider(directory_configurations, authenticated_identifier)
|
16
19
|
Soar::Authentication::Identity.new(provider)
|
17
20
|
end
|
18
21
|
|
19
|
-
private
|
22
|
+
private
|
23
|
+
|
24
|
+
##
|
25
|
+
# @param identity [String]
|
26
|
+
# @return [Soar::Registry::Directory]
|
27
|
+
# @raise [KeyError] if config is missing provider and config keys
|
28
|
+
##
|
29
|
+
def self.get_directory(config)
|
30
|
+
provider_class = Object.const_get(config.fetch('provider'))
|
31
|
+
provider = provider_class.new(config.fetch('config').symbolize_keys)
|
32
|
+
Soar::Registry::Directory.new(provider)
|
33
|
+
end
|
20
34
|
|
21
|
-
|
35
|
+
##
|
36
|
+
# @param authenticated_identifier [String]
|
37
|
+
# @raise [Soar::Authentication::Identity::Error::UnknownIdentityError, KeyError]
|
38
|
+
# @return [Soar::Authentication::Identity::Provider]
|
39
|
+
##
|
40
|
+
def self.get_provider(directory_configurations, authenticated_identifier)
|
22
41
|
case authenticated_identifier
|
23
42
|
when /@hetzner.co.za\z/
|
24
43
|
Soar::Authentication::Identity::Provider::Staff.new({
|
25
|
-
directory:
|
44
|
+
directory: get_directory(directory_configurations.fetch('staff')),
|
26
45
|
authenticated_identifier: authenticated_identifier
|
27
46
|
})
|
28
47
|
when /D\d*$/
|
@@ -6,6 +6,8 @@ module Soar
|
|
6
6
|
module Authentication
|
7
7
|
module Identity
|
8
8
|
class Model
|
9
|
+
|
10
|
+
attr_reader :provider
|
9
11
|
|
10
12
|
def initialize(provider)
|
11
13
|
@provider = provider
|
@@ -15,6 +17,10 @@ module Soar
|
|
15
17
|
@provider.uuid
|
16
18
|
end
|
17
19
|
|
20
|
+
def directory
|
21
|
+
@provider.directory
|
22
|
+
end
|
23
|
+
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
@@ -6,16 +6,19 @@ module Soar
|
|
6
6
|
module Provider
|
7
7
|
class Staff
|
8
8
|
|
9
|
+
attr_reader :directory
|
10
|
+
|
9
11
|
def initialize(directory: nil, authenticated_identifier: nil)
|
10
12
|
@directory = directory
|
13
|
+
@authenticated_identifier = authenticated_identifier
|
11
14
|
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)
|
15
|
+
@identity_registry = Soar::Registry::Identity.new(identity_provider)
|
14
16
|
end
|
15
17
|
|
16
18
|
def uuid
|
19
|
+
attributes = @identity_registry.get_attributes(@authenticated_identifier)
|
17
20
|
primary_key = @directory.index[0]
|
18
|
-
|
21
|
+
attributes[primary_key]
|
19
22
|
end
|
20
23
|
|
21
24
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'soar/authentication/identity/factory'
|
2
|
-
require 'soar/registry/directory'
|
3
2
|
require 'securerandom'
|
4
3
|
|
5
4
|
module Soar
|
@@ -9,38 +8,40 @@ module Soar
|
|
9
8
|
module OrchestrationProvider
|
10
9
|
class Staff
|
11
10
|
|
12
|
-
def initialize
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def initialize
|
12
|
+
@entry = {
|
13
|
+
"uuid" => SecureRandom.uuid,
|
14
|
+
"email" => 'test@hetzner.co.za'
|
15
|
+
}
|
16
|
+
@identity = Soar::Authentication::Identity::Factory.create({
|
17
|
+
authenticated_identifier: @entry["email"],
|
18
|
+
directory_configurations: {
|
19
|
+
"staff" => {
|
20
|
+
"provider" => 'Soar::Registry::Directory::Provider::Stub',
|
21
|
+
"config" => {
|
22
|
+
"table" => "identity",
|
23
|
+
"primary_key" =>"uuid",
|
24
|
+
"index" => ["uuid", "email"]
|
25
|
+
}
|
26
|
+
},
|
27
|
+
"customer" => {},
|
28
|
+
"domain" => {}
|
29
|
+
}
|
17
30
|
})
|
18
|
-
@directory = Soar::Registry::Directory.new(directory_provider)
|
19
|
-
|
20
31
|
end
|
21
32
|
|
22
33
|
##
|
23
34
|
# @return [Nil]
|
24
35
|
##
|
25
36
|
def given_existing_identity
|
26
|
-
|
27
|
-
@entry = {
|
28
|
-
"uuid" => SecureRandom.uuid,
|
29
|
-
"email" => 'test@hetzner.co.za'
|
30
|
-
}
|
31
|
-
|
32
|
-
@directory.put(@entry)
|
33
|
-
|
37
|
+
@identity.directory.put(@entry)
|
34
38
|
end
|
35
39
|
|
36
40
|
##
|
37
41
|
# @return [Nil]
|
38
42
|
##
|
39
43
|
def given_authenticated_identifier
|
40
|
-
@
|
41
|
-
directory: @directory,
|
42
|
-
authenticated_identifier: @entry["email"]
|
43
|
-
})
|
44
|
+
@entry["email"]
|
44
45
|
end
|
45
46
|
|
46
47
|
##
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soar-authentication-identity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Mulder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: soar-registry-identity
|
@@ -52,10 +52,8 @@ files:
|
|
52
52
|
- ".ruby-version"
|
53
53
|
- Dockerfile
|
54
54
|
- Gemfile
|
55
|
-
- Gemfile.lock
|
56
55
|
- README.md
|
57
56
|
- Rakefile
|
58
|
-
- config/config.yml
|
59
57
|
- docker-compose.staff.yml
|
60
58
|
- docker-compose.stub.yml
|
61
59
|
- lib/soar/authentication/identity.rb
|
data/Gemfile.lock
DELETED
@@ -1,74 +0,0 @@
|
|
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
|