infinum_id 1.4.2 → 1.5.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: 94991c5e07d98bc97b0e6e186543f2b8bd85e7aae2815fe4fa4c07d54d5e7d51
4
- data.tar.gz: 5ab48ab777bc530957c2e2a5024f5f610737461d8a0730c4097c7cb874d9b6d7
3
+ metadata.gz: 5e62591afc2dcf87b83746e0cfbfa6ce4e1490f252e4f120dcd46bc44bbacc2c
4
+ data.tar.gz: 6bd93953e12d36d8c1bc068286b7a772ceb380d2a8d4f89f693ef7e85605a12e
5
5
  SHA512:
6
- metadata.gz: d984b11b2dab25a90593c2d7bb6f1b92b2b7d81b54a60f80e5b0f71b93f38978edfc2a4dec01c72dad6f0f7040d17ef8e9585f8e85834ab782cb169dc2c71d03
7
- data.tar.gz: 9755508548f7eab822cd91fb50056f1ced318d9da8ffd5ecaf51e161faf0a91bc5dae24f47e94fdf26324035d6800e57e7aedb8f73823161ce505db7b2b11b97
6
+ metadata.gz: a5084163467986c28e70a91922302dc7eb22e2e363a71cbda47ea3abf36d9e070a258e81505705c1c80c8f6317adeaef7205b8581cbdb9787c0d7d1287cc5db5
7
+ data.tar.gz: 8d998e72deeb6b77dd268a168522aad5842975c3b9455f4f047cd021e6cab7076bd381ba6162ca3c7a775a2b48aa95ce1e0c771211090e0dd4b3dde0fd550ecd
data/Gemfile.lock CHANGED
@@ -1,17 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- infinum_id (1.4.2)
4
+ infinum_id (1.5.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/
@@ -61,29 +58,28 @@ GEM
61
58
  public_suffix (>= 2.0.2, < 4.0)
62
59
  arel (9.0.0)
63
60
  bcrypt (3.1.13)
64
- blueprinter (0.19.0)
61
+ blueprinter (0.22.0)
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.1)
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.9.0)
84
80
  concurrent-ruby (~> 1.0)
85
81
  dry-core (~> 0.4, >= 0.4.7)
86
- dry-core (0.4.8)
82
+ dry-core (0.4.9)
87
83
  concurrent-ruby (~> 1.0)
88
84
  erubi (1.8.0)
89
85
  factory_bot (5.0.0)
@@ -93,21 +89,26 @@ GEM
93
89
  railties (>= 4.2.0)
94
90
  faker (1.9.1)
95
91
  i18n (>= 0.7)
96
- faraday (0.15.4)
92
+ faraday (1.0.0)
97
93
  multipart-post (>= 1.2, < 3)
94
+ ffi (1.11.3)
95
+ ffi-compiler (1.0.1)
96
+ ffi (>= 1.0.0)
97
+ rake
98
98
  globalid (0.4.2)
99
99
  activesupport (>= 4.2.0)
100
100
  hashdiff (0.3.8)
101
101
  hashie (3.6.0)
102
- http (4.1.1)
102
+ http (4.3.0)
103
103
  addressable (~> 2.3)
104
104
  http-cookie (~> 1.0)
105
- http-form_data (~> 2.0)
106
- http_parser.rb (~> 0.6.0)
105
+ http-form_data (~> 2.2)
106
+ http-parser (~> 1.2.0)
107
107
  http-cookie (1.0.3)
108
108
  domain_name (~> 0.5)
109
- http-form_data (2.1.1)
110
- http_parser.rb (0.6.0)
109
+ http-form_data (2.2.0)
110
+ http-parser (1.2.1)
111
+ ffi-compiler (>= 1.0, < 2.0)
111
112
  i18n (1.5.3)
112
113
  concurrent-ruby (~> 1.0)
113
114
  json (2.1.0)
@@ -124,14 +125,14 @@ GEM
124
125
  mini_mime (1.0.1)
125
126
  mini_portile2 (2.4.0)
126
127
  minitest (5.11.3)
127
- multi_json (1.13.1)
128
+ multi_json (1.14.1)
128
129
  multi_xml (0.6.0)
129
130
  multipart-post (2.1.1)
130
131
  nio4r (2.3.1)
131
132
  nokogiri (1.10.1)
132
133
  mini_portile2 (~> 2.4.0)
133
- oauth2 (1.4.1)
134
- faraday (>= 0.8, < 0.16.0)
134
+ oauth2 (1.4.2)
135
+ faraday (>= 0.8, < 2.0)
135
136
  jwt (>= 1.0, < 3.0)
