scim-shady 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitlab-ci.yml +15 -0
  4. data/.travis.yml +1 -0
  5. data/lib/scim/shady.rb +19 -1
  6. data/lib/scim/shady/address.rb +41 -0
  7. data/lib/scim/shady/buildable.rb +21 -0
  8. data/lib/scim/shady/builders.rb +14 -0
  9. data/lib/scim/shady/builders/addresses.rb +24 -0
  10. data/lib/scim/shady/builders/bulk.rb +19 -0
  11. data/lib/scim/shady/builders/emails.rb +16 -0
  12. data/lib/scim/shady/builders/filter.rb +17 -0
  13. data/lib/scim/shady/builders/groups.rb +16 -0
  14. data/lib/scim/shady/builders/instant_messengers.rb +16 -0
  15. data/lib/scim/shady/builders/metadata.rb +29 -0
  16. data/lib/scim/shady/builders/name.rb +27 -0
  17. data/lib/scim/shady/builders/phone_numbers.rb +16 -0
  18. data/lib/scim/shady/builders/photos.rb +16 -0
  19. data/lib/scim/shady/builders/resource.rb +26 -0
  20. data/lib/scim/shady/builders/service_provider_configuration.rb +83 -0
  21. data/lib/scim/shady/builders/user.rb +96 -0
  22. data/lib/scim/shady/builders/x509_certificates.rb +16 -0
  23. data/lib/scim/shady/group.rb +25 -0
  24. data/lib/scim/shady/instant_messenger.rb +21 -0
  25. data/lib/scim/shady/metadata.rb +45 -0
  26. data/lib/scim/shady/name.rb +17 -0
  27. data/lib/scim/shady/phone_number.rb +29 -0
  28. data/lib/scim/shady/photo.rb +29 -0
  29. data/lib/scim/shady/resource.rb +25 -0
  30. data/lib/scim/shady/schemas.rb +17 -0
  31. data/lib/scim/shady/service_provider_configuration.rb +71 -0
  32. data/lib/scim/shady/user.rb +71 -0
  33. data/lib/scim/shady/version.rb +1 -1
  34. data/lib/scim/shady/x509_certificate.rb +17 -0
  35. data/scim-shady.gemspec +5 -3
  36. metadata +62 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2965377796c15771ee69d667f7ac752a93289bae2ed7378b3990330fcfd4ab3f
4
- data.tar.gz: 856d36ea561b65f812a32ae1d8a2d41da2747f19e0dfb3590e013796d6cb2f91
3
+ metadata.gz: 8bdfa18d1a406fd72885524c3c29ec078063cd78e48fadc87bb90cf44da67502
4
+ data.tar.gz: cee21c5eee72ad6ce0aaa696e0c51277b87657a7a025a096f70106c9742f6743
5
5
  SHA512:
6
- metadata.gz: 93fd9c0d77c1e249adaede04f0788f579977570243c6c9f07f58131f1ae3847b48a75a582016914b6a668816e0f1546f62de9fccd347f85f49bbf5c9f0fd9120
7
- data.tar.gz: c2440e72f46e9ab7f73d3823e00fa18afe6545046d2fdd99c16d7d94f2e8445aca58eedcb8d86c44533ae86848dc2712ea33d842d3c9a3d8ffed317f6e392db6
6
+ metadata.gz: 5dd9051bbcf1dcbde1a5118a66ac37860fac7eab5a4324aa1ce9362e17609e3627728f71c0c7b19128f7ea1a6b892e9a5e387249b94a9a2d607193da8aa6bc22
7
+ data.tar.gz: 4c092ab94c3ac821682af4e09113e8eaa384db6739bbd47aca2ef2b929f02792866640c190bb812805ad35a24ced46c1fe1c9fd86ce231dc88b9e88e9cb113d1
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
+ /Gemfile.lock
3
4
  /_yardoc/
4
5
  /coverage/
5
6
  /doc/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,15 @@
