thecore_auth_commons 3.5.2 → 3.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29a083c2300c45d950b99efa4ff7e8a5642c11212acd01d392bb07f63fb38a19
4
- data.tar.gz: 9a20546917d55959cf5aa5d4c272c43e7f09efc5888d80d05d9edbb634b499f8
3
+ metadata.gz: 7325e9f014b30e25244254412dffa1628d83db89c627059c6c253a6e24c94fc0
4
+ data.tar.gz: 9bb9f596f65baff791158e1a95eef62632eb2f8414720a42917beb493e82c0da
5
5
  SHA512:
6
- metadata.gz: dbf9f9bcc726736caf0b785807609235d98b56f2180e9b9bd1af32b1167333c739ab27d6992a038b33d8a859612ce09bb6474f9f9851c5f4f0aa6bb74ebb702b
7
- data.tar.gz: edf61e953a0cc68f0d9bde2866499e609241519f9511397cb6730e6549d560cfebbdb2a395ec0f61020c8ca0e8a2089b0c7f4dfe6e59e4dec92629ade6066b67
6
+ metadata.gz: f42b1e563d495c42b65189f746922aabe361b2355d73c63ad07df47fe851e7364d2532dd46fc260fdfa4e5543b32571eb5f0b0d0f064635e87ad80edf5ceab5b
7
+ data.tar.gz: 948132adb3cae41b8f7eebfb2d9aff0414b8dd4c234a99015b1e9ca0961a8de9124c9f9231be7982f5ce7bc324f518db4d0c006006da5023411caeb181fda7d8
@@ -1,10 +1,10 @@
1
1
  # app/controllers/users/omniauth_callbacks_controller.rb
2
2
  class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
3
- def google_oauth2
3
+ def google
4
4
  callback 'Google', from_params, 'google'
5
5
  end
6
6
 
7
- def entra_id
7
+ def microsoft
8
8
  callback 'Microsoft Entra ID', from_params, 'entra_id'
9
9
  end
10
10
 
data/app/models/user.rb CHANGED
@@ -8,7 +8,10 @@ class User < ApplicationRecord
8
8
  :validatable,
9
9
  # Devise modules configurations:
10
10
  # Omniauthable allows the user to sign in with external providers
11
- :omniauth_providers => [:google_oauth2, :entra_id],
11
+ :omniauth_providers => [
12
+ ThecoreAuthCommons.entra_id_vars? && 'microsoft',
13
+ ThecoreAuthCommons.google_oauth2_vars? && 'google'
14
+ ].select(&:itself).compact,
12
15
  # Validatable allows the user to validate their email and password
13
16
  :password_length => ENV.fetch('MIN_PASSWORD_LENGTH', 8).to_i..128,
14
17
  :timeout_in => ENV.fetch('SESSION_TIMEOUT_IN_MINUTES', 31).to_i.minutes
@@ -8,12 +8,10 @@ Rails.application.config.middleware.use OmniAuth::Builder do
8
8
  client_secret: ENV['ENTRA_CLIENT_SECRET'],
9
9
  tenant_id: ENV['ENTRA_TENANT_ID'], # Needed for Microsoft
10
10
  scope: 'openid profile email User.Read',
11
- response_type: 'code'
12
- },
13
- {
14
- label: "Microsoft"
11
+ response_type: 'code',
12
+ name: "microsoft"
15
13
  }
16
- )
14
+ ) if ThecoreAuthCommons.entra_id_vars?
17
15
  provider(
18
16
  :google_oauth2,
19
17
  ENV['GOOGLE_CLIENT_ID'],
@@ -21,9 +19,10 @@ Rails.application.config.middleware.use OmniAuth::Builder do
21
19
  {
22
20
  scope: 'email,profile',
23
21
  prompt: 'select_account',
24
- access_type: 'online'
22
+ access_type: 'online',
23
+ name: "google"
25
24
  }
26
- )
25
+ ) if ThecoreAuthCommons.google_oauth2_vars?
27
26
  end
28
27
 
29
28
  OmniAuth.config.allowed_request_methods = [:get, :post]
@@ -53,6 +53,7 @@ it:
53
53
  third_party: Ente Terzo?
54
54
  password: Password
55
55
  password_confirmation: Conferma Password
56
+ auth_source: Autenticazione
56
57
  role:
57
58
  users: Utenti
58
59
  name: Ruolo
@@ -1,3 +1,3 @@
1
1
  module ThecoreAuthCommons
2
- VERSION = "3.5.2".freeze
2
+ VERSION = "3.5.5".freeze
3
3
  end
@@ -14,9 +14,20 @@ require "thecore/seed"
14
14
 
15
15
  module ThecoreAuthCommons
16
16
  def self.oauth_vars?
17
- (ENV['ENTRA_CLIENT_ID'].present? && ENV['ENTRA_CLIENT_SECRET'].present? && ENV['ENTRA_TENANT_ID'].present?) || (ENV['GOOGLE_CLIENT_ID'].present? && ENV['GOOGLE_CLIENT_SECRET'].present?)
17
+ entra_id_vars? || google_oauth2_vars?
18
18
  end
19
19
 
20
+ def self.entra_id_vars?
21
+ ENV['ENTRA_CLIENT_ID'].present? && ENV['ENTRA_CLIENT_SECRET'].present? && ENV['ENTRA_TENANT_ID'].present?
22
+ end
23
+
24
+ def self.google_oauth2_vars?
25
+ ENV['GOOGLE_CLIENT_ID'].present? && ENV['GOOGLE_CLIENT_SECRET'].present?
26
+ end
27
+
28
+ # Controlla se l'utente esiste, altrimenti lo crea con una password casuale
29
+ # e lo restituisce. Se l'utente esiste già, lo restituisce senza modificarlo.
30
+
20
31
  def self.check_user email, name, surname, provider
21
32
  u = User.find_or_initialize_by(email: email)
22
33
  u.name = name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_auth_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 3.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
@@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
298
  - !ruby/object:Gem::Version
299
299
  version: '0'
300
300
  requirements: []
301
- rubygems_version: 3.6.7
301
+ rubygems_version: 3.6.9
302
302
  specification_version: 4
303
303
  summary: Common Auth methods and models to be used in thecore components.
304
304
  test_files: []