scimitar 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/scimitar/errors.rb +1 -1
- data/app/models/scimitar/schema/attribute.rb +1 -1
- data/app/models/scimitar/schema/base.rb +3 -1
- data/config/initializers/scimitar.rb +71 -67
- data/lib/scimitar/version.rb +2 -2
- data/spec/apps/dummy/config/application.rb +1 -0
- data/spec/apps/dummy/config/environments/test.rb +28 -5
- data/spec/apps/dummy/config/initializers/scimitar.rb +10 -8
- data/spec/models/scimitar/resources/user_spec.rb +4 -4
- data/spec/requests/application_controller_spec.rb +0 -1
- metadata +42 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95a2166cc921a400959f9d8d4398f6bf8ecb772f8d7a0a0a73950892e85d808a
|
4
|
+
data.tar.gz: cdf5aab3812f10f69c96304e738a150f4208850267527b66d36eeb99548d7b1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0925517599b107e44fd93db9be142aebe608892c2c5069c50d22b353c51238290710474b062a002fdb010be3d783c4dea3b314f72f47b4aca3c2385a8fc1377
|
7
|
+
data.tar.gz: eef6eebfc64bb2d4adabfca110f26e3a6c9e227f47387da6fb384925899ddf0ae260cf68176f24040a6bb356cf34f6576c920bd44264d4a1fee415aeadc237e6
|
@@ -26,7 +26,9 @@ module Scimitar
|
|
26
26
|
#
|
27
27
|
def self.valid?(resource)
|
28
28
|
cloned_scim_attributes.each do |scim_attribute|
|
29
|
-
|
29
|
+
unless scim_attribute.valid?(resource.send(scim_attribute.name))
|
30
|
+
resource.add_errors_from_hash(errors_hash: scim_attribute.errors.to_hash)
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -2,81 +2,85 @@
|
|
2
2
|
#
|
3
3
|
# For supporting information and rationale, please see README.md.
|
4
4
|
|
5
|
-
#
|
6
|
-
# SERVICE PROVIDER CONFIGURATION
|
7
|
-
# =============================================================================
|
8
|
-
#
|
9
|
-
# This is a Ruby abstraction over a SCIM entity that declares the capabilities
|
10
|
-
# supported by a particular implementation.
|
11
|
-
#
|
12
|
-
# Typically this is used to declare parts of the standard unsupported, if you
|
13
|
-
# don't need them and don't want to provide subclass support.
|
14
|
-
#
|
15
|
-
Scimitar.service_provider_configuration = Scimitar::ServiceProviderConfiguration.new({
|
5
|
+
Rails.application.config.to_prepare do # (required for >= Rails 7 / Zeitwerk)
|
16
6
|
|
17
|
-
#
|
7
|
+
# ===========================================================================
|
8
|
+
# SERVICE PROVIDER CONFIGURATION
|
9
|
+
# ===========================================================================
|
18
10
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# that filters are not supported so that calling clients shouldn't use them:
|
11
|
+
# This is a Ruby abstraction over a SCIM entity that declares the
|
12
|
+
# capabilities supported by a particular implementation.
|
22
13
|
#
|
23
|
-
#
|
14
|
+
# Typically this is used to declare parts of the standard unsupported, if you
|
15
|
+
# don't need them and don't want to provide subclass support.
|
16
|
+
#
|
17
|
+
Scimitar.service_provider_configuration = Scimitar::ServiceProviderConfiguration.new({
|
24
18
|
|
25
|
-
|
19
|
+
# See https://tools.ietf.org/html/rfc7643#section-8.5 for properties.
|
20
|
+
#
|
21
|
+
# See Gem file 'app/models/scimitar/service_provider_configuration.rb'
|
22
|
+
# for defaults. Define Hash keys here that override defaults; e.g. to
|
23
|
+
# declare that filters are not supported so that calling clients shouldn't
|
24
|
+
# use them:
|
25
|
+
#
|
26
|
+
# filter: Scimitar::Supported.unsupported
|
26
27
|
|
27
|
-
|
28
|
-
# ENGINE CONFIGURATION
|
29
|
-
# =============================================================================
|
30
|
-
#
|
31
|
-
# This is where you provide callbacks for things like authorisation or mixins
|
32
|
-
# that get included into all Scimitar-derived controllers (for things like
|
33
|
-
# before-actions that apply to all Scimitar controller-based routes).
|
34
|
-
#
|
35
|
-
Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
|
28
|
+
})
|
36
29
|
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
# For example:
|
30
|
+
# ===========================================================================
|
31
|
+
# ENGINE CONFIGURATION
|
32
|
+
# ===========================================================================
|
42
33
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
34
|
+
# This is where you provide callbacks for things like authorisation or mixins
|
35
|
+
# that get included into all Scimitar-derived controllers (for things like
|
36
|
+
# before-actions that apply to all Scimitar controller-based routes).
|
46
37
|
#
|
47
|
-
|
48
|
-
# # one of your controller classes, but it gets included in all
|
49
|
-
# # Scimitar classes too.
|
50
|
-
#
|
51
|
-
# skip_before_action :verify_authenticity_token
|
52
|
-
# prepend_before_action :setup_some_kind_of_multi_tenancy_data
|
53
|
-
# end
|
54
|
-
# end
|
55
|
-
# end, # ...other configuration entries might follow...
|
38
|
+
Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
|
56
39
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
40
|
+
# If you have filters you want to run for any Scimitar action/route, you
|
41
|
+
# can define them here. For example, you might use a before-action to set
|
42
|
+
# up some multi-tenancy related state, or skip Rails CSRF token
|
43
|
+
# verification. For example:
|
44
|
+
#
|
45
|
+
# application_controller_mixin: Module.new do
|
46
|
+
# def self.included(base)
|
47
|
+
# base.class_eval do
|
48
|
+
#
|
49
|
+
# # Anything here is written just as you'd write it at the top of
|
50
|
+
# # one of your controller classes, but it gets included in all
|
51
|
+
# # Scimitar classes too.
|
52
|
+
#
|
53
|
+
# skip_before_action :verify_authenticity_token
|
54
|
+
# prepend_before_action :setup_some_kind_of_multi_tenancy_data
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
# end, # ...other configuration entries might follow...
|
67
58
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
59
|
+
# If you want to support username/password authentication:
|
60
|
+
#
|
61
|
+
# basic_authenticator: Proc.new do | username, password |
|
62
|
+
# # Check username/password and return 'true' if valid, else 'false'.
|
63
|
+
# end, # ...other configuration entries might follow...
|
64
|
+
#
|
65
|
+
# The 'username' and 'password' parameters come from Rails:
|
66
|
+
#
|
67
|
+
# https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
|
68
|
+
# https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic/ControllerMethods.html#method-i-authenticate_with_http_basic
|
69
|
+
|
70
|
+
# If you want to support HTTP bearer token (OAuth-style) authentication:
|
71
|
+
#
|
72
|
+
# token_authenticator: Proc.new do | token, options |
|
73
|
+
# # Check token and return 'true' if valid, else 'false'.
|
74
|
+
# end, # ...other configuration entries might follow...
|
75
|
+
#
|
76
|
+
# The 'token' and 'options' parameters come from Rails:
|
77
|
+
#
|
78
|
+
# https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
|
79
|
+
# https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token/ControllerMethods.html#method-i-authenticate_with_http_token
|
80
|
+
#
|
81
|
+
# Note that both basic and token authentication can be declared, with the
|
82
|
+
# parameters in the inbound HTTP request determining which is invoked.
|
83
|
+
|
84
|
+
})
|
81
85
|
|
82
|
-
|
86
|
+
end
|
data/lib/scimitar/version.rb
CHANGED
@@ -3,11 +3,11 @@ module Scimitar
|
|
3
3
|
# Gem version. If this changes, be sure to re-run "bundle install" or
|
4
4
|
# "bundle update".
|
5
5
|
#
|
6
|
-
VERSION = '
|
6
|
+
VERSION = '2.0.0'
|
7
7
|
|
8
8
|
# Date for VERSION. If this changes, be sure to re-run "bundle install"
|
9
9
|
# or "bundle update".
|
10
10
|
#
|
11
|
-
DATE = '
|
11
|
+
DATE = '2022-03-04'
|
12
12
|
|
13
13
|
end
|
@@ -1,15 +1,38 @@
|
|
1
|
+
require 'active_support/core_ext/integer/time'
|
2
|
+
|
1
3
|
Rails.application.configure do
|
2
4
|
config.cache_classes = true
|
3
5
|
config.eager_load = false
|
4
|
-
config.serve_static_files = true
|
5
|
-
config.static_cache_control = 'public, max-age=3600'
|
6
|
-
config.consider_all_requests_local = true
|
7
6
|
|
8
|
-
|
7
|
+
# Configure public file server for tests with Cache-Control for performance.
|
8
|
+
config.public_file_server.enabled = true
|
9
|
+
config.public_file_server.headers = {
|
10
|
+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
|
11
|
+
}
|
9
12
|
|
13
|
+
# Show full error reports and disable caching.
|
14
|
+
config.consider_all_requests_local = true
|
10
15
|
config.action_controller.perform_caching = false
|
16
|
+
config.cache_store = :null_store
|
17
|
+
|
18
|
+
# Raise exceptions instead of rendering exception templates.
|
19
|
+
config.action_dispatch.show_exceptions = false
|
20
|
+
|
21
|
+
# Disable request forgery protection in test environment.
|
11
22
|
config.action_controller.allow_forgery_protection = false
|
12
23
|
|
13
|
-
|
24
|
+
# Print deprecation notices to the stderr.
|
14
25
|
config.active_support.deprecation = :stderr
|
26
|
+
|
27
|
+
# Raise exceptions for disallowed deprecations.
|
28
|
+
config.active_support.disallowed_deprecation = :raise
|
29
|
+
|
30
|
+
# Tell Active Support which deprecation messages to disallow.
|
31
|
+
config.active_support.disallowed_deprecation_warnings = []
|
32
|
+
|
33
|
+
# Raises error for missing translations.
|
34
|
+
config.i18n.raise_on_missing_translations = true
|
35
|
+
|
36
|
+
# Annotate rendered view with file names.
|
37
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
15
38
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# Test app configuration.
|
2
2
|
#
|
3
|
-
|
3
|
+
Rails.application.config.to_prepare do
|
4
|
+
Scimitar.engine_configuration = Scimitar::EngineConfiguration.new({
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
application_controller_mixin: Module.new do
|
7
|
+
def self.included(base)
|
8
|
+
base.class_eval do
|
9
|
+
def test_hook; end
|
10
|
+
before_action :test_hook
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
})
|
15
|
+
})
|
16
|
+
end
|
@@ -42,25 +42,25 @@ RSpec.describe Scimitar::Resources::User do
|
|
42
42
|
let(:user) { described_class.new }
|
43
43
|
|
44
44
|
it 'adds the error when the value is a string' do
|
45
|
-
user.add_errors_from_hash(key: 'some error')
|
45
|
+
user.add_errors_from_hash(errors_hash: {key: 'some error'})
|
46
46
|
expect(user.errors.messages.to_h).to eql({key: ['some error']})
|
47
47
|
expect(user.errors.full_messages).to eql(['Key some error'])
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'adds the error when the value is an array' do
|
51
|
-
user.add_errors_from_hash(key: ['error1', 'error2'])
|
51
|
+
user.add_errors_from_hash(errors_hash: {key: ['error1', 'error2']})
|
52
52
|
expect(user.errors.messages.to_h).to eql({key: ['error1', 'error2']})
|
53
53
|
expect(user.errors.full_messages).to eql(['Key error1', 'Key error2'])
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'adds the error with prefix when the value is a string' do
|
57
|
-
user.add_errors_from_hash({key: 'some error'}, prefix: :pre)
|
57
|
+
user.add_errors_from_hash(errors_hash: {key: 'some error'}, prefix: :pre)
|
58
58
|
expect(user.errors.messages.to_h).to eql({:'pre.key' => ['some error']})
|
59
59
|
expect(user.errors.full_messages).to eql(['Pre key some error'])
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'adds the error wity prefix when the value is an array' do
|
63
|
-
user.add_errors_from_hash({key: ['error1', 'error2']}, prefix: :pre)
|
63
|
+
user.add_errors_from_hash(errors_hash: {key: ['error1', 'error2']}, prefix: :pre)
|
64
64
|
expect(user.errors.messages.to_h).to eql({:'pre.key' => ['error1', 'error2']})
|
65
65
|
expect(user.errors.full_messages).to eql(['Pre key error1', 'Pre key error2'])
|
66
66
|
end
|
@@ -23,7 +23,6 @@ RSpec.describe Scimitar::ApplicationController do
|
|
23
23
|
|
24
24
|
expect(response).to have_http_status(:bad_request)
|
25
25
|
expect(JSON.parse(response.body)['detail']).to start_with('Invalid JSON - ')
|
26
|
-
expect(JSON.parse(response.body)['detail']).to include("'not-json-12345'")
|
27
26
|
end
|
28
27
|
|
29
28
|
it 'translates Content-Type to Rails request format' do
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scimitar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RIPA Global
|
8
8
|
- Andrew David Hodgkinson
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '7.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '7.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '6.
|
76
|
+
version: '6.4'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '6.
|
83
|
+
version: '6.4'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rspec-rails
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,7 +245,7 @@ metadata:
|
|
245
245
|
source_code_uri: https://github.com/RIPAGlobal/scimitar/
|
246
246
|
bug_tracker_uri: https://github.com/RIPAGlobal/scimitar/issues/
|
247
247
|
changelog_uri: https://github.com/RIPAGlobal/scimitar/blob/master/CHANGELOG.md
|
248
|
-
post_install_message:
|
248
|
+
post_install_message:
|
249
249
|
rdoc_options: []
|
250
250
|
require_paths:
|
251
251
|
- lib
|
@@ -260,51 +260,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
260
|
- !ruby/object:Gem::Version
|
261
261
|
version: '0'
|
262
262
|
requirements: []
|
263
|
-
rubygems_version: 3.
|
264
|
-
signing_key:
|
263
|
+
rubygems_version: 3.3.3
|
264
|
+
signing_key:
|
265
265
|
specification_version: 4
|
266
266
|
summary: SCIM v2 for Rails
|
267
267
|
test_files:
|
268
|
-
- spec/
|
269
|
-
- spec/
|
268
|
+
- spec/apps/dummy/app/controllers/custom_destroy_mock_users_controller.rb
|
269
|
+
- spec/apps/dummy/app/controllers/custom_request_verifiers_controller.rb
|
270
|
+
- spec/apps/dummy/app/controllers/mock_groups_controller.rb
|
271
|
+
- spec/apps/dummy/app/controllers/mock_users_controller.rb
|
272
|
+
- spec/apps/dummy/app/models/mock_group.rb
|
273
|
+
- spec/apps/dummy/app/models/mock_user.rb
|
274
|
+
- spec/apps/dummy/config/application.rb
|
275
|
+
- spec/apps/dummy/config/boot.rb
|
276
|
+
- spec/apps/dummy/config/environment.rb
|
277
|
+
- spec/apps/dummy/config/environments/test.rb
|
278
|
+
- spec/apps/dummy/config/initializers/cookies_serializer.rb
|
279
|
+
- spec/apps/dummy/config/initializers/scimitar.rb
|
280
|
+
- spec/apps/dummy/config/initializers/session_store.rb
|
281
|
+
- spec/apps/dummy/config/routes.rb
|
282
|
+
- spec/apps/dummy/db/migrate/20210304014602_create_mock_users.rb
|
283
|
+
- spec/apps/dummy/db/migrate/20210308020313_create_mock_groups.rb
|
284
|
+
- spec/apps/dummy/db/migrate/20210308044214_create_join_table_mock_groups_mock_users.rb
|
285
|
+
- spec/apps/dummy/db/schema.rb
|
286
|
+
- spec/controllers/scimitar/application_controller_spec.rb
|
287
|
+
- spec/controllers/scimitar/resource_types_controller_spec.rb
|
288
|
+
- spec/controllers/scimitar/resources_controller_spec.rb
|
289
|
+
- spec/controllers/scimitar/schemas_controller_spec.rb
|
290
|
+
- spec/controllers/scimitar/service_provider_configurations_controller_spec.rb
|
291
|
+
- spec/models/scimitar/complex_types/address_spec.rb
|
292
|
+
- spec/models/scimitar/complex_types/email_spec.rb
|
270
293
|
- spec/models/scimitar/lists/count_spec.rb
|
294
|
+
- spec/models/scimitar/lists/query_parser_spec.rb
|
295
|
+
- spec/models/scimitar/resource_type_spec.rb
|
296
|
+
- spec/models/scimitar/resources/base_spec.rb
|
271
297
|
- spec/models/scimitar/resources/base_validation_spec.rb
|
272
298
|
- spec/models/scimitar/resources/mixin_spec.rb
|
273
299
|
- spec/models/scimitar/resources/user_spec.rb
|
274
|
-
- spec/models/scimitar/resources/base_spec.rb
|
275
300
|
- spec/models/scimitar/schema/attribute_spec.rb
|
301
|
+
- spec/models/scimitar/schema/base_spec.rb
|
276
302
|
- spec/models/scimitar/schema/group_spec.rb
|
277
303
|
- spec/models/scimitar/schema/user_spec.rb
|
278
|
-
- spec/models/scimitar/schema/base_spec.rb
|
279
|
-
- spec/models/scimitar/resource_type_spec.rb
|
280
|
-
- spec/models/scimitar/complex_types/email_spec.rb
|
281
|
-
- spec/models/scimitar/complex_types/address_spec.rb
|
282
|
-
- spec/requests/controller_configuration_spec.rb
|
283
|
-
- spec/requests/engine_spec.rb
|
284
304
|
- spec/requests/active_record_backed_resources_controller_spec.rb
|
285
305
|
- spec/requests/application_controller_spec.rb
|
306
|
+
- spec/requests/controller_configuration_spec.rb
|
307
|
+
- spec/requests/engine_spec.rb
|
308
|
+
- spec/spec_helper.rb
|
286
309
|
- spec/spec_helper_spec.rb
|
287
310
|
- spec/support/hash_with_indifferent_case_insensitive_access_spec.rb
|
288
|
-
- spec/controllers/scimitar/schemas_controller_spec.rb
|
289
|
-
- spec/controllers/scimitar/resource_types_controller_spec.rb
|
290
|
-
- spec/controllers/scimitar/resources_controller_spec.rb
|
291
|
-
- spec/controllers/scimitar/service_provider_configurations_controller_spec.rb
|
292
|
-
- spec/controllers/scimitar/application_controller_spec.rb
|
293
|
-
- spec/apps/dummy/app/models/mock_group.rb
|
294
|
-
- spec/apps/dummy/app/models/mock_user.rb
|
295
|
-
- spec/apps/dummy/app/controllers/custom_request_verifiers_controller.rb
|
296
|
-
- spec/apps/dummy/app/controllers/custom_destroy_mock_users_controller.rb
|
297
|
-
- spec/apps/dummy/app/controllers/mock_groups_controller.rb
|
298
|
-
- spec/apps/dummy/app/controllers/mock_users_controller.rb
|
299
|
-
- spec/apps/dummy/config/routes.rb
|
300
|
-
- spec/apps/dummy/config/environments/test.rb
|
301
|
-
- spec/apps/dummy/config/environment.rb
|
302
|
-
- spec/apps/dummy/config/application.rb
|
303
|
-
- spec/apps/dummy/config/boot.rb
|
304
|
-
- spec/apps/dummy/config/initializers/session_store.rb
|
305
|
-
- spec/apps/dummy/config/initializers/cookies_serializer.rb
|
306
|
-
- spec/apps/dummy/config/initializers/scimitar.rb
|
307
|
-
- spec/apps/dummy/db/schema.rb
|
308
|
-
- spec/apps/dummy/db/migrate/20210308020313_create_mock_groups.rb
|
309
|
-
- spec/apps/dummy/db/migrate/20210308044214_create_join_table_mock_groups_mock_users.rb
|
310
|
-
- spec/apps/dummy/db/migrate/20210304014602_create_mock_users.rb
|