decidim-trusted_ids 0.12.0 → 0.13.0

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: 2add148a8358a933c509c5e86641e8f067f44e7d6d0f890652dc59e233e336f1
4
- data.tar.gz: 516b88091bf1caa1105eb4d3c3374c1e1743a48e4e9230db0a2843f0e371d83d
3
+ metadata.gz: 1b7f4bc28edbb47bd7dc527d03d4d7e1f24dc93dc499c5c3b182193f5d9cfc4c
4
+ data.tar.gz: 95cd5a3983405d107072f2c1a847899ce69a1a0b6b59d8ab6a94b5a3627900ab
5
5
  SHA512:
6
- metadata.gz: 844a68f0ffe486b8f4c98606e05800b586a91a4c01360c5b924d67bf5f1a429321c646c4623cf2fdc42120fbeb9dd6b85b232daf613148811feb2dbc62fb16f5
7
- data.tar.gz: bc7c4a6275fb737551f1a3e0fa73544abaa49808449f28c5dd7a7542bba604fd8f03227beb8cff72bea240fe6420145726f6e24b1fe2dd196cca845191524230
6
+ metadata.gz: 71c723aa05ab5f68ede805083abf98c138805f83241b440236088206c4a0f0b4fa9235ff3b4d39007c38a9a8ca7a2922b56321d3d30820886380177a0c11ffd4
7
+ data.tar.gz: 8d92bd7edc4eba33035e2109e94f6f47c3756c3a43e6d68eb5351126ee6db79fadd6135823029c968022ec1d0706496cf50211efcd0b1eb010fb6b5e8c2e135d
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Decidim :: Trusted IDs
1
+ # Decidim :: Authenticated identities for the public sector
2
2
 