1
+ image: ruby:2.2
2
+
3
+ before_script:
4
+ - apt-get update && apt-get install -y locales
5
+ - echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
6
+ - locale-gen
7
+ - export LC_ALL=en_US.UTF-8
8
+ - ruby -v
9
+ - which ruby
10
+ - gem install bundler --no-ri --no-rdoc
11
+ - bundle install --jobs $(nproc) "${FLAGS[@]}"
12
+
13
+ rspec:
14
+ script:
15
+ - bundle exec rspec
data/.travis.yml CHANGED
@@ -3,3 +3,4 @@ language: ruby
3
3
  rvm:
4
4
  - 2.5.0
5
5
  before_install: gem install bundler -v 1.16.1
6
+ script: bundle exec rspec
data/lib/scim/shady.rb CHANGED
@@ -1,7 +1,25 @@
1
+ require "forwardable"
2
+ require "json"
3
+ require "time"
4
+ require "active_support/concern"
5
+
6
+ require "scim/shady/address"
7
+ require "scim/shady/buildable"
8
+ require "scim/shady/builders"
9
+ require "scim/shady/group"
10
+ require "scim/shady/instant_messenger"
11
+ require "scim/shady/metadata"
12
+ require "scim/shady/name"
13
+ require "scim/shady/phone_number"
14
+ require "scim/shady/photo"
15
+ require "scim/shady/resource"
16
+ require "scim/shady/schemas"
17
+ require "scim/shady/service_provider_configuration"
18
+ require "scim/shady/user"
1
19
  require "scim/shady/version"
20
+ require "scim/shady/x509_certificate"
2
21
 
3
22
  module Scim
4
23
  module Shady
5
- # Your code goes here...
6
24
  end
7
25
  end
