infinum_azure 2.0.0 → 3.1.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: ed06b297d0b3f0e23fb9f1907a47d0929a0877d18118a2b1cc082ab1ff590151
4
- data.tar.gz: a50b124bb33df07057eb8d9d2460cfa46373b2187a3272b3714670f8ded8df2b
3
+ metadata.gz: e1ce7d76ade64bf406fc7a720ee92587ca183b885d252599374748d324fba3e4
4
+ data.tar.gz: 8607066482524b4b52f4b1a878fdca8ddf4071ec73024c6c22a2592a80bdb412
5
5
  SHA512:
6
- metadata.gz: e1d8a9312d942c4460926640c6b94ba95fd51a481cac78c176fea9f1a7462e55dbb1aeb38e92d2b42fe110ea776feda207efaa652d644412130d0cd4751a476c
7
- data.tar.gz: f7b751e569c6100128fb23dba031a9fcb37354d1d4471fed008edb7f3d7fe6e7a9cb3a52a0e121ba71efff7be29b8ef803fc3450a365d1e8e875c8cfea867203
6
+ metadata.gz: b4b1c32d1aba8937e83dd9426a03a6d5ea25eb76b7a9cb6afb020875259357f6c903331a3c1f7b05cda6be9520c204b87981350bd7e2b772d3e8cc9721adb019
7
+ data.tar.gz: 42a9d627ced1e5a058b99e80f27dda5786827a72de6ac6b395810c95ec98946daa569a2888f7a18f9dfbeaee104fae52ebed3d6ce61c7431f99f258d9984f227
data/.dockerignore ADDED
@@ -0,0 +1,4 @@
1
+ .git
2
+ .gitignore
3
+ Dockerfile
4
+ docker-compose.yml
data/.rubocop.yml CHANGED
@@ -1,27 +1,14 @@
1
- AllCops:
2
- TargetRubyVersion: 2.7
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
- Style/Documentation:
12
- Enabled: false
4
+ require:
5
+ - rubocop-infinum
6
+ - rubocop-factory_bot
7
+ - rubocop-rake
8
+ - rubocop-rspec_rails
13
9
 
14
- Style/SymbolArray:
15
- Enabled: false
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
- Style/FrozenStringLiteralComment:
26
- Exclude:
27
- - 'spec/**/*.rb'
13
+ RSpec/MultipleExpectations:
14
+ Max: 5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [3.1.0] - 2024-08-16
4
+
5
+ ### Changed
6
+ - Change provider_groups to groups and add groups attribute to Params
7
+
8
+ ## [3.0.0] - 2024-06-12
9
+
10
+ ### Changed
11
+ - Remove dependency on Rails secrets and enable clients to choose how to manage secret parameters
12
+
13
+ ### Added
14
+ - RuboCop gems `factory_bot`, `infinum`, `rake`, `rspec_rails`
15
+ - GitHub Actions to build app image and run checks
16
+
17
+ ### Fixed
18
+ - RuboCop offenses
19
+
3
20
  ## [2.0.0] - 2024-03-12
4
21
 
5
22
  **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 (2.0.0)
4
+ infinum_azure (3.1.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-arm64-darwin)
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-arm64-darwin)
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,22 +38,29 @@ 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
- :deactivated_at, :provider_groups, :employee]
43
+ :deactivated_at, :groups, :employee]
46
44
 
47
45
  config.user_migration_scope = -> { resource_class.where(provider: 'infinum_id') }
