infinum_id 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0256762e3c906875f6161a4e46d010b37cb498c226b28886f8f6764d1486b5b4
4
- data.tar.gz: 6a450547d53dd9ba4fbf90105db3e8d375a28b944f3ccc5a5ada744a3b5f8b76
3
+ metadata.gz: 7890955304e9d46d659e4912ed2a0db17215059091d6841f48b182a966a52b7b
4
+ data.tar.gz: 8599516a3f14cfa1d9df62572842167884219ce3ac10f514757d271b66fe6b38
5
5
  SHA512:
6
- metadata.gz: e8510a55fe4588ecd7a75bc6e10c8fe35eb35c104a9a3c1f3784f4957c01f52fb9a8ea83bb7cb8fc9237190e48bb42bf50f4ae6f6d18feb853cb05f16c1c6905
7
- data.tar.gz: 76bc7089b1721d1351bcaee7b6ea59993c0e299c2dbf3134c21e2604f1cda94b16242c9c5047cef382cf31680faf8215c699f8e2d6a05e00a293308819ca2b18
6
+ metadata.gz: 99287be6aafcbf0c0e600dbfb7bdd5fed5b37ca9eb1bb5b3f26b0ab60bb0c51dddc079f4366ab30780a1851f3d82837be702325b92ce129981de5a5d775b62c9
7
+ data.tar.gz: 6b0def3b8d25f851aa46b89c15a90723e9c334926e41c542489e50f7ddbb6be5dc8fee00dd06feebee18151acd87505ee0cdb6ea1ea1fa2227305b89688ea48e
@@ -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.
@@ -1,17 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- infinum_id (1.4.1)
4
+ infinum_id (2.0.0)
5
5
  blueprinter
6
6
  bundler
7
7
  devise
8
8
  dry-configurable
9
9
  http
10
10
  omniauth-infinum_id
11
- redis
12
- redis-namespace
13
11
  responders
14
- sidekiq
15
12
 
16
13
  GEM
17
14
  remote: https://rubygems.org/
@@ -60,31 +57,32 @@ GEM
60
57
  addressable (2.6.0)
61
58
  public_suffix (>= 2.0.2, < 4.0)
62
59
  arel (9.0.0)
63
- bcrypt (3.1.13)
64
- blueprinter (0.19.0)
60
+ bcrypt (3.1.16)
61
+ blueprinter (0.25.1)
65
62
  builder (3.2.3)
66
63
  byebug (10.0.2)
67
64
  coderay (1.1.2)
68
65
  concurrent-ruby (1.1.4)
69
- connection_pool (2.2.2)
70
66
  crack (0.4.3)
71
67
  safe_yaml (~> 1.0.0)
72
68
  crass (1.0.4)
73
- devise (4.6.2)
69
+ devise (4.7.2)
74
70
  bcrypt (~> 3.0)
75
71
  orm_adapter (~> 0.1)
76
- railties (>= 4.1.0, < 6.0)
72
+ railties (>= 4.1.0)
77
73
  responders
78
74
  warden (~> 1.2.3)
79
75
  diff-lcs (1.3)
80
76
  docile (1.3.1)
81
77
  domain_name (0.5.20190701)
82
78
  unf (>= 0.0.5, < 1.0.0)
83
- dry-configurable (0.8.3)
79
+ dry-configurable (0.11.6)
84
80
  concurrent-ruby (~> 1.0)
85
81
  dry-core (~> 0.4, >= 0.4.7)
86
- dry-core (0.4.8)
82
+ dry-equalizer (~> 0.2)
83
+ dry-core (0.4.9)
87
84
  concurrent-ruby (~> 1.0)
85
+ dry-equalizer (0.3.0)
88
86
  erubi (1.8.0)
89
87
  factory_bot (5.0.0)
90
88
  activesupport (>= 4.2.0)
@@ -93,25 +91,30 @@ GEM
93
91
  railties (>= 4.2.0)
