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 +4 -4
- data/Gemfile.lock +20 -29
- data/README.md +164 -13
- data/app/services/infinum_id/resources/invite.rb +1 -1
- data/infinum_id.gemspec +0 -3
- data/lib/generators/infinum_id/install_generator.rb +0 -2
- data/lib/infinum_id/version.rb +1 -1
- data/lib/infinum_id.rb +0 -1
- metadata +4 -47
- data/app/workers/infinum_id/resources/invite_worker.rb +0 -11
- data/config/initializers/sidekiq.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e62591afc2dcf87b83746e0cfbfa6ce4e1490f252e4f120dcd46bc44bbacc2c
|
4
|
+
data.tar.gz: 6bd93953e12d36d8c1bc068286b7a772ceb380d2a8d4f89f693ef7e85605a12e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
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.
|
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.
|
69
|
+
devise (4.7.1)
|
74
70
|
bcrypt (~> 3.0)
|
75
71
|
orm_adapter (~> 0.1)
|
76
|
-
railties (>= 4.1.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.
|
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.
|
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.
|
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.
|
102
|
+
http (4.3.0)
|
103
103
|
addressable (~> 2.3)
|
104
104
|
http-cookie (~> 1.0)
|
105
|
-
http-form_data (~> 2.
|
106
|
-
|
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.
|
110
|
-
|
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.
|
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.
|
134
|
-
faraday (>= 0.8, <
|
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
|
-
|
3
|
+
InfinumId Engine is gem for resource authentication with [InfinumID](https://github.com/infinum/rails-infinum-id) server.
|
4
4
|
|
5
|
-
|
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
|
-
|
110
|
+
1. Add columns to resource via migration.
|
26
111
|
|
27
|
-
|
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
|
-
|
115
|
+
2. Set same columns in resource attribute config of infinum_id engine
|
30
116
|
|
31
|
-
|
117
|
+
3. Add following rows to resource model:
|
32
118
|
|
33
|
-
|
119
|
+
```ruby
|
120
|
+
devise :omniauthable, omniauth_providers: [:infinum_id]
|
34
121
|
|
35
|
-
|
122
|
+
def active_for_authentication?
|
123
|
+
super && !deactivated_at
|
124
|
+
end
|
125
|
+
```
|
36
126
|
|
37
|
-
|
127
|
+
4. Create AuthenticatedController and inherit it in all controllers that needs to be protected with authentication
|
38
128
|
|
39
|
-
|
129
|
+
```ruby
|
130
|
+
class AuthenticatedController < ApplicationController
|
131
|
+
before_action :authenticate_user!
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
## Features
|
40
136
|
|
41
|
-
|
137
|
+
<details>
|
138
|
+
<summary><big><b>Webhooks</b></big></summary>
|
139
|
+
<hr />
|
140
|
+
In engine there are two webhooks: UpdateResourceCallback & CreateResourceCallback.
|
42
141
|
|
43
|
-
|
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::
|
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 %>
|
data/lib/infinum_id/version.rb
CHANGED
data/lib/infinum_id.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: 1.
|
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:
|
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
|
-
|
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.
|