48
46
  config.user_migration_operation = -> (record, resource) {
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
- * service_name(mandatory) - name of application
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
 
@@ -105,7 +89,7 @@ infinum_azure:
105
89
  * *last_name* _string_
106
90
  * *avatar_url* _string_
107
91
  * *deactivated_at* _datetime_
108
- * *provider_groups* _jsonb array_
92
+ * *groups* _jsonb array_
109
93
  * *employee* _boolean_
110
94
 
111
95
  2. Add following rows to resource model:
@@ -2,11 +2,12 @@
2
2
 
3
3
  module InfinumAzure
4
4
  module Api
5
- class BaseController < ActionController::Base
5
+ class BaseController < ApplicationController
6
6
  protect_from_forgery with: :null_session
7
7
  respond_to :json
8
8
 
9
- delegate :resource_name, :resource_class, to: InfinumAzure
9
+ delegate :resource_name, to: 'InfinumAzure.config'
10
+ delegate :resource_class, to: InfinumAzure
10
11
  end
11
12
  end
12
13
  end
@@ -27,7 +27,7 @@ module InfinumAzure
27
27
 
28
28
  def user_params
29
29
  normalized_azure_params
30
- .slice(*InfinumAzure.resource_attributes)
30
+ .slice(*InfinumAzure.config.resource_attributes)
31
31
  .merge(provider: InfinumAzure.provider)
32
32
  end
33
33
 
@@ -5,10 +5,11 @@ module InfinumAzure
5
5
  protect_from_forgery with: :exception
6
6
  respond_to :html
7
7
 
8
- delegate :resource_name, :resource_class, to: InfinumAzure
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
@@ -3,7 +3,7 @@
3
3
  module InfinumAzure
4
4
  class ResourcesController < InfinumAzure::ApplicationController
5
5
  def passthru
6
- render status: 404, plain: 'Not found. Logout passthru.'
6
+ render status: :not_found, plain: 'Not found. Logout passthru.'
7
7
  end
8
8
 
9
9
  def destroy
@@ -16,7 +16,8 @@ module InfinumAzure
16
16
  employee: {
17
17
  procedure: ->(value) { value&.include?('employees') },
18
18
  target_name: :groups
19
- }
19
+ },
20
+ groups: :propagate
20
21
  }.freeze
21
22
 
22
23
  def self.normalize(payload)
@@ -33,15 +34,13 @@ module InfinumAzure
33
34
  raise 'unsupported normalization'
34
35
  end
35
36
 
36
- instance_variable_set("@#{attribute}", value)
37
+ instance_variable_set(:"@#{attribute}", value)
37
38
  end
38
39
  end
39
40
 
40
41
  def as_json
41
- NORMALIZATIONS.keys.reduce({}) do |hash, key|
42
- hash[key] = instance_variable_get("@#{key}")
43
-
44
- hash
42
+ NORMALIZATIONS.keys.index_with do |key|
43
+ instance_variable_get(:"@#{key}")
45
44
  end
46
45
  end
47
46
 
@@ -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
 
@@ -0,0 +1,13 @@
1
+ name: infinum-azure
2
+
3
+ services:
4
+ runner:
5
+ build:
6
+ context: .
7
+ target: base
8
+ image: infinum-azure:1.0.0
9
+ volumes:
10
+ - .:/app:cached
11
+ command: ['bash']
12
+ stdin_open: true
13
+ tty: true
@@ -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 = ['Marko Ćilimković']
9
- spec.email = ['marko.cilimkovic@infinum.hr']
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 = '>= 2.7.0'
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
@@ -2,11 +2,38 @@
2
2
 
3
3
  module InfinumAzure
4
4
  class Config
5
- Defaults.all_attributes.each do |attr, value|
6
- attr_writer attr
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, :groups, :employee
10
+ ].freeze
7
11
 
8
- define_method(attr) do
9
- instance_variable_set("@#{attr}", instance_variable_get("@#{attr}") || value)
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InfinumAzure
4
- VERSION = '2.0.0'
4
+ VERSION = '3.1.0'
5
5
  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
- ensure_all_attributes_present!
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
@@ -40,7 +40,8 @@ module InfinumAzure
40
40
 
41
41
  private
42
42
 
43
- attr_accessor :users_updated_count, :emails_not_found
43
+ attr_accessor :users_updated_count
44
+ attr_accessor :emails_not_found
44
45
  end
45
46
  end
46
47
  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: 2.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Marko Ćilimković
7
+ - Rails team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-12 00:00:00.000000000 Z
11
+ date: 2024-08-19 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
- - marko.cilimkovic@infinum.hr
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,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
114
  requirements:
294
115
  - - ">="
295
116
  - !ruby/object:Gem::Version
296
- version: 2.7.0
117
+ version: '3.0'
297
118
  required_rubygems_version: !ruby/object:Gem::Requirement
298
119
  requirements:
299
120
  - - ">="
@@ -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