94
92
  faker (1.9.1)
95
93
  i18n (>= 0.7)
96
- faraday (0.15.4)
94
+ faraday (1.0.1)
97
95
  multipart-post (>= 1.2, < 3)
96
+ ffi (1.13.1)
97
+ ffi-compiler (1.0.1)
98
+ ffi (>= 1.0.0)
99
+ rake
98
100
  globalid (0.4.2)
99
101
  activesupport (>= 4.2.0)
100
102
  hashdiff (0.3.8)
101
- hashie (3.6.0)
102
- http (4.1.1)
103
+ hashie (4.1.0)
104
+ http (4.4.1)
103
105
  addressable (~> 2.3)
104
106
  http-cookie (~> 1.0)
105
- http-form_data (~> 2.0)
106
- http_parser.rb (~> 0.6.0)
107
+ http-form_data (~> 2.2)
108
+ http-parser (~> 1.2.0)
107
109
  http-cookie (1.0.3)
108
110
  domain_name (~> 0.5)
109
- http-form_data (2.1.1)
110
- http_parser.rb (0.6.0)
111
+ http-form_data (2.3.0)
112
+ http-parser (1.2.1)
113
+ ffi-compiler (>= 1.0, < 2.0)
111
114
  i18n (1.5.3)
112
115
  concurrent-ruby (~> 1.0)
113
116
  json (2.1.0)
114
- jwt (2.2.1)
117
+ jwt (2.2.2)
115
118
  loofah (2.2.3)
116
119
  crass (~> 1.0.2)
117
120
  nokogiri (>= 1.5.9)
@@ -124,25 +127,25 @@ GEM
124
127
  mini_mime (1.0.1)
125
128
  mini_portile2 (2.4.0)
126
129
  minitest (5.11.3)
127
- multi_json (1.13.1)
130
+ multi_json (1.15.0)
128
131
  multi_xml (0.6.0)
129
132
  multipart-post (2.1.1)
130
133
  nio4r (2.3.1)
131
134
  nokogiri (1.10.1)
132
135
  mini_portile2 (~> 2.4.0)
133
- oauth2 (1.4.1)
134
- faraday (>= 0.8, < 0.16.0)
136
+ oauth2 (1.4.4)
137
+ faraday (>= 0.8, < 2.0)
135
138
  jwt (>= 1.0, < 3.0)
136
139
  multi_json (~> 1.3)
137
140
  multi_xml (~> 0.5)
138
141
  rack (>= 1.2, < 3)
139
- omniauth (1.9.0)
140
- hashie (>= 3.4.6, < 3.7.0)
142
+ omniauth (1.9.1)
143
+ hashie (>= 3.4.6)
141
144
  rack (>= 1.6.2, < 3)
142
- omniauth-infinum_id (1.1.0)
145
+ omniauth-infinum_id (1.2.1)
143
146
  omniauth-oauth2
144
- omniauth-oauth2 (1.6.0)
145
- oauth2 (~> 1.1)
147
+ omniauth-oauth2 (1.7.0)
148
+ oauth2 (~> 1.4)
146
149
  omniauth (~> 1.9)
147
150
  orm_adapter (0.5.0)
148
151
  pry (0.12.2)
@@ -154,9 +157,7 @@ GEM
154
157
  pry-rails (0.3.9)
155
158
  pry (>= 0.10.4)
156
159
  public_suffix (3.0.3)
157
- rack (2.0.6)
158
- rack-protection (2.0.5)
159
- rack
160
+ rack (2.2.3)
160
161
  rack-test (1.1.0)
161
162
  rack (>= 1.0, < 3)
162
163
  rails (5.2.2)
@@ -184,10 +185,7 @@ GEM
184
185
  rake (>= 0.8.7)
185
186
  thor (>= 0.19.0, < 2.0)
186
187
  rake (10.5.0)
