soar-registry-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 +7 -0
- data/README.md +126 -0
- data/lib/soar/registry/identity.rb +11 -0
- data/lib/soar/registry/identity/model.rb +26 -0
- data/lib/soar/registry/identity/provider/staff/base.rb +75 -0
- data/lib/soar/registry/identity/provider/staff/email.rb +24 -0
- data/lib/soar/registry/identity/provider/staff/id.rb +23 -0
- data/lib/soar/registry/identity/provider/staff/translator/default.rb +31 -0
- data/lib/soar/registry/identity/test/fixtures/entries.json +60 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 484df2d3ddb8d8e2b5438fbad4b64f5082cbdf2b
|
4
|
+
data.tar.gz: 0115319b3e7636d6e5bd6cdf7eace3975dbadfdb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 015afb53bd02703e74b64e9ae518f60267eefa7c3965b0ad6a37505767c1240d2ab18bb92726af2775fbad2053299944e6dcfc145d284604fc351bcae8ac883b
|
7
|
+
data.tar.gz: 5ba3a6752b13b05e30888b6c3ef9967863e0c3db21f222a219924c9e433c64c6a6478e17bb4f6f503f3972eb2cdb4d899c84d1a4279a247dbb8f167061eee6af
|
data/README.md
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# Registry of identities
|
2
|
+
|
3
|
+
## Quickstart
|
4
|
+
|
5
|
+
### Directory
|
6
|
+
Create a directory provider
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
require 'soar/registry/directory'
|
10
|
+
directory_provider = Soar::Registry::Directory::Provider::Stub.new
|
11
|
+
```
|
12
|
+
|
13
|
+
Create a directory
|
14
|
+
```ruby
|
15
|
+
directory = Soar::Registry::Directory.new({
|
16
|
+
provider: directory_provider
|
17
|
+
})
|
18
|
+
```
|
19
|
+
|
20
|
+
### Staff UUID IDR
|
21
|
+
Search for staff by UUID.
|
22
|
+
|
23
|
+
Create an identity provider. (Remember to pass in the directory)
|
24
|
+
```ruby
|
25
|
+
require 'soar/registry/identity'
|
26
|
+
identity_provider = Soar::Registry::Identity::Provider::Staff::Id.new(directory)
|
27
|
+
```
|
28
|
+
|
29
|
+
Create an IDR
|
30
|
+
```ruby
|
31
|
+
@id_idr = Soar::Registry::Identity.new(provider: identity_provider)
|
32
|
+
```
|
33
|
+
|
34
|
+
### Staff Email IDR
|
35
|
+
Search for staff by email address. (Remember to pass in the directory)
|
36
|
+
```ruby
|
37
|
+
require 'soar/registry/identity'
|
38
|
+
identity_provider = Soar::Registry::Identity::Provider::Staff::Email.new(directory)
|
39
|
+
```
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
@email_idr = Soar::Registry::Identity.new(provider: identity_provider)
|
43
|
+
```
|
44
|
+
|
45
|
+
### Getting a list of identifiers
|
46
|
+
```ruby
|
47
|
+
> identifiers = @id_idr.get_identifiers("identity-820d5660-2204-4f7d-8c04-746313439b81")
|
48
|
+
> identifiers = @email_idr.get_identifiers("admin@hetzner.co.za")
|
49
|
+
> puts identifiers.inspect
|
50
|
+
["admin@hetzner.co.za", "identity-820d5660-2204-4f7d-8c04-746313439b81"]
|
51
|
+
```
|
52
|
+
|
53
|
+
### Getting a list of roles
|
54
|
+
```ruby
|
55
|
+
> roles = @id_idr.get_roles("identity-820d5660-2204-4f7d-8c04-746313439b81")
|
56
|
+
> roles = @email_idr.get_roles("admin@hetzner.co.za")
|
57
|
+
> puts roles.inspect
|
58
|
+
["staff", "configuration_publisher", "configuration_consumer"]
|
59
|
+
```
|
60
|
+
|
61
|
+
### Getting a hash of attributes for a role
|
62
|
+
```ruby
|
63
|
+
> role = 'staff'
|
64
|
+
> attributes = @id_idr.get_attributes("identity-820d5660-2204-4f7d-8c04-746313439b81", role)
|
65
|
+
> attributes = @email_idr.get_attributes("admin@hetzner.co.za", role)
|
66
|
+
> puts attributes.inspect
|
67
|
+
{
|
68
|
+
"staff": {
|
69
|
+
"department": "technical"
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
### Getting a hash of all attributes
|
76
|
+
```ruby
|
77
|
+
> attributes = @id_idr.get_attributes("identity-820d5660-2204-4f7d-8c04-746313439b81")
|
78
|
+
> attributes = @email_idr.get_attributes("admin@hetzner.co.za")
|
79
|
+
> puts attributes.inspect
|
80
|
+
{
|
81
|
+
"identity_id" => "identity-820d5660-2204-4f7d-8c04-746313439b81",
|
82
|
+
"entity_id"=> "entity-bad85eb9-0713-4da7-8d36-07a8e4b00eab",
|
83
|
+
"email"=> "admin@hetzner.co.za",
|
84
|
+
"roles"=> {
|
85
|
+
"staff"=> {},
|
86
|
+
"configuration_publisher"=> {
|
87
|
+
"configuration_identifiers"=> ["*"]
|
88
|
+
},
|
89
|
+
"configuration_consumer"=> {
|
90
|
+
"configuration_identifiers"=> ["*"]
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"address"=> {
|
94
|
+
"detail"=> "Belvedere Office Park, Unit F",
|
95
|
+
"street"=> "Bella Rosa Street",
|
96
|
+
"suburb"=> "Tygervalley",
|
97
|
+
"city"=> "Durbanville",
|
98
|
+
"postal"=> "7550"
|
99
|
+
}
|
100
|
+
}
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
## Tests
|
105
|
+
|
106
|
+
### Local
|
107
|
+
```bash
|
108
|
+
$ bundle exec rspec
|
109
|
+
```
|
110
|
+
|
111
|
+
### CI
|
112
|
+
```bash
|
113
|
+
docker-compose --file docker-compose.ci.yml up --abort-on-container-exit --remove-orphans --build --force-recreate
|
114
|
+
EXIT_CODE=$(docker ps -a -f "name=soar-registry-identity-provider-staff" -q | xargs docker inspect -f "{{ .State.ExitCode }}");
|
115
|
+
exit $EXIT_CODE;
|
116
|
+
```
|
117
|
+
|
118
|
+
## Resources
|
119
|
+
* [DynamoDBLocal](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html)
|
120
|
+
* [Multiple AWS Credentials](https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs)
|
121
|
+
* [AWS SDK for Ruby](http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.Ruby.html)
|
122
|
+
|
123
|
+
## References
|
124
|
+
* [soar idm](https://github.hetzner.co.za/hetznerZA/soar_idm/blob/master/lib/soar_idm/soar_idm.rb)
|
125
|
+
* [Domain analysis](https://docs.google.com/a/hetzner.co.za/drawings/d/1vGdzjKPD3gzn1e0bsC4liFCyxY31Qjjxe3y41beVBzw/edit?usp=sharing)
|
126
|
+
* [staff idr](https://github.hetzner.co.za/hetznerZA/idr_staff/blob/master/idr_staff/lib/idr_staff/staff_idr.rb)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'soar/registry/identity/provider/staff/email'
|
2
|
+
require 'soar/registry/identity/provider/staff/id'
|
3
|
+
|
4
|
+
module Soar
|
5
|
+
module Registry
|
6
|
+
module Identity
|
7
|
+
class Model
|
8
|
+
def initialize(provider: nil)
|
9
|
+
@provider = provider
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_roles(identifier)
|
13
|
+
@provider.get_roles(identifier)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_attributes(identifier, role = nil)
|
17
|
+
@provider.get_attributes(identifier, role)
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_identifiers(identifier)
|
21
|
+
@provider.get_identifiers(identifier)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'soar_idm/soar_idm'
|
2
|
+
require 'soar/registry/identity/provider/staff/translator/default'
|
3
|
+
|
4
|
+
module Soar
|
5
|
+
module Registry
|
6
|
+
module Identity
|
7
|
+
module Provider
|
8
|
+
module Staff
|
9
|
+
class Base < SoarIdm::IdmApi
|
10
|
+
|
11
|
+
attr_reader :directory
|
12
|
+
attr_reader :translator
|
13
|
+
|
14
|
+
##
|
15
|
+
# @param [Hash] configuration
|
16
|
+
##
|
17
|
+
def initialize(directory)
|
18
|
+
@translator = Soar::Registry::Identity::Provider::Staff::Translator::Default.new
|
19
|
+
@directory = directory
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @param [Hash] identity
|
24
|
+
# @return [Array] list of roles
|
25
|
+
def calculate_roles(identity)
|
26
|
+
entry = @directory.fetch(identity[@directory.index[0]])
|
27
|
+
return nil if not entry
|
28
|
+
identity = @translator.get_identity(entry)
|
29
|
+
roles = []
|
30
|
+
identity['roles'].each do |role, attributes|
|
31
|
+
roles << role
|
32
|
+
end
|
33
|
+
roles
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# @param [Hash] identity
|
38
|
+
# @return [Array] list of identifiers
|
39
|
+
##
|
40
|
+
def calculate_identifiers(identity)
|
41
|
+
indexes = @directory.index
|
42
|
+
entry = @directory.fetch(identity[@directory.index[0]])
|
43
|
+
identity = @translator.get_identity(entry)
|
44
|
+
identifiers = []
|
45
|
+
indexes.each { |index|
|
46
|
+
identifiers << identity[index]
|
47
|
+
}
|
48
|
+
identifiers
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# @param [Hash] identity
|
53
|
+
# @param [String] role
|
54
|
+
# @return [Hash] A hash of attributes
|
55
|
+
def calculate_attributes(identity, role)
|
56
|
+
entry = @directory.fetch(identity[@directory.index[0]])
|
57
|
+
return nil if not entry
|
58
|
+
identity = @translator.get_identity(entry)
|
59
|
+
{ role => identity['roles'][role] }
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# @param [Hash] identity
|
64
|
+
# @return [Hash] Hash of attributes keyed by role
|
65
|
+
def calculate_all_attributes(identity)
|
66
|
+
entry = @directory.fetch(identity[@directory.index[0]])
|
67
|
+
@translator.get_identity(entry)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'soar/registry/identity/provider/staff/base'
|
2
|
+
|
3
|
+
module Soar
|
4
|
+
module Registry
|
5
|
+
module Identity
|
6
|
+
module Provider
|
7
|
+
module Staff
|
8
|
+
class Email < Base
|
9
|
+
|
10
|
+
##
|
11
|
+
# @param [String] identifier, an email address that uniquely identifies an identity
|
12
|
+
# @return [Hash] an identity
|
13
|
+
##
|
14
|
+
def calculate_identities(identifier)
|
15
|
+
entries = @directory.search("email", identifier )
|
16
|
+
return [@translator.get_identity(entries)[0]]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'soar/registry/identity/provider/staff/base'
|
2
|
+
|
3
|
+
module Soar
|
4
|
+
module Registry
|
5
|
+
module Identity
|
6
|
+
module Provider
|
7
|
+
module Staff
|
8
|
+
class Id < Base
|
9
|
+
|
10
|
+
##
|
11
|
+
# @param [String] identifier, a primary key that uniquely identifies an identity
|
12
|
+
# @return [Hash] an identity
|
13
|
+
##
|
14
|
+
def calculate_identities(identifier)
|
15
|
+
return [@translator.get_identity(@directory.fetch(identifier))]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Soar
|
2
|
+
module Registry
|
3
|
+
module Identity
|
4
|
+
module Provider
|
5
|
+
module Staff
|
6
|
+
module Translator
|
7
|
+
class Default
|
8
|
+
|
9
|
+
##
|
10
|
+
# @param [Hash] entry a single entry from datasource
|
11
|
+
# @returns [Hash] identity a single identity
|
12
|
+
##
|
13
|
+
def get_identity(entry)
|
14
|
+
return entry
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# @param [Array] entries a list of entries from data source
|
19
|
+
# @return [Array] identities a list of identities
|
20
|
+
##
|
21
|
+
def get_identities(entries)
|
22
|
+
return entries
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"uuid": "identity-62936e70-1815-439b-bf89-8492855a7e6b",
|
4
|
+
"entity_id": "entity-2d931510-d99f-494a-8c67-87feb05e1594",
|
5
|
+
"email": "test+publisher@hetzner.co.za",
|
6
|
+
"roles": {
|
7
|
+
"staff": {
|
8
|
+
"department": "technical"
|
9
|
+
},
|
10
|
+
"configuration_publisher": {
|
11
|
+
"configuration_identifiers": ["*"]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"uuid": "identity-43353f18-8afe-11e6-ae22-56b6b6499611",
|
17
|
+
"entity_id": "entity-2d931510-d99f-494a-8c67-87feb05e1594",
|
18
|
+
"email": "test+consumer@hetzner.co.za",
|
19
|
+
"roles": {
|
20
|
+
"staff": {},
|
21
|
+
"configuration_consumer": {
|
22
|
+
"configuration_identifiers": ["*"]
|
23
|
+
}
|
24
|
+
|
25
|
+
}
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"uuid": "identity-820d5660-2204-4f7d-8c04-746313439b81",
|
29
|
+
"entity_id": "entity-bad85eb9-0713-4da7-8d36-07a8e4b00eab",
|
30
|
+
"email": "admin@hetzner.co.za",
|
31
|
+
"roles": {
|
32
|
+
"staff": {},
|
33
|
+
"configuration_publisher": {
|
34
|
+
"configuration_identifiers": ["*"]
|
35
|
+
},
|
36
|
+
"configuration_consumer": {
|
37
|
+
"configuration_identifiers": ["*"]
|
38
|
+
}
|
39
|
+
|
40
|
+
},
|
41
|
+
"address": {
|
42
|
+
"detail": "Belvedere Office Park, Unit F",
|
43
|
+
"street": "Bella Rosa Street",
|
44
|
+
"suburb": "Tygervalley",
|
45
|
+
"city": "Durbanville",
|
46
|
+
"postal": "7550"
|
47
|
+
}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"uuid": "identity-1ff472a6-8df3-4f13-82c3-89fde26db3cf",
|
51
|
+
"entity_id": "entity-bad85eb9-0713-4da7-8d36-07a8e4b00eab",
|
52
|
+
"email": "none@example.com",
|
53
|
+
"client_nr": "C123456789",
|
54
|
+
"roles": {
|
55
|
+
"customer": {},
|
56
|
+
"reseller": {}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
]
|
60
|
+
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soar-registry-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-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: soar_idm
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.2
|
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: 0.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.1
|
41
|
+
description: Registry of identities
|
42
|
+
email: charles.mulder@hetzner.co.za
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- README.md
|
48
|
+
- lib/soar/registry/identity.rb
|
49
|
+
- lib/soar/registry/identity/model.rb
|
50
|
+
- lib/soar/registry/identity/provider/staff/base.rb
|
51
|
+
- lib/soar/registry/identity/provider/staff/email.rb
|
52
|
+
- lib/soar/registry/identity/provider/staff/id.rb
|
53
|
+
- lib/soar/registry/identity/provider/staff/translator/default.rb
|
54
|
+
- lib/soar/registry/identity/test/fixtures/entries.json
|
55
|
+
homepage: https://gitlab.host-h.net/registries/identity
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.5.1
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Identity Registry
|
79
|
+
test_files: []
|