@@ -0,0 +1,41 @@
1
+ module Scim
2
+ module Shady
3
+ class Address
4
+ def initialize(hash)
5
+ @hash = hash
6
+ end
7
+
8
+ def street_address
9
+ to_h['streetAddress']
10
+ end
11
+
12
+ def locality
13
+ to_h['locality']
14
+ end
15
+
16
+ def region
17
+ to_h['region']
18
+ end
19
+
20
+ def postal_code
21
+ to_h['postalCode']
22
+ end
23
+
24
+ def country
25
+ to_h['country']
26
+ end
27
+
28
+ def formatted
29
+ "#{street_address}\n#{locality}, #{region} #{postal_code} #{country}"
30
+ end
31
+
32
+ def primary?
33
+ to_h['primary']
34
+ end
35
+
36
+ def to_h
37
+ @hash
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,21 @@
1
+ module Scim
2
+ module Shady
3
+ module Buildable
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def build
8
+ builder do |builder|
9
+ yield builder if block_given?
10
+ end.build
11
+ end
12
+
13
+ def builder
14
+ builder = builder_class.new
15
+ yield builder if block_given?
16
+ builder
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require "scim/shady/builders/addresses"
2
+ require "scim/shady/builders/bulk"
3
+ require "scim/shady/builders/emails"
4
+ require "scim/shady/builders/filter"
5
+ require "scim/shady/builders/groups"
6
+ require "scim/shady/builders/instant_messengers"
7
+ require "scim/shady/builders/metadata"
8
+ require "scim/shady/builders/name"
9
+ require "scim/shady/builders/phone_numbers"
10
+ require "scim/shady/builders/photos"
11
+ require "scim/shady/builders/resource"
12
+ require "scim/shady/builders/service_provider_configuration"
13
+ require "scim/shady/builders/user"
14
+ require "scim/shady/builders/x509_certificates"
@@ -0,0 +1,24 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Addresses
5
+ def add(type:, street_address:, locality:, region:, postal_code:, country:, primary: false)
6
+ @items ||= []
7
+ @items.push(
8
+ type: type,
9
+ streetAddress: street_address,
10
+ locality: locality,
11
+ region: region,
12
+ postalCode: postal_code,
13
+ country: country,
14
+ primary: primary,
15
+ )
16
+ end
17
+
18
+ def to_h
19
+ { 'addresses' => @items }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Bulk
5
+ attr_accessor :supported
6
+ attr_accessor :max_operations
7
+ attr_accessor :max_payload_size
8
+
9
+ def to_h
10
+ {
11
+ 'supported' => supported,
12
+ 'maxOperations' => max_operations,
13
+ 'maxPayloadSize' => max_payload_size,
14
+ }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Emails
5
+ def add(email, type: :work, primary: false)
6
+ @items ||= []
7
+ @items.push(value: email, type: type, primary: primary)
8
+ end
9
+
10
+ def to_h
11
+ { 'emails' => @items }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Filter
5
+ attr_accessor :supported
6
+ attr_accessor :max_results
7
+
8
+ def to_h
9
+ {
10
+ 'supported' => supported,
11
+ 'maxResults' => max_results,
12
+ }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Groups
5
+ def add(id, url, display_name)
6
+ @items ||= []
7
+ @items.push(value: id, '$ref' => url, display: display_name)
8
+ end
9
+
10
+ def to_h
11
+ { 'groups' => @items }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class InstantMessengers
5
+ def add(handle, type:)
6
+ @items ||= []
7
+ @items.push(value: handle, type: type)
8
+ end
9
+
10
+ def to_h
11
+ { 'ims' => @items }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Metadata
5
+ attr_accessor :created_at
6
+ attr_accessor :updated_at
7
+ attr_accessor :location
8
+ attr_accessor :version
9
+
10
+ def initialize(resource)
11
+ @resource = resource
12
+ @created_at = @updated_at = Time.now
13
+ end
14
+
15
+ def to_h
16
+ {
17
+ 'meta' => {
18
+ 'resourceType' => @resource.class.name.split(/::/).last,
19
+ 'created' => created_at.to_time.utc.iso8601,
20
+ 'lastModified' => updated_at.to_time.utc.iso8601,
21
+ 'location' => location,
22
+ 'version' => version,
23
+ },
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Name
5
+ attr_accessor :family_name
6
+ attr_accessor :given_name
7
+ attr_accessor :middle_name
8
+ attr_accessor :honorific_prefix
9
+ attr_accessor :honorific_suffix
10
+ attr_accessor :formatted
11
+
12
+ def to_h
13
+ {
14
+ 'name' => {
15
+ 'formatted' => formatted,
16
+ 'familyName' => family_name,
17
+ 'givenName' => given_name,
18
+ 'middleName' => middle_name,
19
+ 'honorificPrefix' => honorific_prefix,
20
+ 'honorificSuffix' => honorific_suffix,
21
+ }
22
+ }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class PhoneNumbers
5
+ def add(phone_number, type: :work)
6
+ @items ||= []
7
+ @items.push(value: phone_number, type: type)
8
+ end
9
+
10
+ def to_h
11
+ { 'phoneNumbers' => @items }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Photos
5
+ def add(url, type: :photo)
6
+ @items ||= []
7
+ @items.push(value: url, type: type)
8
+ end
9
+
10
+ def to_h
11
+ { 'photos' => @items }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class Resource
5
+ extend Forwardable
6
+ attr_accessor :id
7
+ def_delegators :@meta, :created_at=, :updated_at=, :location=, :version=
8
+
9
+ def initialize
10
+ @meta = Metadata.new(self)
11
+ end
12
+
13
+ def meta
14
+ yield @meta
15
+ end
16
+
17
+ def to_h
18
+ {
19
+ 'schemas' => [],
20
+ 'id' => id,
21
+ }.merge(@meta.to_h)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,83 @@
1
+ module Scim
2
+ module Shady
3
+ module Builders
4
+ class ServiceProviderConfiguration
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 bulk
21
+ @bulk = Bulk.new
22
+ yield @bulk
23
+ end
24
+
25
+ def filter
26
+ @filter = Filter.new
27
+ yield @filter
28
+ end
29
+
30
+ def add_authentication_scheme(type)
31
+ if :oauth_bearer_token == type
32
+ @authentication_schemes.push({
33
+ "name" => "OAuth Bearer Token",
34
+ "description" => "Authentication scheme using the OAuth Bearer Token Standard",
35
+ "specUri" => "http://www.rfc-editor.org/info/rfc6750",
36
+ "documentationUri" => "http://example.com/help/oauth.html",
37
+ "type" => "oauthbearertoken",
38
+ })
39
+ elsif :http_basic == type
40
+ @authentication_schemes.push({
41
+ "name" => "HTTP Basic",
42
+ "description" => "Authentication scheme using the HTTP Basic Standard",
43
+ "specUri" => "http://www.rfc-editor.org/info/rfc2617",
44
+ "documentationUri" => "http://example.com/help/httpBasic.html",
45
+ "type" => "httpbasic",
46
+ })
47
+ end
48
+ end
49
+
50
+ def build
51
+ Scim::Shady::ServiceProviderConfiguration.new(to_json)
52
+ end
53
+
54
+ def to_json
55
+ JSON.generate(to_h)
56
+ end
57
+
58
+ def to_h
59
+ {
60
+ 'schemas' => [Schemas::SERVICE_PROVIDER_CONFIG],
61
+ 'documentationUri' => documentation_uri,
62
+ 'patch' => { "supported" => patch },
63
+ 'bulk' => @bulk.to_h,
64
+ 'filter' => @filter.to_h,
65
+ 'changePassword' => {
66
+ 'supported' => change_password_supported,
67
+ },
68
+ 'sort' => {
69
+ 'supported' => sort_supported,
70
+ },
71
+ 'etag' => {
72
+ 'supported' => etag_supported,
73
+ },
74
+ 'authenticationSchemes' => @authentication_schemes.each_with_index.map do |scheme, index|
75
+ scheme['primary'] = true if index.zero?
76
+ scheme
77
+ end
78
+ }.merge(@meta.to_h)
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,96 @@
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
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,25 @@
1
+ module Scim
2
+ module Shady
3
+ class Group
4
+ def initialize(hash)
5
+ @hash = hash
6
+ end
7
+
8
+ def value
9
+ to_h['value']
10
+ end
11
+
12
+ def reference
13
+ to_h['$ref']
14
+ end
15
+
16
+ def display
17
+ to_h['display']
18
+ end
19
+
20
+ def to_h
21
+ @hash
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
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
@@ -0,0 +1,45 @@
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
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,71 @@
1
+ module Scim
2
+ module Shady
3
+ class ServiceProviderConfiguration
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::ServiceProviderConfiguration
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,71 @@
1
+ module Scim
2
+ module Shady
3
+ class User < Resource
4
+ include Buildable
5
+
6
+ def username
7
+ to_h['userName']
8
+ end
9
+
10
+ def external_id
11
+ to_h['externalId']
12
+ end
13
+
14
+ def name
15
+ Name.new(to_h)
16
+ end
17
+
18
+ def addresses
19
+ to_h['addresses'].map { |x| Address.new(x) }
20
+ end
21
+
22
+ def phone_numbers
23
+ to_h['phoneNumbers'].map { |x| PhoneNumber.new(x) }
24
+ end
25
+
26
+ def instant_messengers
27
+ to_h['ims'].map { |x| InstantMessenger.new(x) }
28
+ end
29
+
30
+ def photos
31
+ to_h['photos'].map { |x| Photo.new(x) }
32
+ end
33
+
34
+ def user_type
35
+ to_h['userType']
36
+ end
37
+
38
+ def title
39
+ to_h['title']
40
+ end
41
+
42
+ def preferred_language
43
+ to_h['preferredLanguage']
44
+ end
45
+
46
+ def locale
47
+ to_h['locale']
48
+ end
49
+
50
+ def timezone
51
+ to_h['timezone']
52
+ end
53
+
54
+ def active?
55
+ to_h['active']
56
+ end
57
+
58
+ def groups
59
+ to_h['groups'].map { |x| Group.new(x) }
60
+ end
61
+
62
+ def x509_certificates
63
+ to_h['x509Certificates'].map { |x| X509Certificate.new(x) }
64
+ end
65
+
66
+ def self.builder_class
67
+ Scim::Shady::Builders::User
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,5 +1,5 @@
1
1
  module Scim
2
2
  module Shady
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,17 @@
1
+ module Scim
2
+ module Shady
3
+ class X509Certificate
4
+ def initialize(hash)
5
+ @hash = hash
6
+ end
7
+
8
+ def value
9
+ to_h['value']
10
+ end
11
+
12
+ def to_h
13
+ @hash
14
+ end
15
+ end
16
+ end
17
+ end
data/scim-shady.gemspec CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "scim-shady"
8
8
  spec.version = Scim::Shady::VERSION
9
9
  spec.authors = ["mo"]
10
- spec.email = ["mo.khan@gmail.com"]
10
+ spec.email = ["mo@mokhan.ca"]
11
11
 
12
- spec.summary = %q{Write a short summary, because RubyGems requires one.}
13
- spec.description = %q{Write a longer description or delete this line.}
12
+ spec.summary = %q{A simple toolkit for implementing SCIM schema. https://tools.ietf.org/html/rfc7643}
13
+ spec.description = %q{A simple toolkit for implementing SCIM schema. https://tools.ietf.org/html/rfc7643}
14
14
  spec.homepage = "http://www.mokhan.ca/"
15
15
  spec.license = "MIT"
16
16
 
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
+ spec.add_dependency "activesupport", ">= 4.2.0"
24
25
  spec.add_development_dependency "bundler", "~> 1.16"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
26
27
  spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "ffaker"
27
29
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scim-shady
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-13 00:00:00.000000000 Z
11
+ date: 2018-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,14 +66,29 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '3.0'
55
- description: Write a longer description or delete this line.
69
+ - !ruby/object:Gem::Dependency
70
+ name: ffaker
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A simple toolkit for implementing SCIM schema. https://tools.ietf.org/html/rfc7643
56
84
  email:
57
- - mo.khan@gmail.com
85
+ - mo@mokhan.ca
58
86
  executables: []
59
87
  extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
62
90
  - ".gitignore"
91
+ - ".gitlab-ci.yml"
63
92
  - ".rspec"
64
93
  - ".travis.yml"
65
94
  - Gemfile
@@ -69,7 +98,35 @@ files:
69
98
  - bin/console
70
99
  - bin/setup
71
100
  - lib/scim/shady.rb
101
+ - lib/scim/shady/address.rb
102
+ - lib/scim/shady/buildable.rb
103
+ - lib/scim/shady/builders.rb
104
+ - lib/scim/shady/builders/addresses.rb
105
+ - lib/scim/shady/builders/bulk.rb
106
+ - lib/scim/shady/builders/emails.rb
107
+ - lib/scim/shady/builders/filter.rb
108
+ - lib/scim/shady/builders/groups.rb
109
+ - lib/scim/shady/builders/instant_messengers.rb
110
+ - lib/scim/shady/builders/metadata.rb
111
+ - lib/scim/shady/builders/name.rb
112
+ - lib/scim/shady/builders/phone_numbers.rb
113
+ - lib/scim/shady/builders/photos.rb
114
+ - lib/scim/shady/builders/resource.rb
115
+ - lib/scim/shady/builders/service_provider_configuration.rb
116
+ - lib/scim/shady/builders/user.rb
117
+ - lib/scim/shady/builders/x509_certificates.rb
118
+ - lib/scim/shady/group.rb
119
+ - lib/scim/shady/instant_messenger.rb
120
+ - lib/scim/shady/metadata.rb
121
+ - lib/scim/shady/name.rb
122
+ - lib/scim/shady/phone_number.rb
123
+ - lib/scim/shady/photo.rb
124
+ - lib/scim/shady/resource.rb
125
+ - lib/scim/shady/schemas.rb
126
+ - lib/scim/shady/service_provider_configuration.rb
127
+ - lib/scim/shady/user.rb
72
128
  - lib/scim/shady/version.rb
129
+ - lib/scim/shady/x509_certificate.rb
73
130
  - scim-shady.gemspec
74
131
  homepage: http://www.mokhan.ca/
75
132
  licenses:
@@ -94,5 +151,5 @@ rubyforge_project:
94
151
  rubygems_version: 2.7.3
95
152
  signing_key:
96
153
  specification_version: 4
97
- summary: Write a short summary, because RubyGems requires one.
154
+ summary: A simple toolkit for implementing SCIM schema. https://tools.ietf.org/html/rfc7643
98
155
  test_files: []