scim-shady 0.2.1 → 0.3.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +2 -2
  3. data/.travis.yml +2 -2
  4. data/README.md +6 -5
  5. data/lib/scim/shady.rb +6 -19
  6. data/lib/scim/shady/enterprise_user.rb +93 -0
  7. data/lib/scim/shady/group.rb +49 -17
  8. data/lib/scim/shady/user.rb +550 -63
  9. data/lib/scim/shady/version.rb +1 -1
  10. data/scim-shady.gemspec +3 -2
  11. metadata +12 -38
  12. data/lib/scim/shady/address.rb +0 -41
  13. data/lib/scim/shady/buildable.rb +0 -21
  14. data/lib/scim/shady/builders.rb +0 -14
  15. data/lib/scim/shady/builders/addresses.rb +0 -24
  16. data/lib/scim/shady/builders/bulk.rb +0 -19
  17. data/lib/scim/shady/builders/emails.rb +0 -16
  18. data/lib/scim/shady/builders/filter.rb +0 -17
  19. data/lib/scim/shady/builders/groups.rb +0 -16
  20. data/lib/scim/shady/builders/instant_messengers.rb +0 -16
  21. data/lib/scim/shady/builders/metadata.rb +0 -29
  22. data/lib/scim/shady/builders/name.rb +0 -27
  23. data/lib/scim/shady/builders/phone_numbers.rb +0 -16
  24. data/lib/scim/shady/builders/photos.rb +0 -16
  25. data/lib/scim/shady/builders/resource.rb +0 -26
  26. data/lib/scim/shady/builders/service_provider_config.rb +0 -87
  27. data/lib/scim/shady/builders/user.rb +0 -96
  28. data/lib/scim/shady/builders/x509_certificates.rb +0 -16
  29. data/lib/scim/shady/instant_messenger.rb +0 -21
  30. data/lib/scim/shady/metadata.rb +0 -45
  31. data/lib/scim/shady/name.rb +0 -17
  32. data/lib/scim/shady/phone_number.rb +0 -29
  33. data/lib/scim/shady/photo.rb +0 -29
  34. data/lib/scim/shady/resource.rb +0 -25
  35. data/lib/scim/shady/schemas.rb +0 -17
  36. data/lib/scim/shady/service_provider_config.rb +0 -71
  37. data/lib/scim/shady/x509_certificate.rb +0 -17
