thecore_auth_commons 3.6.2 → 3.6.3
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 +4 -4
- data/README.md +1 -1
- data/lib/thecore_auth_commons/version.rb +1 -1
- data/lib/thecore_auth_commons.rb +14 -10
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e5604a65938fe43fe952c42c11bdc339ff3217d7d0ca63b659ae5c871c9be5f
|
|
4
|
+
data.tar.gz: a7a71c049092955e8e2d47c0117ed62e693d7505ea21cb74ad0d9a3837ab4d13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f13691ce6ca514d637d5031ac1e1555a5a23823e9b669c4c4333d237d8a8c4e0761177932471784597e305cc6a4d46907336921cc096cbf325fb1f93434caa70
|
|
7
|
+
data.tar.gz: dec750f7817baa78f77da553e0dc0cc787b4765937ca2ebf6822de8cd23d1f657af4e19450843c2c5d10852028ac644af8f5db6a9bda43d00659f000c411d6f9
|
data/README.md
CHANGED
|
@@ -112,7 +112,7 @@ Deleting a `LdapServer` record keeps all users whose `auth_source` is `"ldap #{i
|
|
|
112
112
|
|
|
113
113
|
### OAuth2 (Entra ID / Google)
|
|
114
114
|
|
|
115
|
-
Handled by `Users::OmniauthCallbacksController`. On callback, `ThecoreAuthCommons.check_user` finds
|
|
115
|
+
Handled by `Users::OmniauthCallbacksController`. On callback, `ThecoreAuthCommons.check_user` finds the user by the provider-verified email or creates them (random secure password, `auth_source` `'google'` or `'microsoft'`, no admin, no roles: an administrator assigns those). An existing user's password, admin flag and `auth_source` are never changed by an OAuth login.
|
|
116
116
|
|
|
117
117
|
## Password policy
|
|
118
118
|
|
data/lib/thecore_auth_commons.rb
CHANGED
|
@@ -30,18 +30,22 @@ module ThecoreAuthCommons
|
|
|
30
30
|
ENV["GOOGLE_CLIENT_ID"].present? && ENV["GOOGLE_CLIENT_SECRET"].present?
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
|
|
33
|
+
# Restituisce l'utente con l'email verificata dal provider OAuth, creandolo se non esiste:
|
|
34
|
+
# password casuale, auth_source = provider, nessun admin e nessun ruolo (si assegnano a mano).
|
|
35
|
+
# Di un utente esistente aggiorna solo nome e cognome: password, admin e auth_source restano,
|
|
36
|
+
# così chi ha anche una password locale può continuare a usarla. nil se l'utente non è salvabile.
|
|
36
37
|
def self.check_user(email, name, surname, provider)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
u
|
|
40
|
-
u.
|
|
41
|
-
u.
|
|
42
|
-
u.
|
|
38
|
+
return if email.blank?
|
|
39
|
+
|
|
40
|
+
u = User.find_or_initialize_by(email: email.to_s.strip.downcase)
|
|
41
|
+
u.name = name if u.respond_to?(:name=)
|
|
42
|
+
u.surname = surname if u.respond_to?(:surname=)
|
|
43
|
+
if u.new_record?
|
|
44
|
+
u.password = u.password_confirmation = generate_secure_password
|
|
45
|
+
u.auth_source = provider # 'google' or 'microsoft'
|
|
46
|
+
end
|
|
43
47
|
u.save if u.changed?
|
|
44
|
-
u
|
|
48
|
+
u if u.persisted?
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
INITIAL_ADMIN_PASSWORD_FILE = "admin_initial_password".freeze
|