3
3
  [![[CI] Lint](https://github.com/ConsorciAOC-PRJ/decidim-module-trusted-ids/actions/workflows/lint.yml/badge.svg)](https://github.com/ConsorciAOC-PRJ/decidim-module-trusted-ids/actions/workflows/lint.yml)
4
4
  [![[CI] Test](https://github.com/ConsorciAOC-PRJ/decidim-module-trusted-ids/actions/workflows/test.yml/badge.svg)](https://github.com/ConsorciAOC-PRJ/decidim-module-trusted-ids/actions/workflows/test.yml)
@@ -170,21 +170,25 @@ If you are using a different source for your settings, you can also configure th
170
170
  For instance, create a file `config/initializers/decidim_trusted_ids.rb` with the following content:
171
171
 
172
172
  ```ruby
173
- Decidim::TrustedIds.configure do |config|
174
- # The name of the omniauth provider, must be registered in Decidim.
175
- config.omniauth_provider = "valid"
176
- config.omniauth = {
177
- enabled: true,
178
- client_id: "my-client-id",
179
- client_secret: "my-client-secret",
180
- site: "https://valid.aoc.cat",
181
- scope: "autenticacio_usuari",
182
- icon: "media/images/valid-icon.png"
183
- },
184
- ...
185
- end
173
+ Decidim::TrustedIds.omniauth_provider = "valid"
174
+ Decidim::TrustedIds.omniauth = {
175
+ enabled: true,
176
+ client_id: "my-client-id",
177
+ client_secret: "my-client-secret",
178
+ site: "https://valid.aoc.cat",
179
+ scope: "autenticacio_usuari",
180
+ icon_path: "media/images/valid-icon.png"
181
+ }
182
+ Decidim::TrustedIds.census_authorization = {
183
+ handler: :via_oberta_handler,
184
+ form: "Decidim::ViaOberta::Verifications::ViaObertaHandler",
185
+ env: "production",
186
+ system_attributes: %w(nif ine municipal_code province_code organization_name)
187
+ }
186
188
  ```
187
189
 
190
+ Set only the values you need to override. The available settings are the accessors defined in [`lib/decidim/trusted_ids.rb`](lib/decidim/trusted_ids.rb); assign them directly on `Decidim::TrustedIds` as shown above.
191
+
188
192
  For the complete list of available options, see the [trusted_ids](lib/decidim/trusted_ids.rb) file.
189
193
 
190
194
  ### Screenshots
@@ -8,7 +8,7 @@ module Decidim
8
8
 
9
9
  included do
10
10
  def save_census_config!(organization)
11
- conf = Decidim::TrustedIds::OrganizationConfig.find_or_initialize_by(organization: organization)
11
+ conf = Decidim::TrustedIds::OrganizationConfig.find_or_initialize_by(organization:)
12
12
  conf.handler = TrustedIds.census_authorization[:handler]
13
13
  return if conf.handler.blank?
14
14
 
@@ -13,13 +13,13 @@ module Decidim
13
13
  helper Decidim::OmniauthHelper
14
14
 
15
15
  # the internal 1st step verification shouldn't be used for impersonations as it is linked with an OAuth login
16
- def other_available_authorization_handlers
16
+ def other_available_authorization_handlers # rubocop:disable Decidim/EnforcePermissionTo
17
17
  Decidim::Verifications::Adapter.from_collection(
18
18
  current_organization.available_authorization_handlers - [handler_name, "trusted_ids_handler"]
19
19
  )
20
20
  end
21
21
 
22
- def available_authorization_handlers
22
+ def available_authorization_handlers # rubocop:disable Decidim/EnforcePermissionTo
23
23
  Decidim::Verifications::Adapter.from_collection(
24
24
  current_organization.available_authorization_handlers - ["trusted_ids_handler"]
25
25
  )
@@ -17,7 +17,7 @@ module Decidim
17
17
  return if current_user.email == verified_email
18
18
 
19
19
  flash[:alert] = I18n.t("decidim.trusted_ids.sessions.different_omniauth_emails")
20
- redirect_back fallback_location: account_path
20
+ redirect_back_or_to(account_path)
21
21
  end
22
22
  end
23
23
  end
@@ -14,8 +14,8 @@ module Decidim
14
14
 
15
15
  def metadata
16
16
  super.merge(
17
- uid: uid,
18
- provider: provider,
17
+ uid:,
18
+ provider:,
19
19
  extra: extra_attributes
20
20
  )
21
21
  end
@@ -59,7 +59,7 @@ module Decidim
59
59
  end
60
60
 
61
61
  def census_response
62
- @census_response ||= ViaOberta::Api::Request.new(document_id: document_id, document_type: document_type, organization: organization).response
62
+ @census_response ||= ViaOberta::Api::Request.new(document_id:, document_type:, organization:).response
63
63
  end
64
64
 
65
65
  def existing_via_oberta_identity
@@ -91,7 +91,7 @@ module Decidim
91
91
  end
92
92
 
93
93
  def trusted_authorization
94
- @trusted_authorization ||= Decidim::Authorization.find_by(name: "trusted_ids_handler", user: user)
94
+ @trusted_authorization ||= Decidim::Authorization.find_by(name: "trusted_ids_handler", user:)
95
95
  end
96
96
 
97
97
  def organization
@@ -34,7 +34,7 @@ module Decidim
34
34
  end
35
35
 
36
36
  def handler
37
- @handler ||= Decidim::AuthorizationHandler.handler_for("trusted_ids_handler", user: user, uid: data[:uid], provider: data[:provider], raw_data: data[:raw_data])
37
+ @handler ||= Decidim::AuthorizationHandler.handler_for("trusted_ids_handler", user:, uid: data[:uid], provider: data[:provider], raw_data: data[:raw_data])
38
38
  end
39
39
 
40
40
  def authorization
@@ -5,6 +5,7 @@ module Decidim
5
5
  class OrganizationConfig < ApplicationRecord
6
6
  include Decidim::TranslatableResource
7
7
  include Decidim::TranslatableAttributes
8
+
8
9
  self.table_name = "organization_trusted_ids_configs"
9
10
 
10
11
  belongs_to :organization,
@@ -31,12 +31,12 @@ de:
31
31
  authorization_handlers:
32
32
  trusted_ids_handler:
33
33
  explanation: This authorization is granted to all users who use a login method
34
- with a trusted identifier.
34
+ with an authenticated identity.
35
35
  fields:
36
36
  extra: Additional information
37
37
  provider: Provider
38
38
  uid: ID
39
- name: Trusted identifier
39
+ name: Authenticated identities
40
40
  via_oberta_handler:
41
41
  explanation: This authorization is granted to all users who are in the Via
42
42
  Oberta census database.
@@ -89,8 +89,8 @@ de:
89
89
  providers:
90
90
  default:
91
91
  description: This authorization is granted to all users who use a login
92
- method with a trusted identifier.
93
- name: Trusted identifier
92
+ method with an authenticated identity.
93
+ name: Authenticated identities
94
94
  valid:
95
95
  description: VÀLid is a service that AOC provides to Catalan public administrations
96
96
  to integrate the different available digital identification mechanisms (idCAT
@@ -32,12 +32,12 @@ en:
32
32
  authorization_handlers:
33
33
  trusted_ids_handler:
34
34
  explanation: This authorization is granted to all users who use a login method
35
- with a trusted identifier.
35
+ with an authenticated identity.
36
36
  fields:
37
37
  extra: Additional information
38
38
  provider: Provider
39
39
  uid: ID
40
- name: Trusted identifier
40
+ name: Authenticated identities
41
41
  via_oberta_handler:
42
42
  explanation: This authorization is granted to all users who are in the Via
43
43
  Oberta census database.
@@ -90,8 +90,8 @@ en:
90
90
  providers:
91
91
  default:
92
92
  description: This authorization is granted to all users who use a login
93
- method with a trusted identifier.
94
- name: Trusted identifier
93
+ method with an authenticated identity.
94
+ name: Authenticated identities
95
95
  valid:
96
96
  description: VÀLid is a service that AOC provides to Catalan public administrations
97
97
  to integrate the different available digital identification mechanisms
@@ -31,12 +31,12 @@ fr:
31
31
  authorization_handlers:
32
32
  trusted_ids_handler:
33
33
  explanation: This authorization is granted to all users who use a login method
34
- with a trusted identifier.
34
+ with an authenticated identity.
35
35
  fields:
36
36
  extra: Additional information
37
37
  provider: Provider
38
38
  uid: ID
39
- name: Trusted identifier
39
+ name: Authenticated identities
40
40
  via_oberta_handler:
41
41
  explanation: This authorization is granted to all users who are in the Via
42
42
  Oberta census database.
@@ -89,8 +89,8 @@ fr:
89
89
  providers:
90
90
  default:
91
91
  description: This authorization is granted to all users who use a login
92
- method with a trusted identifier.
93
- name: Trusted identifier
92
+ method with an authenticated identity.
93
+ name: Authenticated identities
94
94
  valid:
95
95
  description: VÀLid is a service that AOC provides to Catalan public administrations
96
96
  to integrate the different available digital identification systems (idCAT
@@ -31,12 +31,12 @@ it:
31
31
  authorization_handlers:
32
32
  trusted_ids_handler:
33
33
  explanation: This authorization is granted to all users who use a login method
34
- with a trusted identifier.
34
+ with an authenticated identity.
35
35
  fields:
36
36
  extra: Additional information
37
37
  provider: Provider
38
38
  uid: ID
39
- name: Trusted identifier
39
+ name: Authenticated identities
40
40
  via_oberta_handler:
41
41
  explanation: This authorization is granted to all users who are in the Via
42
42
  Oberta census database.
@@ -89,8 +89,8 @@ it:
89
89
  providers:
90
90
  default:
91
91
  description: This authorization is granted to all users who use a login
92
- method with a trusted identifier.
93
- name: Trusted identifier
92
+ method with an authenticated identity.
93
+ name: Authenticated identities
94
94
  valid:
95
95
  description: VÀLid is a service that AOC provides to Catalan public administrations
96
96
  to integrate the different available digital identification mechanisms (idCAT
@@ -3,8 +3,8 @@
3
3
  module Decidim
4
4
  # This holds the decidim-trusted_ids version.
5
5
  module TrustedIds
6
- VERSION = "0.12.0"
7
- DECIDIM_VERSION = "0.31.7"
8
- COMPAT_DECIDIM_VERSION = [">= 0.31", "< 0.32"].freeze
6
+ VERSION = "0.13.0"
7
+ DECIDIM_VERSION = "0.32.2"
8
+ COMPAT_DECIDIM_VERSION = [">= 0.32", "< 0.33"].freeze
9
9
  end
10
10
  end
@@ -5,8 +5,6 @@ require "decidim/trusted_ids/engine"
5
5
 
6
6
  module Decidim
7
7
  module TrustedIds
8
- include ActiveSupport::Configurable
9
-
10
8
  def self.omniauth_env(key, default = nil)
11
9
  ENV.fetch("#{TrustedIds.omniauth_provider.upcase}_#{key}", default)
12
10
  end
@@ -24,33 +22,35 @@ module Decidim
24
22
  end
25
23
  end
26
24
 
25
+ # Note that initialization on this module is done in the engine.rb file, as it needs to be done using dynamic values from the environment.
26
+
27
27
  # The name of the omniauth provider, must be registered in Decidim.
28
28
  # Leave it empty to disable omniauth authentication.
29
- config_accessor :omniauth_provider
29
+ mattr_accessor :omniauth_provider
30
30
 
31
31
  # From the data obtained we extract metadata to be saved as part of the authorization
32
32
  # This data can later be used by the census_authorization handler as to call the webservice
33
33
  # A hash with keys and how to find it inside hash comming from the OAuth
34
- config_accessor :authorization_metadata
34
+ mattr_accessor :authorization_metadata
35
35
 
36
36
  # setup a hash with :client_id, :client_secret and :site to enable omniauth authentication
37
- config_accessor :omniauth
37
+ mattr_accessor :omniauth
38
38
 
39
39
  # which of the former attributes can not set a the /system configuration, there are all the same for all tenants
40
- config_accessor :omniauth_global_attributes
40
+ mattr_accessor :omniauth_global_attributes
41
41
 
42
42
  # wheter to use a custom login screen or the default one
43
- config_accessor :custom_login_screen
43
+ mattr_accessor :custom_login_screen
44
44
 
45
45
  # how long the verification will be valid, defaults to 90 days
46
46
  # if empty or nil, the verification will never expire
47
- config_accessor :verification_expiration_time
47
+ mattr_accessor :verification_expiration_time
48
48
 
49
49
  # if false, no notifications will be send to users when automatic verifications are performed
50
- config_accessor :send_verification_notifications
50
+ mattr_accessor :send_verification_notifications
51
51
 
52
52
  # Linked authorization method that will automatically verify users after getting a valid TrustedIds verification
53
- config_accessor :census_authorization
53
+ mattr_accessor :census_authorization
54
54
 
55
55
  def self.census_config_attributes
56
56
  return [] if TrustedIds.census_authorization[:handler].blank?