187
- redis (4.1.2)
188
- redis-namespace (1.6.0)
189
- redis (>= 3.0.4)
190
- responders (3.0.0)
188
+ responders (3.0.1)
191
189
  actionpack (>= 5.0)
192
190
  railties (>= 5.0)
193
191
  rspec (3.8.0)
@@ -212,11 +210,6 @@ GEM
212
210
  rspec-support (~> 3.8.0)
213
211
  rspec-support (3.8.0)
214
212
  safe_yaml (1.0.4)
215
- sidekiq (5.2.7)
216
- connection_pool (~> 2.2, >= 2.2.2)
217
- rack (>= 1.5.0)
218
- rack-protection (>= 1.5.0)
219
- redis (>= 3.3.5, < 5)
220
213
  simplecov (0.16.1)
221
214
  docile (~> 1.1)
222
215
  json (>= 1.8, < 3)
@@ -236,9 +229,9 @@ GEM
236
229
  thread_safe (~> 0.1)
237
230
  unf (0.1.4)
238
231
  unf_ext
239
- unf_ext (0.0.7.6)
240
- warden (1.2.8)
241
- rack (>= 2.0.6)
232
+ unf_ext (0.0.7.7)
233
+ warden (1.2.9)
234
+ rack (>= 2.0.9)
242
235
  webmock (3.5.1)
243
236
  addressable (>= 2.3.6)
244
237
  crack (>= 0.3.2)
@@ -267,4 +260,4 @@ DEPENDENCIES
267
260
  webmock
268
261
 
269
262
  BUNDLED WITH
