scim_rails 0.2.0 → 0.2.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 +4 -4
- data/app/controllers/scim_rails/scim_users_controller.rb +11 -7
- data/lib/generators/scim_rails/templates/initializer.rb +6 -2
- data/lib/scim_rails/config.rb +2 -1
- data/lib/scim_rails/version.rb +1 -1
- data/spec/controllers/scim_rails/scim_users_controller_spec.rb +20 -0
- metadata +2 -10
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -37
- data/spec/dummy/log/test.log +0 -56770
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2fdd85f73785a5e6f541f9d5ce4948f1881391215b55235480b398d64352c52
|
4
|
+
data.tar.gz: d1003817197e93ae0669250b8cdef586447890ed79cc76ebbed71ecb77308d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acd22821b645cf7d3aed942cdf061b0264318474c0af65aef1787c44c304cfc477b77616f527034da2e03e4cd1d3a637ce9710ea5527578e768031662b408fd2
|
7
|
+
data.tar.gz: dddf0587bd64c1202e9088b6967378187a595e3e2abb67ef853a7b13e02ef1505775aae0dfec436b5fbf14fe696c7173dad596f9356d9d95b56186b0c3d977f6
|
@@ -27,13 +27,17 @@ module ScimRails
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def create
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
.
|
35
|
-
|
36
|
-
|
30
|
+
if ScimRails.config.scim_user_prevent_update_on_create
|
31
|
+
user = @company.public_send(ScimRails.config.scim_users_scope).create!(permitted_user_params)
|
32
|
+
else
|
33
|
+
username_key = ScimRails.config.queryable_user_attributes[:userName]
|
34
|
+
find_by_username = Hash.new
|
35
|
+
find_by_username[username_key] = permitted_user_params[username_key]
|
36
|
+
user = @company
|
37
|
+
.public_send(ScimRails.config.scim_users_scope)
|
38
|
+
.find_or_create_by(find_by_username)
|
39
|
+
user.update!(permitted_user_params)
|
40
|
+
end
|
37
41
|
update_status(user) unless put_active_param.nil?
|
38
42
|
json_scim_response(object: user, status: :created)
|
39
43
|
end
|
@@ -18,6 +18,10 @@ ScimRails.configure do |config|
|
|
18
18
|
# authenticatable model.
|
19
19
|
config.scim_users_scope = :users
|
20
20
|
|
21
|
+
# Determine whether the create endpoint updates users that already exist
|
22
|
+
# or throws an error (returning 409 Conflict in accordance with SCIM spec)
|
23
|
+
config.scim_user_prevent_update_on_create = false
|
24
|
+
|
21
25
|
# Default sort order for pagination is by id. If you
|
22
26
|
# use non sequential ids for user records, uncomment
|
23
27
|
# the below line and configure a determinate order.
|
@@ -33,7 +37,7 @@ ScimRails.configure do |config|
|
|
33
37
|
# Hash of queryable attribtues on the user model. If
|
34
38
|
# the attribute is not listed in this hash it cannot
|
35
39
|
# be queried by this Gem. The structure of this hash
|
36
|
-
# is { queryable_scim_attribute => user_attribute }.
|
40
|
+
# is { queryable_scim_attribute => user_attribute }.
|
37
41
|
config.queryable_user_attributes = {
|
38
42
|
userName: :email,
|
39
43
|
givenName: :first_name,
|
@@ -54,7 +58,7 @@ ScimRails.configure do |config|
|
|
54
58
|
# for this Gem to figure out where to look in a SCIM
|
55
59
|
# response for mutable values. This object should
|
56
60
|
# include all attributes listed in
|
57
|
-
# config.mutable_user_attributes.
|
61
|
+
# config.mutable_user_attributes.
|
58
62
|
config.mutable_user_attributes_schema = {
|
59
63
|
name: {
|
60
64
|
givenName: :first_name,
|
data/lib/scim_rails/config.rb
CHANGED
@@ -20,11 +20,12 @@ module ScimRails
|
|
20
20
|
:scim_users_list_order,
|
21
21
|
:scim_users_model,
|
22
22
|
:scim_users_scope,
|
23
|
+
:scim_user_prevent_update_on_create,
|
23
24
|
:user_attributes,
|
24
25
|
:user_deprovision_method,
|
25
26
|
:user_reprovision_method,
|
26
27
|
:user_schema
|
27
|
-
|
28
|
+
|
28
29
|
def initialize
|
29
30
|
@basic_auth_model = "Company"
|
30
31
|
@scim_users_list_order = :id
|
data/lib/scim_rails/version.rb
CHANGED
@@ -325,6 +325,26 @@ RSpec.describe ScimRails::ScimUsersController, type: :controller do
|
|
325
325
|
expect(company.users.first.first_name).to eq "Not New"
|
326
326
|
end
|
327
327
|
|
328
|
+
it "returns 409 if user already exists and config.scim_user_prevent_update_on_create is set to true" do
|
329
|
+
allow(ScimRails.config).to receive(:scim_user_prevent_update_on_create).and_return(true)
|
330
|
+
create(:user, email: "new@example.com", company: company)
|
331
|
+
|
332
|
+
post :create, params: {
|
333
|
+
name: {
|
334
|
+
givenName: "Not New",
|
335
|
+
familyName: "User"
|
336
|
+
},
|
337
|
+
emails: [
|
338
|
+
{
|
339
|
+
value: "new@example.com"
|
340
|
+
}
|
341
|
+
]
|
342
|
+
}
|
343
|
+
|
344
|
+
expect(response.status).to eq 409
|
345
|
+
expect(company.users.count).to eq 1
|
346
|
+
end
|
347
|
+
|
328
348
|
it "creates and archives inactive user" do
|
329
349
|
post :create, params: {
|
330
350
|
id: 1,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scim_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spencer Alan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -178,14 +178,10 @@ files:
|
|
178
178
|
- spec/dummy/config/routes.rb
|
179
179
|
- spec/dummy/config/secrets.yml
|
180
180
|
- spec/dummy/config/spring.rb
|
181
|
-
- spec/dummy/db/development.sqlite3
|
182
181
|
- spec/dummy/db/migrate/20181206184304_create_users.rb
|
183
182
|
- spec/dummy/db/migrate/20181206184313_create_companies.rb
|
184
183
|
- spec/dummy/db/schema.rb
|
185
184
|
- spec/dummy/db/seeds.rb
|
186
|
-
- spec/dummy/db/test.sqlite3
|
187
|
-
- spec/dummy/log/development.log
|
188
|
-
- spec/dummy/log/test.log
|
189
185
|
- spec/dummy/public/404.html
|
190
186
|
- spec/dummy/public/422.html
|
191
187
|
- spec/dummy/public/500.html
|
@@ -278,12 +274,8 @@ test_files:
|
|
278
274
|
- spec/dummy/public/apple-touch-icon-precomposed.png
|
279
275
|
- spec/dummy/db/schema.rb
|
280
276
|
- spec/dummy/db/seeds.rb
|
281
|
-
- spec/dummy/db/test.sqlite3
|
282
277
|
- spec/dummy/db/migrate/20181206184304_create_users.rb
|
283
278
|
- spec/dummy/db/migrate/20181206184313_create_companies.rb
|
284
|
-
- spec/dummy/db/development.sqlite3
|
285
|
-
- spec/dummy/log/test.log
|
286
|
-
- spec/dummy/log/development.log
|
287
279
|
- spec/support/factory_bot.rb
|
288
280
|
- spec/support/auth_helper.rb
|
289
281
|
- spec/support/scim_rails_config.rb
|
Binary file
|
data/spec/dummy/db/test.sqlite3
DELETED
Binary file
|
@@ -1,37 +0,0 @@
|
|
1
|
-
[1m[35m (1.5ms)[0m [1m[35mCREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "subdomain" varchar NOT NULL, "api_token" varchar NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
2
|
-
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar NOT NULL, "last_name" varchar NOT NULL, "email" varchar NOT NULL, "company_id" integer, "archived_at" datetime, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
3
|
-
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
4
|
-
[1m[35m (0.1ms)[0m [1m[34mSELECT version FROM "schema_migrations"[0m
|
5
|
-
[1m[35m (0.7ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20181206184313)[0m
|
6
|
-
[1m[35m (0.1ms)[0m [1m[34mselect sqlite_version(*)[0m
|
7
|
-
[1m[35m (0.7ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
8
|
-
(20181206184304);
|
9
|
-
|
10
|
-
[0m
|
11
|
-
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
12
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
13
|
-
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
14
|
-
[1m[35mSQL (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", "2019-04-04 18:34:57.670031"], ["updated_at", "2019-04-04 18:34:57.670031"]]
|
15
|
-
[1m[35m (0.7ms)[0m [1m[36mcommit transaction[0m
|
16
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
17
|
-
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
18
|
-
[1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m
|
19
|
-
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "subdomain" varchar NOT NULL, "api_token" varchar NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
20
|
-
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar NOT NULL, "last_name" varchar NOT NULL, "email" varchar NOT NULL, "company_id" integer, "archived_at" datetime, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
21
|
-
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
22
|
-
[1m[35m (0.1ms)[0m [1m[34mSELECT version FROM "schema_migrations"[0m
|
23
|
-
[1m[35m (0.8ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20181206184313)[0m
|
24
|
-
[1m[35m (0.0ms)[0m [1m[34mselect sqlite_version(*)[0m
|
25
|
-
[1m[35m (0.8ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
26
|
-
(20181206184304);
|
27
|
-
|
28
|
-
[0m
|
29
|
-
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
30
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
31
|
-
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
32
|
-
[1m[35mSQL (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", "2019-04-04 18:34:57.684014"], ["updated_at", "2019-04-04 18:34:57.684014"]]
|
33
|
-
[1m[35m (0.6ms)[0m [1m[36mcommit transaction[0m
|
34
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
35
|
-
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
36
|
-
[1m[35mSQL (0.2ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = ?, "updated_at" = ? WHERE "ar_internal_metadata"."key" = ?[0m [["value", "test"], ["updated_at", "2019-04-04 18:34:57.686570"], ["key", "environment"]]
|
37
|
-
[1m[35m (0.6ms)[0m [1m[36mcommit transaction[0m
|