infinum_id 1.6.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/CHANGES.md +11 -0
- data/Gemfile.lock +23 -23
- data/README.md +9 -7
- data/app/blueprints/infinum_id/resource_blueprint.rb +1 -1
- data/app/controllers/infinum_id/api/webhooks_controller.rb +12 -19
- data/app/services/infinum_id/after_resource_intent.rb +6 -0
- data/app/services/infinum_id/after_resource_upsert.rb +5 -0
- data/app/services/infinum_id/requests/invite_sender.rb +5 -1
- data/app/services/infinum_id/resources/updater.rb +5 -1
- data/config/routes.rb +2 -3
- data/lib/generators/templates/migration.rb +1 -0
- data/lib/generators/templates/user.rb +1 -0
- data/lib/infinum_id.rb +3 -2
- data/lib/infinum_id/version.rb +1 -1
- metadata +9 -9
- data/app/services/infinum_id/after_resource_create.rb +0 -5
- data/app/services/infinum_id/after_resource_update.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7890955304e9d46d659e4912ed2a0db17215059091d6841f48b182a966a52b7b
|
4
|
+
data.tar.gz: 8599516a3f14cfa1d9df62572842167884219ce3ac10f514757d271b66fe6b38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99287be6aafcbf0c0e600dbfb7bdd5fed5b37ca9eb1bb5b3f26b0ab60bb0c51dddc079f4366ab30780a1851f3d82837be702325b92ce129981de5a5d775b62c9
|
7
|
+
data.tar.gz: 6b0def3b8d25f851aa46b89c15a90723e9c334926e41c542489e50f7ddbb6be5dc8fee00dd06feebee18151acd87505ee0cdb6ea1ea1fa2227305b89688ea48e
|
data/CHANGES.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Version 2.0.0
|
4
|
+
|
5
|
+
Released of September 18, 2020
|
6
|
+
|
7
|
+
Changes:
|
8
|
+
* [BREAKING] Removed `InfinumId::AfterResourceCreate` and `InfinumId::AfterResourceUpdate` classes.
|
9
|
+
* [BREAKING] Added `InfinumId::AfterResourceUpsert` and `InfinumId::AfterResourceIntent` classes. see [Webhooks](README.md#webhooks) for more info
|
10
|
+
* [BREAKING] Removed `/webhooks#update_resource_callback` and `/webhooks#create_resource_callback` routes.
|
11
|
+
* [BREAKING] Added `/webhook#upsert_resource_callback` route.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
infinum_id (
|
4
|
+
infinum_id (2.0.0)
|
5
5
|
blueprinter
|
6
6
|
bundler
|
7
7
|
devise
|
@@ -57,8 +57,8 @@ GEM
|
|
57
57
|
addressable (2.6.0)
|
58
58
|
public_suffix (>= 2.0.2, < 4.0)
|
59
59
|
arel (9.0.0)
|
60
|
-
bcrypt (3.1.
|
61
|
-
blueprinter (0.
|
60
|
+
bcrypt (3.1.16)
|
61
|
+
blueprinter (0.25.1)
|
62
62
|
builder (3.2.3)
|
63
63
|
byebug (10.0.2)
|
64
64
|
coderay (1.1.2)
|
@@ -66,7 +66,7 @@ GEM
|
|
66
66
|
crack (0.4.3)
|
67
67
|
safe_yaml (~> 1.0.0)
|
68
68
|
crass (1.0.4)
|
69
|
-
devise (4.7.
|
69
|
+
devise (4.7.2)
|
70
70
|
bcrypt (~> 3.0)
|
71
71
|
orm_adapter (~> 0.1)
|
72
72
|
railties (>= 4.1.0)
|
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
docile (1.3.1)
|
77
77
|
domain_name (0.5.20190701)
|
78
78
|
unf (>= 0.0.5, < 1.0.0)
|
79
|
-
dry-configurable (0.11.
|
79
|
+
dry-configurable (0.11.6)
|
80
80
|
concurrent-ruby (~> 1.0)
|
81
81
|
dry-core (~> 0.4, >= 0.4.7)
|
82
82
|
dry-equalizer (~> 0.2)
|
@@ -91,30 +91,30 @@ GEM
|
|
91
91
|
railties (>= 4.2.0)
|
92
92
|
faker (1.9.1)
|
93
93
|
i18n (>= 0.7)
|
94
|
-
faraday (1.0.
|
94
|
+
faraday (1.0.1)
|
95
95
|
multipart-post (>= 1.2, < 3)
|
96
|
-
ffi (1.
|
96
|
+
ffi (1.13.1)
|
97
97
|
ffi-compiler (1.0.1)
|
98
98
|
ffi (>= 1.0.0)
|
99
99
|
rake
|
100
100
|
globalid (0.4.2)
|
101
101
|
activesupport (>= 4.2.0)
|
102
102
|
hashdiff (0.3.8)
|
103
|
-
hashie (
|
104
|
-
http (4.
|
103
|
+
hashie (4.1.0)
|
104
|
+
http (4.4.1)
|
105
105
|
addressable (~> 2.3)
|
106
106
|
http-cookie (~> 1.0)
|
107
107
|
http-form_data (~> 2.2)
|
108
108
|
http-parser (~> 1.2.0)
|
109
109
|
http-cookie (1.0.3)
|
110
110
|
domain_name (~> 0.5)
|
111
|
-
http-form_data (2.
|
111
|
+
http-form_data (2.3.0)
|
112
112
|
http-parser (1.2.1)
|
113
113
|
ffi-compiler (>= 1.0, < 2.0)
|
114
114
|
i18n (1.5.3)
|
115
115
|
concurrent-ruby (~> 1.0)
|
116
116
|
json (2.1.0)
|
117
|
-
jwt (2.2.
|
117
|
+
jwt (2.2.2)
|
118
118
|
loofah (2.2.3)
|
119
119
|
crass (~> 1.0.2)
|
120
120
|
nokogiri (>= 1.5.9)
|
@@ -127,7 +127,7 @@ GEM
|
|
127
127
|
mini_mime (1.0.1)
|
128
128
|
mini_portile2 (2.4.0)
|
129
129
|
minitest (5.11.3)
|
130
|
-
multi_json (1.
|
130
|
+
multi_json (1.15.0)
|
131
131
|
multi_xml (0.6.0)
|
132
132
|
multipart-post (2.1.1)
|
133
133
|
nio4r (2.3.1)
|
@@ -139,13 +139,13 @@ GEM
|
|
139
139
|
multi_json (~> 1.3)
|
140
140
|
multi_xml (~> 0.5)
|
141
141
|
rack (>= 1.2, < 3)
|
142
|
-
omniauth (1.9.
|
143
|
-
hashie (>= 3.4.6
|
142
|
+
omniauth (1.9.1)
|
143
|
+
hashie (>= 3.4.6)
|
144
144
|
rack (>= 1.6.2, < 3)
|
145
|
-
omniauth-infinum_id (1.1
|
145
|
+
omniauth-infinum_id (1.2.1)
|
146
146
|
omniauth-oauth2
|
147
|
-
omniauth-oauth2 (1.
|
148
|
-
oauth2 (~> 1.
|
147
|
+
omniauth-oauth2 (1.7.0)
|
148
|
+
oauth2 (~> 1.4)
|
149
149
|
omniauth (~> 1.9)
|
150
150
|
orm_adapter (0.5.0)
|
151
151
|
pry (0.12.2)
|
@@ -157,7 +157,7 @@ GEM
|
|
157
157
|
pry-rails (0.3.9)
|
158
158
|
pry (>= 0.10.4)
|
159
159
|
public_suffix (3.0.3)
|
160
|
-
rack (2.
|
160
|
+
rack (2.2.3)
|
161
161
|
rack-test (1.1.0)
|
162
162
|
rack (>= 1.0, < 3)
|
163
163
|
rails (5.2.2)
|
@@ -185,7 +185,7 @@ GEM
|
|
185
185
|
rake (>= 0.8.7)
|
186
186
|
thor (>= 0.19.0, < 2.0)
|
187
187
|
rake (10.5.0)
|
188
|
-
responders (3.0.
|
188
|
+
responders (3.0.1)
|
189
189
|
actionpack (>= 5.0)
|
190
190
|
railties (>= 5.0)
|
191
191
|
rspec (3.8.0)
|
@@ -229,9 +229,9 @@ GEM
|
|
229
229
|
thread_safe (~> 0.1)
|
230
230
|
unf (0.1.4)
|
231
231
|
unf_ext
|
232
|
-
unf_ext (0.0.7.
|
233
|
-
warden (1.2.
|
234
|
-
rack (>= 2.0.
|
232
|
+
unf_ext (0.0.7.7)
|
233
|
+
warden (1.2.9)
|
234
|
+
rack (>= 2.0.9)
|
235
235
|
webmock (3.5.1)
|
236
236
|
addressable (>= 2.3.6)
|
237
237
|
crack (>= 0.3.2)
|
@@ -260,4 +260,4 @@ DEPENDENCIES
|
|
260
260
|
webmock
|
261
261
|
|
262
262
|
BUNDLED WITH
|
263
|
-
2.
|
263
|
+
2.1.4
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ module InfinumId
|
|
51
51
|
class ResourceBlueprint < Blueprinter::Base
|
52
52
|
identifier :email
|
53
53
|
|
54
|
-
fields :first_name, :last_name
|
54
|
+
fields :first_name, :last_name, :employee
|
55
55
|
|
56
56
|
field :slack_username
|
57
57
|
field :avatar_url, as: :avatar_remote_url
|
@@ -80,7 +80,7 @@ InfinumId.configure do |config|
|
|
80
80
|
config.service_name = 'Revisor'
|
81
81
|
config.resource_name = 'User'
|
82
82
|
config.send_invite_request = !Rails.env.test? # to disable in tests
|
83
|
-
config.resource_attributes = [:uid, :email, :first_name, :last_name, :deactivated_at, :time_zone, :avatar_url, :slack_username]
|
83
|
+
config.resource_attributes = [:uid, :email, :first_name, :last_name, :deactivated_at, :time_zone, :avatar_url, :slack_username, :employee]
|
84
84
|
end
|
85
85
|
```
|
86
86
|
|
@@ -135,20 +135,22 @@ end
|
|
135
135
|
## Features
|
136
136
|
|
137
137
|
<details>
|
138
|
-
<summary><big><b>Webhooks</b></big></summary>
|
138
|
+
<summary><big><b id="webhooks">Webhooks</b></big></summary>
|
139
139
|
<hr />
|
140
|
-
In engine there are two webhooks: UpdateResourceCallback & CreateResourceCallback
|
140
|
+
In engine there are two webhooks: `UpdateResourceCallback` & `CreateResourceCallback`.
|
141
141
|
|
142
142
|
When user is created or updated on InfinumID these webhooks are called and then resource is created or updated accordingly.
|
143
143
|
|
144
|
-
After resource is created or updated methods InfinumId::
|
144
|
+
After resource is created or updated methods `InfinumId::AfterResourceUpsert` is called. So if resource can't be created before setting role, you can override this class and set role that way.
|
145
|
+
|
146
|
+
`intent` is one of `InfinumId::AfterResourceIntent::CREATE` or `InfinumId::AfterResourceIntent::UPDATE.`
|
145
147
|
|
146
148
|
```ruby
|
147
149
|
# app/services/infinum_id/after_resource_create.rb
|
148
150
|
|
149
151
|
module InfinumId
|
150
|
-
class
|
151
|
-
def self.call(person,
|
152
|
+
class AfterResourceUpsert
|
153
|
+
def self.call(person, _params = nil, _intent = nil)
|
152
154
|
person.update(employee: true)
|
153
155
|
end
|
154
156
|
end
|
@@ -1,24 +1,14 @@
|
|
1
1
|
module InfinumId
|
2
2
|
module Api
|
3
3
|
class WebhooksController < Api::BaseController
|
4
|
-
def
|
5
|
-
|
4
|
+
def upsert_resource_callback
|
5
|
+
intent, resource = upsert
|
6
6
|
|
7
|
-
|
8
|
-
InfinumId::AfterResourceUpdate.call(resource, params[:user])
|
7
|
+
InfinumId::AfterResourceUpsert.call(resource, params[:user], intent)
|
9
8
|
|
10
9
|
render json: { resource_name.underscore => 'updated' }
|
11
10
|
end
|
12
11
|
|
13
|
-
def create_resource_callback
|
14
|
-
return render_already_exists if resource
|
15
|
-
|
16
|
-
resource = resource_class.create(user_params.merge(provider: params[:provider]))
|
17
|
-
InfinumId::AfterResourceCreate.call(resource, params[:user])
|
18
|
-
|
19
|
-
render json: { resource_name.underscore => 'created' }
|
20
|
-
end
|
21
|
-
|
22
12
|
private
|
23
13
|
|
24
14
|
def user_params
|
@@ -26,17 +16,20 @@ module InfinumId
|
|
26
16
|
end
|
27
17
|
|
28
18
|
def resource
|
29
|
-
@resource ||=
|
19
|
+
@resource ||=
|
30
20
|
resource_class.find_by(uid: user_params[:uid], provider: params[:provider]) ||
|
31
21
|
resource_class.find_by(email: user_params[:email])
|
32
22
|
end
|
33
23
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
24
|
+
def upsert
|
25
|
+
if resource
|
26
|
+
resource.update(user_params)
|
27
|
+
[InfinumId::AfterResourceIntent::UPDATE, resource]
|
28
|
+
else
|
29
|
+
@resource = resource_class.create(user_params.merge(provider: params[:provider]))
|
37
30
|
|
38
|
-
|
39
|
-
|
31
|
+
[InfinumId::AfterResourceIntent::CREATE, resource]
|
32
|
+
end
|
40
33
|
end
|
41
34
|
end
|
42
35
|
end
|
@@ -39,7 +39,11 @@ module InfinumId
|
|
39
39
|
|
40
40
|
def update_resource
|
41
41
|
resource.update(user_params.merge(provider: 'infinum_id'))
|
42
|
-
InfinumId::
|
42
|
+
InfinumId::AfterResourceUpsert.call(
|
43
|
+
resource,
|
44
|
+
params[:user],
|
45
|
+
InfinumId::AfterResourceIntent::UPDATE
|
46
|
+
)
|
43
47
|
end
|
44
48
|
|
45
49
|
def send_email
|
data/config/routes.rb
CHANGED
@@ -7,9 +7,8 @@ Rails.application.routes.draw do
|
|
7
7
|
|
8
8
|
namespace :infinum_id do
|
9
9
|
namespace :api do
|
10
|
-
scope '/webhooks', :
|
11
|
-
post :
|
12
|
-
post :create_resource_callback
|
10
|
+
scope '/webhooks', controller: :webhooks do
|
11
|
+
post :upsert_resource_callback
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
data/lib/infinum_id.rb
CHANGED
@@ -14,8 +14,9 @@ module InfinumId
|
|
14
14
|
setting :infinum_id_send_email, false, reader: true
|
15
15
|
setting :send_invite_request, true, reader: true
|
16
16
|
|
17
|
-
setting :resource_attributes,
|
18
|
-
|
17
|
+
setting :resource_attributes,
|
18
|
+
[:uid, :email, :first_name, :last_name, :deactivated_at, :employee],
|
19
|
+
reader: true
|
19
20
|
|
20
21
|
def self.resource_class
|
21
22
|
resource_name.constantize
|
data/lib/infinum_id/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infinum_id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dajana Jeroncic
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -301,6 +301,7 @@ files:
|
|
301
301
|
- ".rspec"
|
302
302
|
- ".rubocop.yml"
|
303
303
|
- ".travis.yml"
|
304
|
+
- CHANGES.md
|
304
305
|
- CODE_OF_CONDUCT.md
|
305
306
|
- Gemfile
|
306
307
|
- Gemfile.lock
|
@@ -317,8 +318,8 @@ files:
|
|
317
318
|
- app/mailers/infinum_id/application_mailer.rb
|
318
319
|
- app/mailers/infinum_id/mailer.rb
|
319
320
|
- app/models/infinum_id/application_record.rb
|
320
|
-
- app/services/infinum_id/
|
321
|
-
- app/services/infinum_id/
|
321
|
+
- app/services/infinum_id/after_resource_intent.rb
|
322
|
+
- app/services/infinum_id/after_resource_upsert.rb
|
322
323
|
- app/services/infinum_id/requests/invite_sender.rb
|
323
324
|
- app/services/infinum_id/resources/finder.rb
|
324
325
|
- app/services/infinum_id/resources/invite.rb
|
@@ -343,7 +344,7 @@ licenses:
|
|
343
344
|
- MIT
|
344
345
|
metadata:
|
345
346
|
allowed_push_host: https://rubygems.org
|
346
|
-
post_install_message:
|
347
|
+
post_install_message:
|
347
348
|
rdoc_options: []
|
348
349
|
require_paths:
|
349
350
|
- lib
|
@@ -358,9 +359,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
359
|
- !ruby/object:Gem::Version
|
359
360
|
version: '0'
|
360
361
|
requirements: []
|
361
|
-
|
362
|
-
|
363
|
-
signing_key:
|
362
|
+
rubygems_version: 3.0.3
|
363
|
+
signing_key:
|
364
364
|
specification_version: 4
|
365
365
|
summary: Write a short summary, because RubyGems requires one.
|
366
366
|
test_files: []
|