270
- 2.0.2
263
+ 2.1.4
data/README.md CHANGED
@@ -1,8 +1,15 @@
1
- # InfinumId
1
+ # InfinumId Engine
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/infinum_id`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ InfinumId Engine is gem for resource authentication with [InfinumID](https://github.com/infinum/rails-infinum-id) server.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Table of Contents
6
+ - [Installation](#installation)
7
+ - [Dependencies](#dependencies)
8
+ - [Configuration](#configuration)
9
+ * [InfinumID](#infinumid)
10
+ * [Secrets](#secrets)
11
+ - [Usage](#usage)
12
+ - [Features](#features)
6
13
 
7
14
  ## Installation
8
15
 
@@ -20,24 +27,170 @@ Or install it yourself as:
20
27
 
21
28
  $ gem install infinum_id
22
29
 
30
+ ## Dependencies
31
+
32
+ * [Blueprinter](https://github.com/procore/blueprinter)
33
+ * [Devise](https://github.com/plataformatec/devise)
34
+ * [Dry configurable](https://github.com/dry-rb/dry-configurable)
35
+ * [Http](https://github.com/httprb/http)
36
+ * [Omniauth::InfinumId](https://github.com/infinum/ruby-infinum-id-omniauth)
37
+ * [Redis](https://github.com/antirez/redis)
38
+
39
+ <details>
40
+ <summary><big><b>Blueprinter</b></big></summary>
41
+ <hr />
42
+ When new user is being created in application, info of that user is being sent to InfinumID to create user there as well.
43
+ Model of user in application might not be the same as on in InfinumID. So parametars need to be changed to match one on InfinumID.
44
+
45
+ For example, url to profile picture in application is called avatar_remote_url and in InfinumID it's called avatar_url.
46
+
47
+ ```ruby
48
+ # app/blueprints/infinum_id/resource_blueprint.rb
49
+
50
+ module InfinumId
51
+ class ResourceBlueprint < Blueprinter::Base
52
+ identifier :email
53
+
54
+ fields :first_name, :last_name, :employee
55
+
56
+ field :slack_username
57
+ field :avatar_url, as: :avatar_remote_url
58
+ end
59
+ end
60
+ ```
61
+
62
+ Default serializator is given, but it can be overridden.
63
+ </details>
64
+
65
+ <details>
66
+ <summary><big><b>Devise</b></big></summary>
67
+ <hr />
68
+ Devise is used like middleware for authentication that uses Omniauth with infinum_id strategy. Devise should be configured inside model that will be authenticated. When configured all methods of devise can be used (e.g. current_user)
69
+ <br/><br/>
70
+ </details>
71
+
72
+ ## Configuration
73
+
74
+ ### InfinumID
75
+
76
+ ```ruby
77
+ # config/initializers/infinum_id.rb
78
+
79
+ InfinumId.configure do |config|
80
+ config.service_name = 'Revisor'
81
+ config.resource_name = 'User'
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, :employee]
84
+ end
85
+ ```
86
+
87
+ Configuration options:
88
+ * Service name - name of application
89
+ * Resource name - name of resource on whom authentication is being done
90
+ * InfinumID send email - toggle if InfinumID should send invite email or application (false for InfinumID)
91
+ * Resource attributes - list of resource attributes that will be send to InfinumID when new user is created
92
+
93
+ ### Secrets
94
+
95
+ Needed secrets:
96
+
97
+ ```ruby
98
+ # config/secrets.yml
99
+
100
+ infinum_id:
101
+ client_id: 'client_id_from_InfinumID'
102
+ client_secret: 'client_secret_from_InfinumID'
103
+ url: 'InfinumID_url'
104
+ redis_server_url: 'redis_server_url'
105
+ redis_client_url: 'redis_client_url'
106
+ ```
107
+
23
108
  ## Usage
24
109
 
25
- TODO: Write usage instructions here
110
+ 1. Add columns to resource via migration.
26
111
 
27
- ## Development
112
+ <b>Required columns:</b> email, uid, provider and deactivated_at. <br />
113
+ <b>Optional columns:</b> first_name, last_name, avatar_url, slack_username, time_zone
28
114
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
115
+ 2. Set same columns in resource attribute config of infinum_id engine
30
116
 
31
- 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).
117
+ 3. Add following rows to resource model:
32
118
 
33
- ## Contributing
119
+ ```ruby
120
+ devise :omniauthable, omniauth_providers: [:infinum_id]
34
121
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/infinum_id. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
122
+ def active_for_authentication?
123
+ super && !deactivated_at
124
+ end
125
+ ```
36
126
 
37
- ## License
127
+ 4. Create AuthenticatedController and inherit it in all controllers that needs to be protected with authentication
38
128
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
129
+ ```ruby
130
+ class AuthenticatedController < ApplicationController
131
+ before_action :authenticate_user!
132
+ end
133
+ ```
134
+
135
+ ## Features
136
+
137
+ <details>
138
+ <summary><big><b id="webhooks">Webhooks</b></big></summary>
139
+ <hr />
140
+ In engine there are two webhooks: `UpdateResourceCallback` & `CreateResourceCallback`.
141
+
142
+ When user is created or updated on InfinumID these webhooks are called and then resource is created or updated accordingly.
143
+
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.`
147
+
148
+ ```ruby
149
+ # app/services/infinum_id/after_resource_create.rb
150
+
151
+ module InfinumId
152
+ class AfterResourceUpsert
153
+ def self.call(person, _params = nil, _intent = nil)
154
+ person.update(employee: true)
155
+ end
156
+ end
157
+ end
158
+ ```
159
+ </details>
160
+
161
+ <details>
162
+ <summary><big><b>infinum_id_profile_edit_path</b></big></summary>
163
+ <hr />
164
+ Path to InfinumID profile of currently logged in user.
165
+ <br /><br />
166
+ </details>
167
+
168
+ <details>
169
+ <summary><big><b>Resource::Invite</b></big></summary>
170
+ <hr />
40
171
 
41
- ## Code of Conduct
172
+ Resource::Invite calls creates new user by given user parameters and sends request to InfinumID server. If user does not exist on InfinumID server user will be created there. If user existed on InfinumID Welcome email will be sent, if not Invite email with link to InfinumID server will be sent where user can finish his account creation.
42
173
 
