infinum_azure 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +4 -0
- data/.rubocop.yml +11 -24
- data/CHANGELOG.md +12 -0
- data/Dockerfile +18 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +62 -3
- data/README.md +10 -26
- data/app/controllers/infinum_azure/api/base_controller.rb +3 -2
- data/app/controllers/infinum_azure/api/webhooks_controller.rb +1 -1
- data/app/controllers/infinum_azure/application_controller.rb +3 -2
- data/app/controllers/infinum_azure/resources/omniauth_callbacks_controller.rb +1 -1
- data/app/controllers/infinum_azure/resources_controller.rb +1 -1
- data/app/services/infinum_azure/resources/params.rb +3 -5
- data/config/initializers/devise.rb +2 -7
- data/config/routes.rb +3 -3
- data/docker-compose.yml +13 -0
- data/infinum_azure.gemspec +4 -17
- data/lib/infinum_azure/config.rb +31 -4
- data/lib/infinum_azure/engine.rb +12 -0
- data/lib/infinum_azure/version.rb +1 -1
- data/lib/infinum_azure.rb +2 -35
- data/lib/tasks/infinum_azure/users/migration.rb +2 -1
- data/lib/tasks/infinum_azure/users/request.rb +1 -1
- metadata +10 -189
- data/lib/infinum_azure/defaults.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad4e0e2a028d73b80e54f6adf9e752a57e1ac22f9088cd9eb90322f8224a16d0
|
4
|
+
data.tar.gz: 89eb6ee189c4b42a4fff2266ec9778d296124f4bbb9be2fc0f783ef95efa69ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf9f6c4455285395cddc330263c60d4d54a28d85c1f3990121be7d4cc8e371bb7dc5ed433aa00113b907dab48f10c9d3778a656bf58cc0bf0a10b4d9592a8ddf
|
7
|
+
data.tar.gz: 7dee7905a808dad37a65cd731abecf058ee930f51c2bc638922b3770526c78c184285b6f4ed5cae94886cca1e227541f371f5e510c95b441827ca4965f8bb814
|
data/.dockerignore
ADDED
data/.rubocop.yml
CHANGED
@@ -1,27 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Style/StringLiterals:
|
5
|
-
Enabled: true
|
6
|
-
EnforcedStyle: single_quotes
|
7
|
-
|
8
|
-
Layout/LineLength:
|
9
|
-
Max: 120
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-infinum: rubocop.yml
|
10
3
|
|
11
|
-
|
12
|
-
|
4
|
+
require:
|
5
|
+
- rubocop-infinum
|
6
|
+
- rubocop-factory_bot
|
7
|
+
- rubocop-rake
|
8
|
+
- rubocop-rspec_rails
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
Style/Lambda:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
Metrics/BlockLength:
|
21
|
-
Exclude:
|
22
|
-
- '**/*.rake'
|
23
|
-
- 'spec/**/*.rb'
|
10
|
+
AllCops:
|
11
|
+
TargetRubyVersion: 3.0
|
24
12
|
|
25
|
-
|
26
|
-
|
27
|
-
- 'spec/**/*.rb'
|
13
|
+
RSpec/MultipleExpectations:
|
14
|
+
Max: 5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [3.0.0] - 2024-06-12
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
- Remove dependency on Rails secrets and enable clients to choose how to manage secret parameters
|
7
|
+
|
8
|
+
### Added
|
9
|
+
- RuboCop gems `factory_bot`, `infinum`, `rake`, `rspec_rails`
|
10
|
+
- GitHub Actions to build app image and run checks
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- RuboCop offenses
|
14
|
+
|
3
15
|
## [2.0.0] - 2024-03-12
|
4
16
|
|
5
17
|
**BREAKING CHANGE**
|
data/Dockerfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
FROM ruby:3.0 as base
|
2
|
+
|
3
|
+
RUN apt-get update -qq \
|
4
|
+
&& apt-get install -yq --no-install-recommends git build-essential less
|
5
|
+
|
6
|
+
WORKDIR /app
|
7
|
+
|
8
|
+
ARG BUNDLER_VERSION=2.4.6
|
9
|
+
RUN gem update --system && \
|
10
|
+
gem install bundler -v $BUNDLER_VERSION
|
11
|
+
|
12
|
+
COPY Gemfile* infinum_azure.gemspec ./
|
13
|
+
COPY lib/infinum_azure/version.rb lib/infinum_azure/version.rb
|
14
|
+
|
15
|
+
RUN bundle install
|
16
|
+
|
17
|
+
FROM base as ci
|
18
|
+
COPY . /app
|
data/Gemfile
CHANGED
@@ -6,3 +6,21 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
7
7
|
# Specify your gem's dependencies in infinum_azure.gemspec
|
8
8
|
gemspec
|
9
|
+
|
10
|
+
gem 'bundler'
|
11
|
+
gem 'factory_bot_rails'
|
12
|
+
gem 'faker'
|
13
|
+
gem 'pry'
|
14
|
+
gem 'pry-byebug'
|
15
|
+
gem 'pry-rails'
|
16
|
+
gem 'rails', '~> 7.0'
|
17
|
+
gem 'rake', '~> 12.0'
|
18
|
+
gem 'rspec', '~> 3.0'
|
19
|
+
gem 'rspec-rails'
|
20
|
+
gem 'rubocop-factory_bot'
|
21
|
+
gem 'rubocop-infinum'
|
22
|
+
gem 'rubocop-rake'
|
23
|
+
gem 'rubocop-rspec_rails'
|
24
|
+
gem 'simplecov'
|
25
|
+
gem 'sqlite3'
|
26
|
+
gem 'webmock'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
infinum_azure (
|
4
|
+
infinum_azure (3.0.0)
|
5
5
|
bundler
|
6
6
|
devise
|
7
7
|
omniauth-infinum_azure (>= 0.3.0, < 2.0)
|
@@ -76,6 +76,7 @@ GEM
|
|
76
76
|
tzinfo (~> 2.0)
|
77
77
|
addressable (2.8.1)
|
78
78
|
public_suffix (>= 2.0.2, < 6.0)
|
79
|
+
ast (2.4.2)
|
79
80
|
bcrypt (3.1.18)
|
80
81
|
builder (3.2.4)
|
81
82
|
byebug (11.1.3)
|
@@ -111,7 +112,9 @@ GEM
|
|
111
112
|
hashie (5.0.0)
|
112
113
|
i18n (1.12.0)
|
113
114
|
concurrent-ruby (~> 1.0)
|
115
|
+
json (2.7.2)
|
114
116
|
jwt (2.7.0)
|
117
|
+
language_server-protocol (3.17.0.3)
|
115
118
|
loofah (2.19.1)
|
116
119
|
crass (~> 1.0.2)
|
117
120
|
nokogiri (>= 1.5.9)
|
@@ -123,6 +126,7 @@ GEM
|
|
123
126
|
marcel (1.0.2)
|
124
127
|
method_source (1.0.0)
|
125
128
|
mini_mime (1.1.2)
|
129
|
+
mini_portile2 (2.8.7)
|
126
130
|
minitest (5.18.0)
|
127
131
|
multi_xml (0.6.0)
|
128
132
|
net-imap (0.3.4)
|
@@ -135,7 +139,8 @@ GEM
|
|
135
139
|
net-smtp (0.3.3)
|
136
140
|
net-protocol
|
137
141
|
nio4r (2.5.8)
|
138
|
-
nokogiri (1.14.2
|
142
|
+
nokogiri (1.14.2)
|
143
|
+
mini_portile2 (~> 2.8.0)
|
139
144
|
racc (~> 1.4)
|
140
145
|
oauth2 (2.0.9)
|
141
146
|
faraday (>= 0.17.3, < 3.0)
|
@@ -154,6 +159,10 @@ GEM
|
|
154
159
|
oauth2 (>= 1.4, < 3)
|
155
160
|
omniauth (~> 2.0)
|
156
161
|
orm_adapter (0.5.0)
|
162
|
+
parallel (1.25.1)
|
163
|
+
parser (3.3.2.0)
|
164
|
+
ast (~> 2.4.1)
|
165
|
+
racc
|
157
166
|
pry (0.14.2)
|
158
167
|
coderay (~> 1.1)
|
159
168
|
method_source (~> 1.0)
|
@@ -195,7 +204,9 @@ GEM
|
|
195
204
|
rake (>= 12.2)
|
196
205
|
thor (~> 1.0)
|
197
206
|
zeitwerk (~> 2.5)
|
207
|
+
rainbow (3.1.1)
|
198
208
|
rake (12.3.3)
|
209
|
+
regexp_parser (2.9.2)
|
199
210
|
responders (3.1.0)
|
200
211
|
actionpack (>= 5.2)
|
201
212
|
railties (>= 5.2)
|
@@ -221,6 +232,46 @@ GEM
|
|
221
232
|
rspec-mocks (~> 3.11)
|
222
233
|
rspec-support (~> 3.11)
|
223
234
|
rspec-support (3.12.0)
|
235
|
+
rubocop (1.64.1)
|
236
|
+
json (~> 2.3)
|
237
|
+
language_server-protocol (>= 3.17.0)
|
238
|
+
parallel (~> 1.10)
|
239
|
+
parser (>= 3.3.0.2)
|
240
|
+
rainbow (>= 2.2.2, < 4.0)
|
241
|
+
regexp_parser (>= 1.8, < 3.0)
|
242
|
+
rexml (>= 3.2.5, < 4.0)
|
243
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
244
|
+
ruby-progressbar (~> 1.7)
|
245
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
246
|
+
rubocop-ast (1.31.3)
|
247
|
+
parser (>= 3.3.1.0)
|
248
|
+
rubocop-capybara (2.21.0)
|
249
|
+
rubocop (~> 1.41)
|
250
|
+
rubocop-factory_bot (2.26.0)
|
251
|
+
rubocop (~> 1.41)
|
252
|
+
rubocop-infinum (0.8.0)
|
253
|
+
rubocop (>= 1.28.0)
|
254
|
+
rubocop-performance
|
255
|
+
rubocop-rails
|
256
|
+
rubocop-rspec
|
257
|
+
rubocop-performance (1.21.0)
|
258
|
+
rubocop (>= 1.48.1, < 2.0)
|
259
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
260
|
+
rubocop-rails (2.25.0)
|
261
|
+
activesupport (>= 4.2.0)
|
262
|
+
rack (>= 1.1)
|
263
|
+
rubocop (>= 1.33.0, < 2.0)
|
264
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
265
|
+
rubocop-rake (0.6.0)
|
266
|
+
rubocop (~> 1.0)
|
267
|
+
rubocop-rspec (2.31.0)
|
268
|
+
rubocop (~> 1.40)
|
269
|
+
rubocop-capybara (~> 2.17)
|
270
|
+
rubocop-factory_bot (~> 2.22)
|
271
|
+
rubocop-rspec_rails (~> 2.28)
|
272
|
+
rubocop-rspec_rails (2.29.0)
|
273
|
+
rubocop (~> 1.40)
|
274
|
+
ruby-progressbar (1.13.0)
|
224
275
|
ruby2_keywords (0.0.5)
|
225
276
|
simplecov (0.22.0)
|
226
277
|
docile (~> 1.1)
|
@@ -231,11 +282,13 @@ GEM
|
|
231
282
|
snaky_hash (2.0.1)
|
232
283
|
hashie
|
233
284
|
version_gem (~> 1.1, >= 1.1.1)
|
234
|
-
sqlite3 (1.6.1
|
285
|
+
sqlite3 (1.6.1)
|
286
|
+
mini_portile2 (~> 2.8.0)
|
235
287
|
thor (1.2.1)
|
236
288
|
timeout (0.3.2)
|
237
289
|
tzinfo (2.0.6)
|
238
290
|
concurrent-ruby (~> 1.0)
|
291
|
+
unicode-display_width (2.5.0)
|
239
292
|
version_gem (1.1.1)
|
240
293
|
warden (1.2.9)
|
241
294
|
rack (>= 2.0.9)
|
@@ -249,8 +302,10 @@ GEM
|
|
249
302
|
zeitwerk (2.6.7)
|
250
303
|
|
251
304
|
PLATFORMS
|
305
|
+
aarch64-linux
|
252
306
|
arm64-darwin-21
|
253
307
|
arm64-darwin-22
|
308
|
+
arm64-darwin-23
|
254
309
|
|
255
310
|
DEPENDENCIES
|
256
311
|
bundler
|
@@ -264,6 +319,10 @@ DEPENDENCIES
|
|
264
319
|
rake (~> 12.0)
|
265
320
|
rspec (~> 3.0)
|
266
321
|
rspec-rails
|
322
|
+
rubocop-factory_bot
|
323
|
+
rubocop-infinum
|
324
|
+
rubocop-rake
|
325
|
+
rubocop-rspec_rails
|
267
326
|
simplecov
|
268
327
|
sqlite3
|
269
328
|
webmock
|
data/README.md
CHANGED
@@ -7,7 +7,6 @@ InfinumAzure Engine is gem for resource authentication with Infinum Azure AD ser
|
|
7
7
|
- [Dependencies](#dependencies)
|
8
8
|
- [Configuration](#configuration)
|
9
9
|
* [InfinumAzure](#infinumazure)
|
10
|
-
* [Secrets](#secrets)
|
11
10
|
- [Usage](#usage)
|
12
11
|
|
13
12
|
## Installation
|
@@ -39,7 +38,6 @@ Or install it yourself as:
|
|
39
38
|
# config/initializers/infinum_azure.rb
|
40
39
|
|
41
40
|
InfinumAzure.configure do |config|
|
42
|
-
config.service_name = 'Revisor'
|
43
41
|
config.resource_name = 'User'
|
44
42
|
config.resource_attributes = [:uid, :email, :first_name, :last_name, :avatar_url,
|
45
43
|
:deactivated_at, :provider_groups, :employee]
|
@@ -49,12 +47,20 @@ InfinumAzure.configure do |config|
|
|
49
47
|
record.update_attribute(:provider, 'infinum_azure')
|
50
48
|
record.update_attribute(:uid, resource['uid'])
|
51
49
|
}
|
50
|
+
config.client_id = 'client-id'
|
51
|
+
config.client_secret = 'client-secret'
|
52
|
+
config.domain = 'https://login.b2c.com'
|
53
|
+
config.tenant = 'tenant'
|
54
|
+
config.users_auth_url = 'https://example.com'
|
52
55
|
end
|
53
56
|
```
|
54
57
|
|
55
58
|
Configuration options:
|
56
|
-
*
|
59
|
+
* client_id(mandatory) - client ID
|
60
|
+
* client_secret(mandatory) - client secret
|
61
|
+
* domain(mandatory) - Identity service domain
|
57
62
|
* resource_name(mandatory) - name of resource on whom authentication is being done
|
63
|
+
* tenant(mandatory) - Tenant id
|
58
64
|
* resource_attributes(optional) - attributes that will be permitted once the webhook controller receives the params from InfinumAzure
|
59
65
|
* user_migration_scope(optional) - a block that will be used to get the initial collection of resources (if blank, default is written above)
|
60
66
|
* user_migration_operation(optional) - a block that will be called for each resource from the above collection if a matching resource on InfinumAzure is found. The resource is a Hash containing the following properties:
|
@@ -65,29 +71,7 @@ Configuration options:
|
|
65
71
|
* `avatar_url` - string || null
|
66
72
|
* `groups` - string || null -> a comma separated list; if "employees" is present, the user is an employee
|
67
73
|
* `deactivated` - boolean
|
68
|
-
|
69
|
-
### Secrets
|
70
|
-
|
71
|
-
Secrets should be kept in `config/secrets.yml` file.
|
72
|
-
|
73
|
-
Required ones are:
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
# config/secrets.yml
|
77
|
-
|
78
|
-
infinum_azure:
|
79
|
-
client_id: 'client_id_from_InfinumAzure'
|
80
|
-
client_secret: 'client_secret_from_InfinumAzure'
|
81
|
-
domain: 'https://login.b2c.com'
|
82
|
-
tenant: 'InfinumAzure_tenant'
|
83
|
-
```
|
84
|
-
|
85
|
-
Optional ones are:
|
86
|
-
|
87
|
-
```ruby
|
88
|
-
infinum_azure:
|
89
|
-
users_auth_url: 'InfinumAzure_users_auth_url_with_api_code' # required only if infinum_azure:migrate_users rake task is used
|
90
|
-
```
|
74
|
+
* users_auth_url(optional)
|
91
75
|
|
92
76
|
## Usage
|
93
77
|
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
module InfinumAzure
|
4
4
|
module Api
|
5
|
-
class BaseController <
|
5
|
+
class BaseController < ApplicationController
|
6
6
|
protect_from_forgery with: :null_session
|
7
7
|
respond_to :json
|
8
8
|
|
9
|
-
delegate :resource_name,
|
9
|
+
delegate :resource_name, to: 'InfinumAzure.config'
|
10
|
+
delegate :resource_class, to: InfinumAzure
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -5,10 +5,11 @@ module InfinumAzure
|
|
5
5
|
protect_from_forgery with: :exception
|
6
6
|
respond_to :html
|
7
7
|
|
8
|
-
delegate :
|
8
|
+
delegate :resource_class, to: InfinumAzure
|
9
|
+
delegate :resource_name, to: 'InfinumAzure.config'
|
9
10
|
|
10
11
|
def current_resource
|
11
|
-
method("current_#{resource_name.underscore}").call
|
12
|
+
method(:"current_#{resource_name.underscore}").call
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -10,7 +10,7 @@ module InfinumAzure
|
|
10
10
|
flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: 'Azure'
|
11
11
|
sign_in_and_redirect resource, event: :authentication
|
12
12
|
else
|
13
|
-
flash[:notice] = 'You do not have permission to access this application.'
|
13
|
+
flash[:notice] = 'You do not have permission to access this application.' # rubocop:disable Rails/I18nLocaleTexts
|
14
14
|
redirect_to root_path
|
15
15
|
end
|
16
16
|
end
|
@@ -33,15 +33,13 @@ module InfinumAzure
|
|
33
33
|
raise 'unsupported normalization'
|
34
34
|
end
|
35
35
|
|
36
|
-
instance_variable_set("@#{attribute}", value)
|
36
|
+
instance_variable_set(:"@#{attribute}", value)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def as_json
|
41
|
-
NORMALIZATIONS.keys.
|
42
|
-
|
43
|
-
|
44
|
-
hash
|
41
|
+
NORMALIZATIONS.keys.index_with do |key|
|
42
|
+
instance_variable_get(:"@#{key}")
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Devise.setup do |config|
|
2
4
|
require 'devise/orm/active_record'
|
3
5
|
|
@@ -15,11 +17,4 @@ Devise.setup do |config|
|
|
15
17
|
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
16
18
|
|
17
19
|
config.sign_out_via = :get
|
18
|
-
|
19
|
-
# ==> OmniAuth
|
20
|
-
config.omniauth :infinum_azure, InfinumAzure.client_id, InfinumAzure.client_secret,
|
21
|
-
client_options: {
|
22
|
-
domain: InfinumAzure.domain,
|
23
|
-
tenant: InfinumAzure.tenant
|
24
|
-
}
|
25
20
|
end
|
data/config/routes.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Rails.application.routes.draw do
|
4
|
-
get "/#{InfinumAzure.resource_name.pluralize.underscore}/auth/infinum_azure/logout",
|
4
|
+
get "/#{InfinumAzure.config.resource_name.pluralize.underscore}/auth/infinum_azure/logout",
|
5
5
|
to: 'infinum_azure/resources#passthru',
|
6
6
|
as: :infinum_azure_logout
|
7
|
-
get "/#{InfinumAzure.resource_name.pluralize.underscore}/auth/logout",
|
7
|
+
get "/#{InfinumAzure.config.resource_name.pluralize.underscore}/auth/logout",
|
8
8
|
to: 'infinum_azure/resources#destroy',
|
9
9
|
as: :logout
|
10
10
|
|
11
|
-
devise_for InfinumAzure.resource_name.pluralize.underscore, controllers: {
|
11
|
+
devise_for InfinumAzure.config.resource_name.pluralize.underscore, controllers: {
|
12
12
|
omniauth_callbacks: 'infinum_azure/resources/omniauth_callbacks'
|
13
13
|
}
|
14
14
|
|
data/docker-compose.yml
ADDED
data/infinum_azure.gemspec
CHANGED
@@ -5,13 +5,13 @@ require_relative 'lib/infinum_azure/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'infinum_azure'
|
7
7
|
spec.version = InfinumAzure::VERSION
|
8
|
-
spec.authors = ['
|
9
|
-
spec.email = ['
|
8
|
+
spec.authors = ['Rails team']
|
9
|
+
spec.email = ['team.rails@infinum.com']
|
10
10
|
|
11
11
|
spec.summary = 'Authentication mechanism for Rails apps with devise via OAuth2'
|
12
12
|
spec.homepage = 'https://github.com/infinum/rails-infinum-azure-engine'
|
13
13
|
spec.license = 'MIT'
|
14
|
-
spec.required_ruby_version = '>=
|
14
|
+
spec.required_ruby_version = '>= 3.0'
|
15
15
|
|
16
16
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
17
|
|
@@ -30,21 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
|
-
spec.add_development_dependency 'bundler'
|
34
|
-
spec.add_development_dependency 'factory_bot_rails'
|
35
|
-
spec.add_development_dependency 'faker'
|
36
|
-
spec.add_development_dependency 'pry'
|
37
|
-
spec.add_development_dependency 'pry-byebug'
|
38
|
-
spec.add_development_dependency 'pry-rails'
|
39
|
-
spec.add_development_dependency 'rails', '~> 7.0'
|
40
|
-
spec.add_development_dependency 'rake', '~> 12.0'
|
41
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
-
spec.add_development_dependency 'rspec-rails'
|
43
|
-
spec.add_development_dependency 'simplecov'
|
44
|
-
spec.add_development_dependency 'sqlite3'
|
45
|
-
spec.add_development_dependency 'webmock'
|
46
|
-
|
47
33
|
spec.add_dependency 'bundler'
|
48
34
|
spec.add_dependency 'devise'
|
49
35
|
spec.add_dependency 'omniauth-infinum_azure', '>= 0.3.0', '< 2.0'
|
36
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
50
37
|
end
|
data/lib/infinum_azure/config.rb
CHANGED
@@ -2,11 +2,38 @@
|
|
2
2
|
|
3
3
|
module InfinumAzure
|
4
4
|
class Config
|
5
|
-
|
6
|
-
|
5
|
+
PROVIDER_INFINUM_ID = 'infinum_id'
|
6
|
+
PROVIDER_INFINUM_AZURE = 'infinum_azure'
|
7
|
+
UID = 'uid'
|
8
|
+
DEFAULT_RESOURCE_ATTRIBUTES = [
|
9
|
+
:uid, :email, :first_name, :last_name, :avatar_url, :deactivated_at, :provider_groups, :employee
|
10
|
+
].freeze
|
7
11
|
|
8
|
-
|
9
|
-
|
12
|
+
attr_accessor :resource_name
|
13
|
+
attr_accessor :resource_attributes
|
14
|
+
attr_accessor :user_migration_scope
|
15
|
+
attr_accessor :user_migration_operation
|
16
|
+
attr_accessor :client_id
|
17
|
+
attr_accessor :client_secret
|
18
|
+
attr_accessor :domain
|
19
|
+
attr_accessor :tenant
|
20
|
+
attr_accessor :users_auth_url
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
self.resource_attributes = DEFAULT_RESOURCE_ATTRIBUTES
|
24
|
+
self.user_migration_scope = -> { InfinumAzure.resource_class.where(provider: PROVIDER_INFINUM_ID) }
|
25
|
+
self.user_migration_operation = lambda { |record, resource|
|
26
|
+
record.update_columns( # rubocop:disable Rails/SkipsModelValidations
|
27
|
+
provider: PROVIDER_INFINUM_AZURE,
|
28
|
+
uid: resource[UID]
|
29
|
+
)
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate!
|
34
|
+
[:resource_name, :resource_attributes, :user_migration_scope, :user_migration_operation, :client_id,
|
35
|
+
:client_secret, :domain, :tenant].each do |attribute|
|
36
|
+
raise InfinumAzure::Error, "InfinumAzure attribute '@#{attribute}' not set" if public_send(attribute).blank?
|
10
37
|
end
|
11
38
|
end
|
12
39
|
end
|
data/lib/infinum_azure/engine.rb
CHANGED
@@ -2,5 +2,17 @@
|
|
2
2
|
|
3
3
|
module InfinumAzure
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
+
initializer 'infinum_azure.devise_omniauth', before: 'devise.omniauth' do
|
6
|
+
Devise.setup do |config|
|
7
|
+
# ==> OmniAuth
|
8
|
+
config.omniauth :infinum_azure,
|
9
|
+
InfinumAzure.config.client_id,
|
10
|
+
InfinumAzure.config.client_secret,
|
11
|
+
client_options: {
|
12
|
+
domain: InfinumAzure.config.domain,
|
13
|
+
tenant: InfinumAzure.config.tenant
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
5
17
|
end
|
6
18
|
end
|
data/lib/infinum_azure.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'omniauth/infinum_azure'
|
4
4
|
require 'infinum_azure/version'
|
5
5
|
require 'infinum_azure/engine'
|
6
|
-
require 'infinum_azure/defaults'
|
7
6
|
require 'infinum_azure/config'
|
8
7
|
require 'devise'
|
9
8
|
|
@@ -14,51 +13,19 @@ module InfinumAzure
|
|
14
13
|
def configure
|
15
14
|
yield config if block_given?
|
16
15
|
|
17
|
-
|
16
|
+
config.validate!
|
18
17
|
end
|
19
18
|
|
20
19
|
def config
|
21
20
|
@config ||= Config.new
|
22
21
|
end
|
23
22
|
|
24
|
-
def ensure_all_attributes_present!
|
25
|
-
Defaults.all_attribute_names.each do |attribute|
|
26
|
-
raise Error, "InfinumAzure attribute '@#{attribute}' not set" if config.public_send(attribute).blank?
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
delegate(*Defaults.all_attribute_names, to: :config)
|
31
|
-
|
32
23
|
def provider
|
33
24
|
to_s.underscore
|
34
25
|
end
|
35
26
|
|
36
27
|
def resource_class
|
37
|
-
resource_name.constantize
|
38
|
-
end
|
39
|
-
|
40
|
-
def client_id
|
41
|
-
dig_secret(:client_id)
|
42
|
-
end
|
43
|
-
|
44
|
-
def client_secret
|
45
|
-
dig_secret(:client_secret)
|
46
|
-
end
|
47
|
-
|
48
|
-
def domain
|
49
|
-
dig_secret(:domain)
|
50
|
-
end
|
51
|
-
|
52
|
-
def tenant
|
53
|
-
dig_secret(:tenant)
|
54
|
-
end
|
55
|
-
|
56
|
-
def users_auth_url
|
57
|
-
dig_secret(:users_auth_url)
|
58
|
-
end
|
59
|
-
|
60
|
-
def dig_secret(key)
|
61
|
-
Rails.application.secrets.dig(:infinum_azure, key)
|
28
|
+
config.resource_name.constantize
|
62
29
|
end
|
63
30
|
end
|
64
31
|
end
|
@@ -7,7 +7,7 @@ require_relative 'response'
|
|
7
7
|
module InfinumAzure
|
8
8
|
module Users
|
9
9
|
class Request
|
10
|
-
URL = InfinumAzure.users_auth_url
|
10
|
+
URL = InfinumAzure.config.users_auth_url
|
11
11
|
|
12
12
|
def self.execute
|
13
13
|
raise 'infinum_azure_users_auth_url secret required for this rake task' if URL.blank?
|
metadata
CHANGED
@@ -1,197 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infinum_azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Rails team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: factory_bot_rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faker
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry-byebug
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-rails
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rails
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '7.0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '7.0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '12.0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '12.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rspec
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '3.0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '3.0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rspec-rails
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: simplecov
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: sqlite3
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: webmock
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
13
|
- !ruby/object:Gem::Dependency
|
196
14
|
name: bundler
|
197
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -242,15 +60,17 @@ dependencies:
|
|
242
60
|
version: '2.0'
|
243
61
|
description:
|
244
62
|
email:
|
245
|
-
-
|
63
|
+
- team.rails@infinum.com
|
246
64
|
executables: []
|
247
65
|
extensions: []
|
248
66
|
extra_rdoc_files: []
|
249
67
|
files:
|
68
|
+
- ".dockerignore"
|
250
69
|
- ".rspec"
|
251
70
|
- ".rubocop.yml"
|
252
71
|
- CHANGELOG.md
|
253
72
|
- CODE_OF_CONDUCT.md
|
73
|
+
- Dockerfile
|
254
74
|
- Gemfile
|
255
75
|
- Gemfile.lock
|
256
76
|
- LICENSE
|
@@ -267,10 +87,10 @@ files:
|
|
267
87
|
- app/services/infinum_azure/resources/params.rb
|
268
88
|
- config/initializers/devise.rb
|
269
89
|
- config/routes.rb
|
90
|
+
- docker-compose.yml
|
270
91
|
- infinum_azure.gemspec
|
271
92
|
- lib/infinum_azure.rb
|
272
93
|
- lib/infinum_azure/config.rb
|
273
|
-
- lib/infinum_azure/defaults.rb
|
274
94
|
- lib/infinum_azure/engine.rb
|
275
95
|
- lib/infinum_azure/version.rb
|
276
96
|
- lib/tasks/infinum_azure/user_migration.rake
|
@@ -285,6 +105,7 @@ metadata:
|
|
285
105
|
homepage_uri: https://github.com/infinum/rails-infinum-azure-engine
|
286
106
|
source_code_uri: https://github.com/infinum/rails-infinum-azure-engine
|
287
107
|
changelog_uri: https://github.com/infinum/rails-infinum-azure-engine/blob/master/CHANGELOG.md
|
108
|
+
rubygems_mfa_required: 'true'
|
288
109
|
post_install_message:
|
289
110
|
rdoc_options: []
|
290
111
|
require_paths:
|
@@ -293,14 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
293
114
|
requirements:
|
294
115
|
- - ">="
|
295
116
|
- !ruby/object:Gem::Version
|
296
|
-
version:
|
117
|
+
version: '3.0'
|
297
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
119
|
requirements:
|
299
120
|
- - ">="
|
300
121
|
- !ruby/object:Gem::Version
|
301
122
|
version: '0'
|
302
123
|
requirements: []
|
303
|
-
rubygems_version: 3.
|
124
|
+
rubygems_version: 3.5.3
|
304
125
|
signing_key:
|
305
126
|
specification_version: 4
|
306
127
|
summary: Authentication mechanism for Rails apps with devise via OAuth2
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module InfinumAzure
|
4
|
-
module Defaults
|
5
|
-
REQUIRED = {
|
6
|
-
service_name: nil,
|
7
|
-
resource_name: nil
|
8
|
-
}.freeze
|
9
|
-
OPTIONAL = {
|
10
|
-
resource_attributes: [
|
11
|
-
:uid, :email, :first_name, :last_name, :avatar_url, :deactivated_at, :provider_groups, :employee
|
12
|
-
],
|
13
|
-
user_migration_scope: -> { InfinumAzure.resource_class.where(provider: 'infinum_id') },
|
14
|
-
user_migration_operation: ->(record, resource) {
|
15
|
-
record.update_attribute(:provider, 'infinum_azure')
|
16
|
-
record.update_attribute(:uid, resource['uid'])
|
17
|
-
}
|
18
|
-
}.freeze
|
19
|
-
|
20
|
-
def self.all_attribute_names
|
21
|
-
REQUIRED.keys + OPTIONAL.keys
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.all_attributes
|
25
|
-
REQUIRED.merge(OPTIONAL)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|