136
137
  multi_json (~> 1.3)
137
138
  multi_xml (~> 0.5)
@@ -155,8 +156,6 @@ GEM
155
156
  pry (>= 0.10.4)
156
157
  public_suffix (3.0.3)
157
158
  rack (2.0.6)
158
- rack-protection (2.0.5)
159
- rack
160
159
  rack-test (1.1.0)
161
160
  rack (>= 1.0, < 3)
162
161
  rails (5.2.2)
@@ -184,9 +183,6 @@ GEM
184
183
  rake (>= 0.8.7)
185
184
  thor (>= 0.19.0, < 2.0)
186
185
  rake (10.5.0)
187
- redis (4.1.2)
188
- redis-namespace (1.6.0)
189
- redis (>= 3.0.4)
190
186
  responders (3.0.0)
191
187
  actionpack (>= 5.0)
192
188
  railties (>= 5.0)
@@ -212,11 +208,6 @@ GEM
212
208
  rspec-support (~> 3.8.0)
213
209
  rspec-support (3.8.0)
214
210
  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
211
  simplecov (0.16.1)
221
212
  docile (~> 1.1)
222
213
  json (>= 1.8, < 3)
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,168 @@ 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
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.infinum_id_send_email = false
83
+ config.resource_attributes = [:uid, :email, :first_name, :last_name, :deactivated_at, :time_zone, :avatar_url, :slack_username]
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
40
136
 
41
- ## Code of Conduct
137
+ <details>
138
+ <summary><big><b>Webhooks</b></big></summary>
139
+ <hr />
140
+ In engine there are two webhooks: UpdateResourceCallback & CreateResourceCallback.
42
141
 
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).
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::AfterResourceCreate/InfinumId::AfterResourceUpdate are called. So if resource can't be created before setting role, you can override those methods and set role that way.
145
+
146
+ ```ruby
147
+ # app/services/infinum_id/after_resource_create.rb
148
+
149
+ module InfinumId
150
+ class AfterResourceCreate
151
+ def self.call(person, params=nil)
152
+ person.update(employee: true)
153
+ end
154
+ end
155
+ end
156
+ ```
157
+ </details>
158
+
159
+ <details>
160
+ <summary><big><b>infinum_id_profile_edit_path</b></big></summary>
161
+ <hr />
162
+ Path to InfinumID profile of currently logged in user.
163
+ <br /><br />
164
+ </details>
165
+
166
+ <details>
167
+ <summary><big><b>Resource::Invite</b></big></summary>
168
+ <hr />
169
+
170
+ 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.
171
+
172
+ ```ruby
173
+ # app/controllers/users_controller.rb
174
+
175
+ user = InfinumId::Resources::Invite.call(user_params, current_user)
176
+ ```
177
+
178
+ </details>
179
+
180
+ <details>
181
+ <summary><big><b>Mailer</b></big></summary>
182
+ <hr />
183
+
184
+ There are two mailer: WelcomeMailer & InviteMailer.
185
+
186
+ WelcomeMailer is being used when user exists on InfinumID and we just invited him to application.
187
+
188
+ 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.
189
+
190
+ </details>
191
+
192
+ ## License
193
+
194
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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
data/infinum_id.gemspec CHANGED
@@ -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 %>
@@ -1,3 +1,3 @@
1
1
  module InfinumId
2
- VERSION = '1.4.2'
2
+ VERSION = '1.5.0'
3
3
  end
data/lib/infinum_id.rb CHANGED
@@ -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
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.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dajana Jeroncic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-12 00:00:00.000000000 Z
11
+ date: 2020-01-13 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
@@ -369,11 +327,9 @@ files:
369
327
  - app/views/infinum_id/mailer/invite_email.text.erb
370
328
  - app/views/infinum_id/mailer/welcome_email.html.erb
371
329
  - app/views/infinum_id/mailer/welcome_email.text.erb
372
- - app/workers/infinum_id/resources/invite_worker.rb
373
330
  - bin/console
374
331
  - bin/setup
375
332
  - config/initializers/devise.rb
376
- - config/initializers/sidekiq.rb
377
333
  - config/routes.rb
378
334
  - infinum_id.gemspec
379
335
  - lib/generators/infinum_id/install_generator.rb
@@ -402,7 +358,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
402
358
  - !ruby/object:Gem::Version
403
359
  version: '0'
404
360
  requirements: []
405
- rubygems_version: 3.0.3
361
+ rubyforge_project:
362
+ rubygems_version: 2.7.6
406
363
  signing_key:
407
364
  specification_version: 4
408
365
  summary: Write a short summary, because RubyGems requires one.
@@ -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