43
- Everyone interacting in the InfinumId project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/infinum_id/blob/master/CODE_OF_CONDUCT.md).
174
+ ```ruby
175
+ # app/controllers/users_controller.rb
176
+
177
+ user = InfinumId::Resources::Invite.call(user_params, current_user)
178
+ ```
179
+
180
+ </details>
181
+
182
+ <details>
183
+ <summary><big><b>Mailer</b></big></summary>
184
+ <hr />
185
+
186
+ There are two mailer: WelcomeMailer & InviteMailer.
187
+
188
+ WelcomeMailer is being used when user exists on InfinumID and we just invited him to application.
189
+
190
+ InviteMailer is being used when user doesn't exist on InfinumID and account was just created there and in mail invitation link is sent to finish account creation.
191
+
192
+ </details>
193
+
194
+ ## License
195
+
196
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -2,7 +2,7 @@ module InfinumId
2
2
  class ResourceBlueprint < Blueprinter::Base
3
3
  identifier :email
4
4
 
5
- fields :first_name, :last_name
5
+ fields :first_name, :last_name, :employee
6
6
 
7
7
  # field :slack_username
8
8
  # field :avatar_url, as: :avatar_remote_url
@@ -1,24 +1,14 @@
1
1
  module InfinumId
2
2
  module Api
3
3
  class WebhooksController < Api::BaseController
4
- def update_resource_callback
5
- return render_not_found unless resource
4
+ def upsert_resource_callback
5
+ intent, resource = upsert
6
6
 
7
- resource.update(user_params)
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,15 +16,20 @@ module InfinumId
26
16
  end
27
17
 
28
18
  def resource
29
- @resource ||= resource_class.find_by(uid: user_params[:uid])
19
+ @resource ||=
20
+ resource_class.find_by(uid: user_params[:uid], provider: params[:provider]) ||
21
+ resource_class.find_by(email: user_params[:email])
30
22
  end
31
23
 
32
- def render_not_found
33
- render json: { resource_name.underscore => 'not found' }, status: :not_found
34
- end
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]))
35
30
 
36
- def render_already_exists
37
- render json: { resource_name.underscore => 'already exists' }, status: :unprocessable_entity
31
+ [InfinumId::AfterResourceIntent::CREATE, resource]
32
+ end
38
33
  end
39
34
  end
40
35
  end
@@ -0,0 +1,6 @@
1
+ module InfinumId
2
+ class AfterResourceIntent
3
+ CREATE = :create
4
+ UPDATE = :update
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module InfinumId
2
+ class AfterResourceUpsert
3
+ def self.call(resource, params, intent); end
4
+ end
5
+ end
@@ -11,6 +11,8 @@ module InfinumId
11
11
  end
12
12
 
13
13
  def call
14
+ return unless InfinumId.send_invite_request
15
+
14
16
  send_invite_request
15
17
  handle_response
16
18
  end
@@ -37,7 +39,11 @@ module InfinumId
37
39
 
38
40
  def update_resource
39
41
  resource.update(user_params.merge(provider: 'infinum_id'))
40
- InfinumId::AfterResourceUpdate.call(resource, params[:user])
42
+ InfinumId::AfterResourceUpsert.call(
43
+ resource,
44
+ params[:user],
45
+ InfinumId::AfterResourceIntent::UPDATE
46
+ )
41
47
  end
42
48
 
43
49
  def send_email
@@ -22,7 +22,7 @@ module InfinumId
22
22
  attr_reader :current_resource, :resource
23
23
 
24
24
  def send_invite_request
25
- InfinumId::Resources::InviteWorker.perform_async(@resource.id, current_resource.uid)
25
+ InfinumId::Requests::InviteSender.call(@resource.id, current_resource.uid)
26
26
  end
27
27
  end
28
28
  end
@@ -12,7 +12,11 @@ module InfinumId
12
12
 