@@ -1,87 +0,0 @@
1
- module Scim
2
- module Shady
3
- module Builders
4
- class ServiceProviderConfig
5
- extend Forwardable
6
- def_delegators :@meta, :created_at=, :updated_at=, :location=, :version=
7
- def_delegators :@meta, :created_at, :updated_at, :location, :version
8
- attr_accessor :documentation_uri
9
- attr_accessor :patch
10
- attr_accessor :change_password_supported
11
- attr_accessor :sort_supported
12
- attr_accessor :etag_supported
13
-
14
- def initialize
15
- @authentication_schemes = []
16
- @created_at = @updated_at = Time.now
17
- @meta = Metadata.new(self)
18
- end
19
-
20
- def meta
21
- yield @meta
22
- end
23
-
24
- def bulk
25
- @bulk = Bulk.new
26
- yield @bulk
27
- end
28
-
29
- def filter
30
- @filter = Filter.new
31
- yield @filter
32
- end
33
-
34
- def add_authentication_scheme(type)
35
- if :oauth_bearer_token == type
36
- @authentication_schemes.push({
37
- "name" => "OAuth Bearer Token",
38
- "description" => "Authentication scheme using the OAuth Bearer Token Standard",
39
- "specUri" => "http://www.rfc-editor.org/info/rfc6750",
40
- "documentationUri" => "http://example.com/help/oauth.html",
41
- "type" => "oauthbearertoken",
42
- })
43
- elsif :http_basic == type
44
- @authentication_schemes.push({
45
- "name" => "HTTP Basic",
46
- "description" => "Authentication scheme using the HTTP Basic Standard",
47
- "specUri" => "http://www.rfc-editor.org/info/rfc2617",
48
- "documentationUri" => "http://example.com/help/httpBasic.html",
49
- "type" => "httpbasic",
50
- })
51
- end
52
- end
53
-
54
- def build
55
- Scim::Shady::ServiceProviderConfig.new(to_json)
56
- end
57
-
58
- def to_json
59
- JSON.generate(to_h)
60
- end
61
-
62
- def to_h
63
- {
64
- 'schemas' => [Schemas::SERVICE_PROVIDER_CONFIG],
65
- 'documentationUri' => documentation_uri,
66
- 'patch' => { "supported" => patch },
67
- 'bulk' => @bulk.to_h,
68
- 'filter' => @filter.to_h,
69
- 'changePassword' => {
70
- 'supported' => change_password_supported,
71
- },
72
- 'sort' => {
73
- 'supported' => sort_supported,
74
- },
75
- 'etag' => {
76
- 'supported' => etag_supported,
77
- },
78
- 'authenticationSchemes' => @authentication_schemes.each_with_index.map do |scheme, index|
79
- scheme['primary'] = true if index.zero?
80
- scheme
81
- end
82
- }.merge(@meta.to_h)
83
- end
84
- end
85
- end
86
- end
87
- end
@@ -1,96 +0,0 @@
1
- module Scim
2
- module Shady
3
- module Builders
4
- class User < Resource
5
- attr_accessor :external_id
6
- attr_accessor :username
7
- attr_accessor :display_name
8
- attr_accessor :nick_name
9
- attr_accessor :profile_url
10
- attr_accessor :user_type
11
- attr_accessor :title
12
- attr_accessor :preferred_language
13
- attr_accessor :locale
14
- attr_accessor :timezone
15
- attr_accessor :active
16
-
17
- def initialize
18
- @name = Name.new
19
- @emails = Emails.new
20
- @addresses = Addresses.new
21
- @phone_numbers = PhoneNumbers.new
22
- @instant_messengers = InstantMessengers.new
23
- @photos = Photos.new
24
- @groups = Groups.new
25
- @x509_certificates = X509Certificates.new
26
- super
27
- end
28
-
29
- def name
30
- yield @name
31
- end
32
-
33
- def emails
34
- yield @emails
35
- end
36
-
37
- def addresses
38
- yield @addresses
39
- end
40
-
41
- def phone_numbers
42
- yield @phone_numbers
43
- end
44
-
45
- def instant_messengers
46
- yield @instant_messengers
47
- end
48
-
49
- def photos
50
- yield @photos
51
- end
52
-
53
- def groups
54
- yield @groups
55
- end
56
-
57
- def x509_certificates
58
- yield @x509_certificates
59
- end
60
-
61
- def build
62
- Scim::Shady::User.new(to_json)
63
- end
64
-
65
- def to_json
66
- JSON.generate(to_h)
67
- end
68
-
69
- def to_h
70
- super.merge({
71
- 'schemas' => [Schemas::USER],
72
- 'externalId' => external_id,
73
- 'userName' => username,
74
- 'displayName' => display_name,
75
- 'nickName' => nick_name,
76
- 'profile_url' => profile_url,
77
- 'userType' => user_type,
78
- 'title' => title,
79
- 'preferredLanguage' => preferred_language,
80
- 'locale' => locale,
81
- 'timezone' => timezone,
82
- 'active' => active,
83
- })
84
- .merge(@name.to_h)
85
- .merge(@emails.to_h)
86
- .merge(@addresses.to_h)
87
- .merge(@phone_numbers.to_h)
88
- .merge(@instant_messengers.to_h)
89
- .merge(@photos.to_h)
90
- .merge(@groups.to_h)
91
- .merge(@x509_certificates.to_h)
92
- end
93
- end
94
- end
95
- end
96
- end
@@ -1,16 +0,0 @@
1
- module Scim
2
- module Shady
3
- module Builders
4
- class X509Certificates
5
- def add(certificate)
6
- @items ||= []
7
- @items.push(value: certificate.to_pem.gsub(/-----BEGIN CERTIFICATE-----/, '').gsub(/-----END CERTIFICATE-----/, ''))
8
- end
9
-
10
- def to_h
11
- { 'x509Certificates' => @items }
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,21 +0,0 @@
1
- module Scim
2
- module Shady
3
- class InstantMessenger
4
- def initialize(hash)
5
- @hash = hash
6
- end
7
-
8
- def value
9
- to_h['value']
10
- end
11
-
12
- def type
13
- to_h['type']
14
- end
15
-
16
- def to_h
17
- @hash
18
- end
19
- end
20
- end
21
- end
@@ -1,45 +0,0 @@
1
- module Scim
2
- module Shady
3
- class Metadata
4
- def initialize(hash)
5
- @hash = hash
6
- end
7
-
8
- def created
9
- created_at
10
- end
11
-
12
- def created_at
13
- DateTime.parse(to_h['meta']['created'])
14
- end
15
-
16
- def last_modified
17
- updated_at
18
- end
19
-
20
- def updated_at
21
- DateTime.parse(to_h['meta']['lastModified'])
22
- end
23
-
24
- def version
25
- to_h['meta']['version']
26
- end
27
-
28
- def location
29
- to_h['meta']['location']
30
- end
31
-
32
- def resource_type
33
- to_h['meta']['resourceType']
34
- end
35
-
36
- def user?
37
- resource_type == 'User'
38
- end
39
-
40
- def to_h
41
- @hash
42
- end
43
- end
44
- end
45
- end
@@ -1,17 +0,0 @@
1
- module Scim
2
- module Shady
3
- class Name
4
- def initialize(hash)
5
- @hash = hash
6
- end
7
-
8
- def formatted
9
- to_h['formatted']
10
- end
11
-
12
- def to_h
13
- @hash['name']
14
- end
15
- end
16
- end
17
- end
@@ -1,29 +0,0 @@
1
- module Scim
2
- module Shady
3
- class PhoneNumber
4
- def initialize(hash)
5
- @hash = hash
6
- end
7
-
8
- def value
9
- to_h['value']
10
- end
11
-
12
- def type
13
- to_h['type']
14
- end
15
-
16
- def work?
17
- type == 'work'
18
- end
19
-
20
- def mobile?
21
- type == 'mobile'
22
- end
23
-
24
- def to_h
25
- @hash
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- module Scim
2
- module Shady
3
- class Photo
4
- def initialize(hash)
5
- @hash = hash
6
- end
7
-
8
- def value
9
- to_h['value']
10
- end
11
-
12
- def type
13
- to_h['type']
14
- end
15
-
16
- def photo?
17
- type == 'photo'
18
- end
19
-
20
- def thumbnail?
21
- type == 'thumbnail'
22
- end
23
-
24
- def to_h
25
- @hash
26
- end
27
- end
28
- end
29
- end
@@ -1,25 +0,0 @@
1
- module Scim
2
- module Shady
3
- class Resource
4
- def initialize(json)
5
- @json = json
6
- end
7
-
8
- def meta
9
- Metadata.new(to_h)
10
- end
11
-
12
- def id
13
- to_h['id']
14
- end
15
-
16
- def to_h
17
- @json_hash ||= JSON.parse(to_json)
18
- end
19
-
20
- def to_json
21
- @json
22
- end
23
- end
24
- end
25
- end
@@ -1,17 +0,0 @@
1
- module Scim
2
- module Shady
3
- class Schemas
4
- CORE = "urn:ietf:params:scim:schemas:core:2.0"
5
- GROUP = "#{CORE}:Group"
6
- SERVICE_PROVIDER_CONFIG = "#{CORE}:ServiceProviderConfig"
7
- USER = "#{CORE}:User"
8
- end
9
-
10
- class Messages
11
- CORE = "urn:ietf:params:scim:api:messages:2.0"
12
- LIST_RESPONSE = "#{CORE}:ListResponse"
13
- SEARCH_REQUEST = "#{CORE}:SearchRequest"
14
- ERROR = "#{CORE}:Error"
15
- end
16
- end
17
- end
@@ -1,71 +0,0 @@
1
- module Scim
2
- module Shady
3
- class ServiceProviderConfig
4
- include Buildable
5
-
6
- def initialize(json)
7
- @json = json
8
- end
9
-
10
- def meta
11
- Metadata.new(to_h)
12
- end
13
-
14
- def documentation_uri
15
- to_h['documentationUri']
16
- end
17
-
18
- def patch
19
- to_h['patch']['supported']
20
- end
21
-
22
- def bulk_supported
23
- to_h['bulk']['supported']
24
- end
25
-
26
- def bulk_max_operations
27
- to_h['bulk']['maxOperations']
28
- end
29
-
30
- def bulk_max_payload_size
31
- to_h['bulk']['maxPayloadSize']
32
- end
33
-
34
- def filter_supported
35
- to_h['filter']['supported']
36
- end
37
-
38
- def filter_max_results
39
- to_h['filter']['maxResults']
40
- end
41
-
42
- def change_password_supported
43
- to_h['changePassword']['supported']
44
- end
45
-
46
- def sort_supported
47
- to_h['sort']['supported']
48
- end
49
-
50
- def etag_supported
51
- to_h['etag']['supported']
52
- end
53
-
54
- def authentication_schemes
55
- to_h['authenticationSchemes']
56
- end
57
-
58
- def to_h
59
- @hash ||= JSON.parse(to_json)
60
- end
61
-
62
- def to_json
63
- @json
64
- end
65
-
66
- def self.builder_class
67
- Scim::Shady::Builders::ServiceProviderConfig
68
- end
69
- end
70
- end
71
- end