scim-kit 0.2.16 → 0.3.0
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/.rubocop.yml +2 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +10 -4
- data/README.md +6 -2
- data/lib/scim/kit.rb +2 -0
- data/lib/scim/kit/templatable.rb +13 -0
- data/lib/scim/kit/v2/attributable.rb +18 -0
- data/lib/scim/kit/v2/attribute_type.rb +19 -16
- data/lib/scim/kit/v2/authentication_scheme.rb +20 -9
- data/lib/scim/kit/v2/configuration.rb +52 -19
- data/lib/scim/kit/v2/meta.rb +14 -0
- data/lib/scim/kit/v2/mutability.rb +3 -0
- data/lib/scim/kit/v2/resource.rb +6 -0
- data/lib/scim/kit/v2/resource_type.rb +23 -5
- data/lib/scim/kit/v2/schema.rb +25 -6
- data/lib/scim/kit/v2/service_provider_configuration.rb +24 -7
- data/lib/scim/kit/v2/supportable.rb +11 -0
- data/lib/scim/kit/version.rb +1 -1
- data/scim-kit.gemspec +3 -0
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 639a2ef0b56a72450d228d3523e9e5f999e4ad68cd9a4460195aa5d123a5a7f3
|
4
|
+
data.tar.gz: e5f5df1e0834b2269cedbca097b4b4ac5d4b9d7dd14908edffcba17d2ea995e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3595ecddd405ca2bf39e24e0f4778abb9bbc64852fd0e0299704f0bdb759afa1e48e7f68673237b8b6392a9704654c49385e553f7f4dea38af476a5a167b17bc
|
7
|
+
data.tar.gz: 204b543726948468a109fabaf0ba97d65d375ca60cc5699dcdb0c42400e84e539d1761a20f761a4774855243d1984eaf59471821fba8be0e6f0848bd8a6fd950
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Version 0.
|
1
|
+
Version 0.3.0
|
2
2
|
# Changelog
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
@@ -6,8 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
|
-
|
10
|
-
|
9
|
+
- NA
|
10
|
+
|
11
|
+
## [0.3.0] - 2019-02-21
|
12
|
+
### Added
|
13
|
+
- add ServiceProviderConfiguration JSON parsing
|
14
|
+
- add Schema JSON parsing
|
15
|
+
- add Resource Type JSON parsing
|
11
16
|
|
12
17
|
## [0.2.16] - 2019-02-03
|
13
18
|
### Added
|
@@ -22,7 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
22
27
|
- \_assign does not coerce values by default.
|
23
28
|
- errors are merged together instead of overwritten during attribute validation.
|
24
29
|
|
25
|
-
[Unreleased]: https://github.com/mokhan/scim-kit/compare/v0.
|
30
|
+
[Unreleased]: https://github.com/mokhan/scim-kit/compare/v0.3.0...HEAD
|
31
|
+
[0.3.0]: https://github.com/mokhan/scim-kit/compare/v0.2.16...v0.3.0
|
26
32
|
[0.2.16]: https://github.com/mokhan/scim-kit/compare/v0.2.15...v0.2.16
|
27
33
|
[0.2.15]: https://github.com/mokhan/scim-kit/compare/v0.2.14...v0.2.15
|
28
34
|
[0.2.14]: https://github.com/mokhan/scim-kit/compare/v0.2.13...v0.2.14
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Scim::Kit
|
2
2
|
|
3
|
+
[](https://travis-ci.org/mokhan/scim-kit)
|
4
|
+
[](https://codeclimate.com/github/mokhan/scim-kit)
|
5
|
+
[](https://rubygems.org/gems/scim-kit)
|
6
|
+
|
3
7
|
Scim::Kit is a library with the purpose of simplifying the generation
|
4
8
|
and consumption of SCIM Schema. https://tools.ietf.org/html/rfc7643#section-2
|
5
9
|
|
@@ -77,13 +81,13 @@ puts user_schema.to_json
|
|
77
81
|
|
78
82
|
## Development
|
79
83
|
|
80
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
84
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
81
85
|
|
82
86
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
83
87
|
|
84
88
|
## Contributing
|
85
89
|
|
86
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
90
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mokhan/scim-kit.
|
87
91
|
|
88
92
|
## License
|
89
93
|
|
data/lib/scim/kit.rb
CHANGED
@@ -4,6 +4,7 @@ require 'active_model'
|
|
4
4
|
require 'active_support/core_ext/hash/indifferent_access'
|
5
5
|
require 'json'
|
6
6
|
require 'logger'
|
7
|
+
require 'net/hippie'
|
7
8
|
require 'pathname'
|
8
9
|
require 'tilt'
|
9
10
|
require 'tilt/jbuilder'
|
@@ -19,6 +20,7 @@ module Scim
|
|
19
20
|
module Kit
|
20
21
|
class Error < StandardError; end
|
21
22
|
class UnknownAttributeError < Error; end
|
23
|
+
TYPE_ERROR = ArgumentError.new(:type)
|
22
24
|
|
23
25
|
def self.logger
|
24
26
|
@logger ||= Logger.new(STDOUT)
|
data/lib/scim/kit/templatable.rb
CHANGED
@@ -4,22 +4,35 @@ module Scim
|
|
4
4
|
module Kit
|
5
5
|
# Implement methods necessary to generate json from jbuilder templates.
|
6
6
|
module Templatable
|
7
|
+
# Returns the JSON representation of the item.
|
8
|
+
# @param options [Hash] the hash of options to forward to jbuilder
|
9
|
+
# return [String] the json string
|
7
10
|
def to_json(options = {})
|
8
11
|
render(self, options)
|
9
12
|
end
|
10
13
|
|
14
|
+
# Returns the hash representation of the JSON
|
15
|
+
# @return [Hash] the hash representation of the items JSON.
|
11
16
|
def as_json(_options = nil)
|
12
17
|
to_h
|
13
18
|
end
|
14
19
|
|
20
|
+
# Returns the hash representation of the JSON
|
21
|
+
# @return [Hash] the hash representation of the items JSON.
|
15
22
|
def to_h
|
16
23
|
JSON.parse(to_json, symbolize_names: true).with_indifferent_access
|
17
24
|
end
|
18
25
|
|
26
|
+
# Renders the model to JSON.
|
27
|
+
# @param model [Object] the model to render.
|
28
|
+
# @param options [Hash] the hash of options to pass to jbuilder.
|
29
|
+
# @return [String] the JSON.
|
19
30
|
def render(model, options)
|
20
31
|
Template.new(model).to_json(options)
|
21
32
|
end
|
22
33
|
|
34
|
+
# Returns the file name of the jbuilder template.
|
35
|
+
# @return [String] name of the jbuilder template.
|
23
36
|
def template_name
|
24
37
|
"#{self.class.name.split('::').last.underscore}.json.jbuilder"
|
25
38
|
end
|
@@ -7,14 +7,21 @@ module Scim
|
|
7
7
|
module Attributable
|
8
8
|
include Enumerable
|
9
9
|
|
10
|
+
# Returns a hash of the generated dynamic attributes
|
11
|
+
# @return [Hash] the dynamic attributes keys by their name
|
10
12
|
def dynamic_attributes
|
11
13
|
@dynamic_attributes ||= {}.with_indifferent_access
|
12
14
|
end
|
13
15
|
|
16
|
+
# Defines dynamic attributes on the resource for the types provided
|
17
|
+
# @param resource [Scim::Kit::V2::Resource] the resource to attach dynamic attributes to.
|
18
|
+
# @param types [Array<Scim::Kit::V2::AttributeType>] the array of types
|
14
19
|
def define_attributes_for(resource, types)
|
15
20
|
types.each { |x| attribute(x, resource) }
|
16
21
|
end
|
17
22
|
|
23
|
+
# Assigns attribute values via the provided hash.
|
24
|
+
# @param attributes [Hash] The name/values to assign.
|
18
25
|
def assign_attributes(attributes = {})
|
19
26
|
attributes.each do |key, value|
|
20
27
|
next if key.to_sym == :schemas
|
@@ -27,10 +34,16 @@ module Scim
|
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
37
|
+
# Returns the attribute identified by the name.
|
38
|
+
# @param name [String] the name of the attribute to return
|
39
|
+
# @return [Scim::Kit::V2::Attribute] the attribute or {Scim::Kit::V2::UnknownAttribute}
|
30
40
|
def attribute_for(name)
|
31
41
|
dynamic_attributes[name.to_s.underscore] || UnknownAttribute.new(name)
|
32
42
|
end
|
33
43
|
|
44
|
+
# Returns the value associated with the attribute name
|
45
|
+
# @param name [String] the name of the attribute
|
46
|
+
# @return [Object] the value assigned to the attribute
|
34
47
|
def read_attribute(name)
|
35
48
|
attribute = attribute_for(name)
|
36
49
|
return attribute._value if attribute._type.multi_valued
|
@@ -38,6 +51,9 @@ module Scim
|
|
38
51
|
attribute._type.complex? ? attribute : attribute._value
|
39
52
|
end
|
40
53
|
|
54
|
+
# Assigns the value to the attribute with the given name
|
55
|
+
# @param name [String] the name of the attribute
|
56
|
+
# @param value [Object] the value to assign to the attribute
|
41
57
|
def write_attribute(name, value)
|
42
58
|
if value.is_a?(Hash)
|
43
59
|
attribute_for(name)&.assign_attributes(value)
|
@@ -46,6 +62,8 @@ module Scim
|
|
46
62
|
end
|
47
63
|
end
|
48
64
|
|
65
|
+
# yields each attribute to the provided block
|
66
|
+
# @param [Block] the block to yield each attribute to.
|
49
67
|
def each
|
50
68
|
dynamic_attributes.each do |_name, attribute|
|
51
69
|
yield attribute
|
@@ -6,20 +6,14 @@ module Scim
|
|
6
6
|
# Represents a scim Attribute type
|
7
7
|
class AttributeType
|
8
8
|
include Templatable
|
9
|
-
attr_accessor :canonical_values
|
10
|
-
attr_accessor :
|
11
|
-
|
12
|
-
|
13
|
-
attr_accessor :required
|
14
|
-
attr_reader :mutability
|
15
|
-
attr_reader :name, :type
|
16
|
-
attr_reader :reference_types
|
17
|
-
attr_reader :returned
|
18
|
-
attr_reader :uniqueness
|
9
|
+
attr_accessor :canonical_values, :case_exact, :description
|
10
|
+
attr_accessor :multi_valued, :required
|
11
|
+
attr_reader :mutability, :name, :type, :attributes
|
12
|
+
attr_reader :reference_types, :returned, :uniqueness
|
19
13
|
|
20
14
|
def initialize(name:, type: :string)
|
21
15
|
@name = name.to_s.underscore
|
22
|
-
@type = type.to_sym
|
16
|
+
@type = DATATYPES[type.to_sym] ? type.to_sym : (raise TYPE_ERROR)
|
23
17
|
@description = name
|
24
18
|
@multi_valued = false
|
25
19
|
@required = false
|
@@ -27,7 +21,7 @@ module Scim
|
|
27
21
|
@mutability = Mutability::READ_WRITE
|
28
22
|
@returned = Returned::DEFAULT
|
29
23
|
@uniqueness = Uniqueness::NONE
|
30
|
-
|
24
|
+
@attributes = []
|
31
25
|
end
|
32
26
|
|
33
27
|
def mutability=(value)
|
@@ -54,10 +48,6 @@ module Scim
|
|
54
48
|
@reference_types = value
|
55
49
|
end
|
56
50
|
|
57
|
-
def attributes
|
58
|
-
@attributes ||= []
|
59
|
-
end
|
60
|
-
|
61
51
|
def complex?
|
62
52
|
type_is?(:complex)
|
63
53
|
end
|
@@ -85,6 +75,19 @@ module Scim
|
|
85
75
|
complex? ? valid_complex?(value) : valid_simple?(value)
|
86
76
|
end
|
87
77
|
|
78
|
+
class << self
|
79
|
+
def from(hash)
|
80
|
+
x = new(name: hash[:name], type: hash[:type])
|
81
|
+
%i[
|
82
|
+
canonicalValues caseExact description multiValued mutability
|
83
|
+
referenceTypes required returned uniqueness
|
84
|
+
].each do |y|
|
85
|
+
x.public_send("#{y.to_s.underscore}=", hash[y]) if hash.key?(y)
|
86
|
+
end
|
87
|
+
x
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
88
91
|
private
|
89
92
|
|
90
93
|
def coerce_single(value)
|
@@ -32,15 +32,26 @@ module Scim
|
|
32
32
|
yield self if block_given?
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
class << self
|
36
|
+
def build_for(type, primary: nil)
|
37
|
+
defaults = DEFAULTS[type.to_sym] || {}
|
38
|
+
new do |x|
|
39
|
+
x.type = type
|
40
|
+
x.primary = primary
|
41
|
+
x.description = defaults[:description]
|
42
|
+
x.documentation_uri = defaults[:documentation_uri]
|
43
|
+
x.name = defaults[:name]
|
44
|
+
x.spec_uri = defaults[:spec_uri]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def from(hash)
|
49
|
+
x = build_for(hash[:type], primary: hash[:primary])
|
50
|
+
x.description = hash[:description]
|
51
|
+
x.documentation_uri = hash[:documentationUri]
|
52
|
+
x.name = hash[:name]
|
53
|
+
x.spec_uri = hash[:specUri]
|
54
|
+
x
|
44
55
|
end
|
45
56
|
end
|
46
57
|
end
|
@@ -7,31 +7,32 @@ module Scim
|
|
7
7
|
class Configuration
|
8
8
|
# @private
|
9
9
|
class Builder
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
attr_reader :configuration
|
11
|
+
|
12
|
+
def initialize(configuration)
|
13
|
+
@configuration = configuration
|
13
14
|
end
|
14
15
|
|
15
16
|
def service_provider_configuration(location:)
|
16
|
-
|
17
|
-
|
17
|
+
configuration.service_provider_configuration =
|
18
|
+
ServiceProviderConfiguration.new(location: location)
|
19
|
+
yield configuration.service_provider_configuration
|
18
20
|
end
|
19
21
|
|
20
22
|
def resource_type(id:, location:)
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
configuration.resource_types[id] ||=
|
24
|
+
ResourceType.new(location: location)
|
25
|
+
configuration.resource_types[id].id = id
|
26
|
+
yield configuration.resource_types[id]
|
24
27
|
end
|
25
28
|
|
26
29
|
def schema(id:, name:, location:)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
configuration.
|
33
|
-
configuration.resource_types = @resource_types
|
34
|
-
configuration.schemas = @schemas
|
30
|
+
configuration.schemas[id] ||= Schema.new(
|
31
|
+
id: id,
|
32
|
+
name: name,
|
33
|
+
location: location
|
34
|
+
)
|
35
|
+
yield configuration.schemas[id]
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -40,9 +41,41 @@ module Scim
|
|
40
41
|
attr_accessor :schemas
|
41
42
|
|
42
43
|
def initialize
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
@resource_types = {}
|
45
|
+
@schemas = {}
|
46
|
+
|
47
|
+
yield Builder.new(self) if block_given?
|
48
|
+
end
|
49
|
+
|
50
|
+
def load_from(base_url)
|
51
|
+
uri = URI.join(base_url, 'ServiceProviderConfig')
|
52
|
+
self.service_provider_configuration =
|
53
|
+
ServiceProviderConfiguration.parse(client.get(uri).body)
|
54
|
+
|
55
|
+
load_items(base_url, 'Schemas', Schema, schemas)
|
56
|
+
load_items(base_url, 'ResourceTypes', ResourceType, resource_types)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def load_items(base_url, path, type, items)
|
62
|
+
response = client.get(URI.join(base_url, path), headers: headers)
|
63
|
+
hashes = JSON.parse(response.body, symbolize_names: true)
|
64
|
+
hashes.each do |hash|
|
65
|
+
item = type.from(hash)
|
66
|
+
items[item.id] = item
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def client
|
71
|
+
@client ||= Net::Hippie::Client.new
|
72
|
+
end
|
73
|
+
|
74
|
+
def headers
|
75
|
+
{
|
76
|
+
'Accept' => 'application/scim+json',
|
77
|
+
'Content-Type' => 'application/scim+json'
|
78
|
+
}
|
46
79
|
end
|
47
80
|
end
|
48
81
|
end
|
data/lib/scim/kit/v2/meta.rb
CHANGED
@@ -21,6 +21,20 @@ module Scim
|
|
21
21
|
def disable_timestamps
|
22
22
|
@version = @created = @last_modified = nil
|
23
23
|
end
|
24
|
+
|
25
|
+
def self.from(hash)
|
26
|
+
meta = Meta.new(hash[:resourceType], hash[:location])
|
27
|
+
meta.created = parse_date(hash[:created])
|
28
|
+
meta.last_modified = parse_date(hash[:lastModified])
|
29
|
+
meta.version = hash[:version]
|
30
|
+
meta
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.parse_date(date)
|
34
|
+
DateTime.parse(date).to_time
|
35
|
+
rescue StandardError
|
36
|
+
nil
|
37
|
+
end
|
24
38
|
end
|
25
39
|
end
|
26
40
|
end
|
@@ -11,10 +11,13 @@ module Scim
|
|
11
11
|
WRITE_ONLY = 'writeOnly'
|
12
12
|
VALID = {
|
13
13
|
immutable: IMMUTABLE,
|
14
|
+
readOnly: READ_ONLY,
|
15
|
+
readWrite: READ_WRITE,
|
14
16
|
read_only: READ_ONLY,
|
15
17
|
read_write: READ_WRITE,
|
16
18
|
readonly: READ_ONLY,
|
17
19
|
readwrite: READ_WRITE,
|
20
|
+
writeOnly: WRITE_ONLY,
|
18
21
|
write_only: WRITE_ONLY,
|
19
22
|
writeonly: WRITE_ONLY
|
20
23
|
}.freeze
|
data/lib/scim/kit/v2/resource.rb
CHANGED
@@ -27,6 +27,10 @@ module Scim
|
|
27
27
|
yield self if block_given?
|
28
28
|
end
|
29
29
|
|
30
|
+
# Returns the current mode.
|
31
|
+
#
|
32
|
+
# @param type [Symbol] The mode `:server` or `:client`.
|
33
|
+
# @return [Boolean] Returns true if the resource matches the # type of mode
|
30
34
|
def mode?(type)
|
31
35
|
case type.to_sym
|
32
36
|
when :server
|
@@ -36,6 +40,8 @@ module Scim
|
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
43
|
+
# Returns the name of the jbuilder template file.
|
44
|
+
# @return [String] the name of the jbuilder template.
|
39
45
|
def template_name
|
40
46
|
'resource.json.jbuilder'
|
41
47
|
end
|
@@ -13,7 +13,7 @@ module Scim
|
|
13
13
|
attr_accessor :endpoint
|
14
14
|
attr_accessor :schema
|
15
15
|
attr_reader :schema_extensions
|
16
|
-
|
16
|
+
attr_accessor :meta
|
17
17
|
|
18
18
|
def initialize(location:)
|
19
19
|
@meta = Meta.new('ResourceType', location)
|
@@ -25,10 +25,28 @@ module Scim
|
|
25
25
|
@schema_extensions.push(schema: schema, required: required)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
class << self
|
29
|
+
def build(*args)
|
30
|
+
item = new(*args)
|
31
|
+
yield item
|
32
|
+
item
|
33
|
+
end
|
34
|
+
|
35
|
+
def from(hash)
|
36
|
+
x = new(location: hash[:location])
|
37
|
+
x.meta = Meta.from(hash[:meta])
|
38
|
+
%i[id name description endpoint schema].each do |key|
|
39
|
+
x.public_send("#{key}=", hash[key])
|
40
|
+
end
|
41
|
+
hash[:schemaExtensions].each do |y|
|
42
|
+
x.add_schema_extension(schema: y[:schema], required: y[:required])
|
43
|
+
end
|
44
|
+
x
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse(json)
|
48
|
+
from(JSON.parse(json, symbolize_names: true))
|
49
|
+
end
|
32
50
|
end
|
33
51
|
end
|
34
52
|
end
|
data/lib/scim/kit/v2/schema.rb
CHANGED
@@ -7,8 +7,8 @@ module Scim
|
|
7
7
|
class Schema
|
8
8
|
include Templatable
|
9
9
|
|
10
|
-
attr_reader :id, :name, :attributes
|
11
|
-
attr_accessor :description
|
10
|
+
attr_reader :id, :name, :attributes
|
11
|
+
attr_accessor :meta, :description
|
12
12
|
|
13
13
|
def initialize(id:, name:, location:)
|
14
14
|
@id = id
|
@@ -30,10 +30,29 @@ module Scim
|
|
30
30
|
id.include?(Schemas::CORE) || id.include?(Messages::CORE)
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
class << self
|
34
|
+
def build(*args)
|
35
|
+
item = new(*args)
|
36
|
+
yield item
|
37
|
+
item
|
38
|
+
end
|
39
|
+
|
40
|
+
def from(hash)
|
41
|
+
Schema.new(
|
42
|
+
id: hash[:id],
|
43
|
+
name: hash[:name],
|
44
|
+
location: hash[:location]
|
45
|
+
) do |x|
|
46
|
+
x.meta = Meta.from(hash[:meta])
|
47
|
+
hash[:attributes].each do |y|
|
48
|
+
x.attributes << AttributeType.from(y)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def parse(json)
|
54
|
+
from(JSON.parse(json, symbolize_names: true))
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|
39
58
|
end
|
@@ -6,14 +6,16 @@ module Scim
|
|
6
6
|
# Represents a scim Service Provider Configuration
|
7
7
|
class ServiceProviderConfiguration
|
8
8
|
include Templatable
|
9
|
-
|
10
|
-
attr_accessor :
|
11
|
-
|
12
|
-
|
13
|
-
attr_reader :bulk, :filter, :meta
|
9
|
+
attr_accessor :bulk, :filter
|
10
|
+
attr_accessor :etag, :sort, :change_password, :patch
|
11
|
+
attr_accessor :meta, :documentation_uri
|
12
|
+
attr_accessor :authentication_schemes
|
14
13
|
|
15
|
-
def initialize(
|
16
|
-
|
14
|
+
def initialize(
|
15
|
+
location:,
|
16
|
+
meta: Meta.new('ServiceProviderConfig', location)
|
17
|
+
)
|
18
|
+
@meta = meta
|
17
19
|
@authentication_schemes = []
|
18
20
|
@etag = Supportable.new
|
19
21
|
@sort = Supportable.new
|
@@ -28,6 +30,21 @@ module Scim
|
|
28
30
|
yield scheme if block_given?
|
29
31
|
@authentication_schemes << scheme
|
30
32
|
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
def parse(json, hash = JSON.parse(json, symbolize_names: true))
|
36
|
+
x = new(location: hash[:location], meta: Meta.from(hash[:meta]))
|
37
|
+
x.documentation_uri = hash[:documentationUri]
|
38
|
+
%i[patch changePassword sort etag filter bulk].each do |key|
|
39
|
+
x.send("#{key.to_s.underscore}=", Supportable.from(hash[key]))
|
40
|
+
end
|
41
|
+
schemes = hash[:authenticationSchemes]
|
42
|
+
x.authentication_schemes = schemes&.map do |auth|
|
43
|
+
AuthenticationScheme.from(auth)
|
44
|
+
end
|
45
|
+
x
|
46
|
+
end
|
47
|
+
end
|
31
48
|
end
|
32
49
|
end
|
33
50
|
end
|
@@ -11,11 +11,22 @@ module Scim
|
|
11
11
|
attr_accessor :supported
|
12
12
|
|
13
13
|
def initialize(*dynamic_attributes)
|
14
|
+
dynamic_attributes.delete(:supported)
|
14
15
|
@dynamic_attributes = Hash[
|
15
16
|
dynamic_attributes.map { |x| ["#{x}=".to_sym, nil] }
|
16
17
|
]
|
17
18
|
@supported = false
|
18
19
|
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def from(hash)
|
23
|
+
x = new(*hash.keys)
|
24
|
+
hash.each do |key, value|
|
25
|
+
x.public_send("#{key}=", value)
|
26
|
+
end
|
27
|
+
x
|
28
|
+
end
|
29
|
+
end
|
19
30
|
end
|
20
31
|
end
|
21
32
|
end
|
data/lib/scim/kit/version.rb
CHANGED
data/scim-kit.gemspec
CHANGED
@@ -28,8 +28,10 @@ Gem::Specification.new do |spec|
|
|
28
28
|
end
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
spec.required_ruby_version = '>= 2.5.0'
|
31
|
+
spec.metadata['yard.run'] = 'yri'
|
31
32
|
|
32
33
|
spec.add_dependency 'activemodel', '>= 5.2.0'
|
34
|
+
spec.add_dependency 'net-hippie', '~> 0.2'
|
33
35
|
spec.add_dependency 'tilt', '~> 2.0'
|
34
36
|
spec.add_dependency 'tilt-jbuilder', '~> 0.7'
|
35
37
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
@@ -40,4 +42,5 @@ Gem::Specification.new do |spec|
|
|
40
42
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
43
|
spec.add_development_dependency 'rubocop', '~> 0.52'
|
42
44
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.22'
|
45
|
+
spec.add_development_dependency 'webmock', '~> 3.5'
|
43
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scim-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-hippie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: tilt
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +178,20 @@ dependencies:
|
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '1.22'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: webmock
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '3.5'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '3.5'
|
167
195
|
description: A SCIM library.
|
168
196
|
email:
|
169
197
|
- mo@mokhan.ca
|
@@ -228,7 +256,8 @@ files:
|
|
228
256
|
homepage: https://www.github.com/mokhan/scim-kit
|
229
257
|
licenses:
|
230
258
|
- MIT
|
231
|
-
metadata:
|
259
|
+
metadata:
|
260
|
+
yard.run: yri
|
232
261
|
post_install_message:
|
233
262
|
rdoc_options: []
|
234
263
|
require_paths:
|