13
13
  def call
14
14
  update_resource
15
- InfinumId::AfterResourceUpdate.call(resource, @params)
15
+ InfinumId::AfterResourceUpsert.call(
16
+ resource,
17
+ @params,
18
+ InfinumId::AfterResourceIntent::UPDATE
19
+ )
16
20
  end
17
21
 
18
22
  private
@@ -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', :controller => :webhooks do
11
- post :update_resource_callback
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
@@ -49,10 +49,7 @@ Gem::Specification.new do |spec|
49
49
  spec.add_dependency 'devise'
50
50
  spec.add_dependency 'http'
51
51
  spec.add_dependency 'omniauth-infinum_id'
52
- spec.add_dependency 'redis'
53
- spec.add_dependency 'redis-namespace'
54
52
  spec.add_dependency 'responders'
55
- spec.add_dependency 'sidekiq'
56
53
  spec.add_dependency 'dry-configurable'
57
54
  spec.add_dependency 'blueprinter'
58
55
  end
@@ -45,8 +45,6 @@ RUBY
45
45
 
46
46
  def secrets_template
47
47
  <<RUBY
48
- redis_server_url: <%= Figaro.env.redis_server_url %>
49
- redis_client_url: <%= Figaro.env.redis_client_url %>
50
48
  infinum_id:
51
49
  client_id: <%= Figaro.env.infinum_id_client_id %>
52
50
  client_secret: <%= Figaro.env.infinum_id_client_secret %>
@@ -5,6 +5,7 @@ class CreateUsers < ActiveRecord::Migration<%= migration_version %>
5
5
 
6
6
  t.string :first_name
7
7
  t.string :last_name
8
+ t.boolean :employee
8
9
 
9
10
  t.string :slack_username
10
11
  t.string :time_zone
@@ -13,6 +13,7 @@ class User < ApplicationRecord
13
13
  first_name: first_name,
14
14
  last_name: last_name,
15
15
  slack_username: slack_username,
16
+ employee: employee,
16
17
  time_zone: time_zone
17
18
  }
18
19
  end
@@ -4,7 +4,6 @@ require 'infinum_id/engine'
4
4
  require 'dry-configurable'
5
5
  require 'blueprinter'
6
6
  require 'devise'
7
- require 'sidekiq'
8
7
  require 'http'
9
8
 
10
9
  module InfinumId
@@ -13,9 +12,11 @@ module InfinumId
13
12
  setting :service_name, reader: true
14
13
  setting :resource_name, 'User', reader: true
15
14
  setting :infinum_id_send_email, false, reader: true
15
+ setting :send_invite_request, true, reader: true
16
16
 
17
- setting :resource_attributes, [:uid, :email, :first_name, :last_name],
18
- reader: true
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
@@ -1,3 +1,3 @@
1
1
  module InfinumId
2
- VERSION = '1.4.1'
2
+ VERSION = '2.0.0'
3
3
  end
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: 1.4.1
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: 2019-08-09 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -248,34 +248,6 @@ dependencies:
248
248
  - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
- - !ruby/object:Gem::Dependency
252
- name: redis
253
- requirement: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - ">="
256
- - !ruby/object:Gem::Version
257
- version: '0'
258
- type: :runtime
259
- prerelease: false
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - ">="
263
- - !ruby/object:Gem::Version
264
- version: '0'
265
- - !ruby/object:Gem::Dependency
266
- name: redis-namespace
267
- requirement: !ruby/object:Gem::Requirement
268
- requirements:
269
- - - ">="
270
- - !ruby/object:Gem::Version
271
- version: '0'
272
- type: :runtime
273
- prerelease: false
274
- version_requirements: !ruby/object:Gem::Requirement
275
- requirements:
276
- - - ">="
277
- - !ruby/object:Gem::Version
278
- version: '0'
279
251
  - !ruby/object:Gem::Dependency
280
252
  name: responders
281
253
  requirement: !ruby/object:Gem::Requirement
@@ -290,20 +262,6 @@ dependencies:
290
262
  - - ">="
291
263
  - !ruby/object:Gem::Version
292
264
  version: '0'
293
- - !ruby/object:Gem::Dependency
294
- name: sidekiq
295
- requirement: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - ">="
298
- - !ruby/object:Gem::Version
299
- version: '0'
300
- type: :runtime
301
- prerelease: false
302
- version_requirements: !ruby/object:Gem::Requirement
303
- requirements:
304
- - - ">="
305
- - !ruby/object:Gem::Version
306
- version: '0'
307
265
  - !ruby/object:Gem::Dependency
308
266
  name: dry-configurable
309
267
  requirement: !ruby/object:Gem::Requirement
@@ -343,6 +301,7 @@ files:
343
301
  - ".rspec"
344
302
  - ".rubocop.yml"
345
303
  - ".travis.yml"
304
+ - CHANGES.md
346
305
  - CODE_OF_CONDUCT.md
347
306
  - Gemfile
348
307
  - Gemfile.lock
@@ -359,8 +318,8 @@ files:
359
318
  - app/mailers/infinum_id/application_mailer.rb
360
319
  - app/mailers/infinum_id/mailer.rb
361
320
  - app/models/infinum_id/application_record.rb
362
- - app/services/infinum_id/after_resource_create.rb
363
- - app/services/infinum_id/after_resource_update.rb
321
+ - app/services/infinum_id/after_resource_intent.rb
322
+ - app/services/infinum_id/after_resource_upsert.rb
364
323
  - app/services/infinum_id/requests/invite_sender.rb
365
324
  - app/services/infinum_id/resources/finder.rb
366
325
  - app/services/infinum_id/resources/invite.rb
@@ -369,11 +328,9 @@ files:
369
328
  - app/views/infinum_id/mailer/invite_email.text.erb
370
329
  - app/views/infinum_id/mailer/welcome_email.html.erb
371
330
  - app/views/infinum_id/mailer/welcome_email.text.erb
372
- - app/workers/infinum_id/resources/invite_worker.rb
373
331
  - bin/console
374
332
  - bin/setup
375
333
  - config/initializers/devise.rb
376
- - config/initializers/sidekiq.rb
377
334
  - config/routes.rb
378
335
  - infinum_id.gemspec
379
336
  - lib/generators/infinum_id/install_generator.rb
@@ -387,7 +344,7 @@ licenses:
387
344
  - MIT
388
345
  metadata:
389
346
  allowed_push_host: https://rubygems.org
390
- post_install_message:
347
+ post_install_message:
391
348
  rdoc_options: []
392
349
  require_paths:
393
350
  - lib
@@ -403,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
403
360
  version: '0'
404
361
  requirements: []
405
362
  rubygems_version: 3.0.3
406
- signing_key:
363
+ signing_key:
407
364
  specification_version: 4
408
365
  summary: Write a short summary, because RubyGems requires one.
409
366
  test_files: []
@@ -1,5 +0,0 @@
1
- module InfinumId
2
- class AfterResourceCreate
3
- def self.call(resource, params=nil); end
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- module InfinumId
2
- class AfterResourceUpdate
3
- def self.call(resource, params=nil); end
4
- end
5
- end
@@ -1,11 +0,0 @@
1
- module InfinumId
2
- module Resources
3
- class InviteWorker
4
- include Sidekiq::Worker
5
-
6
- def perform(resource_id, current_resource_uid)
7
- InfinumId::Requests::InviteSender.call(resource_id, current_resource_uid)
8
- end
9
- end
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- Sidekiq.configure_server do |config|
2
- config.redis = { url: Rails.application.secrets[:redis_server_url] }
3
- end
4
-
5
- Sidekiq.configure_client do |config|
6
- config.redis = { url: Rails.application.secrets[:redis_client_url] }
7
- end