decidim-idcat_mobil 0.4.0 → 0.7.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: 9a927c46e7526679976cc90ba4177fab538391701909048db1e633833812c739
4
- data.tar.gz: 6e4daa2b14aac1694f959394a35eafe44a6e9ea7e9fafa6fc88892610885fa9e
3
+ metadata.gz: 1c8aa5a39998d9667154240a66c8bb92a97d399a567af9d6efd42abe2a8f4ca9
4
+ data.tar.gz: 1b7ad428aac1cb7fef51ee494f3d739e9102b47b8a9c56038756fbf8272bced8
5
5
  SHA512:
6
- metadata.gz: e61b85ffc84b1a35a04e718736115c51363f330911b78d4b0a06477598c17fd1b97745c30e7ddf344fdaaeccb8d6ae84ce9ee3dd08f4d72da781bcc27fd34ef0
7
- data.tar.gz: 742948914bdc94ce92ceecefcfd2659647412440c49b480f3a20e996f252c5a38fb400285c39064a452c708240c108b23f947bcd979dd9a979b6813b792319bf
6
+ metadata.gz: 4805fdc8c0d6592d9f0716a68a0ff07b61c5e799fe93901b3b8be0bbb0e85021f770bdd8745cdcdd1651ba5a26157e3ce16cbf36c9fa8d9436a930fcd1a5f5e6
7
+ data.tar.gz: 8e09a5186316beaaf46d16c2ac212440f77f93b6652c345b6dd8fcbaaed846c247e3f85e3a60cb98daec02a60b1ff3b7fb1df13eea47066c9a5bd6f41ce5f9f6
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  User registration and login through IdCat Mòbil, an authentication method that uses OAuth 2.0 protocol.
4
4
  _IdCat mòbil_ is an identity validator from VÀLid (Validador d'Identitats del Consorci AOC).
5
5
 
6
- User verification via IdCat Mòbil was started but is incomplete.
6
+ User is also verified with a VÀLid authorization.
7
7
 
8
8
  ## Installation
9
9
 
@@ -19,6 +19,13 @@ And then execute:
19
19
  bundle install
20
20
  ```
21
21
 
22
+ Verifications by default will expire after 90 days but optionally you can set it to your needs by setting the `VERIFICATION_EXPIRATION_TIME` environment variable.
23
+
24
+ ```bash
25
+ # change default value from 90 days to a whole year
26
+ VERIFICATION_EXPIRATION_TIME=365
27
+ ```
28
+
22
29
  ## Usage
23
30
 
24
31
  To use it you have to first configure the omniauth-idcat_mobil.
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module IdcatMobil
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module IdcatMobil
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Decidim
4
4
  module Verifications
5
- # A Handler form object that just holds OAuth2 data provided by AOC when performing "IdCat mòbil" authentication.
6
- class IdCatMobilHandler < AuthorizationHandler
5
+ # A Handler form object that just holds OAuth2 data provided by AOC when performing "VÀLid" authentication.
6
+ class ValidHandler < AuthorizationHandler
7
7
  attribute :oauth_data, Hash
8
8
 
9
9
  validates :unique_id, presence: true
@@ -18,7 +18,11 @@ module Decidim
18
18
  end
19
19
 
20
20
  def user
21
- Decidim::User.find(oauth_data[:user_id])
21
+ Decidim::User.find_by(id: oauth_data[:user_id])
22
+ end
23
+
24
+ def to_partial_path
25
+ "decidim/valid/verifications/form"
22
26
  end
23
27
 
24
28
  #-----------------------------------------------------------
@@ -29,14 +33,14 @@ module Decidim
29
33
  def idcatmobil_method?
30
34
  return true if oauth_data["method"] == "idcatmobil"
31
35
 
32
- errors.add(:base, I18n.t("decidim.verifications.idcat_mobil.errors.invalid_method"))
36
+ errors.add(:base, I18n.t("decidim.verifications.valid.errors.invalid_method"))
33
37
  false
34
38
  end
35
39
 
36
40
  def has_ok_status?
37
41
  return true if oauth_data["status"] == "ok"
38
42
 
39
- errors.add(:base, I18n.t("decidim.verifications.idcat_mobil.errors.invalid_status"))
43
+ errors.add(:base, I18n.t("decidim.verifications.valid.errors.invalid_status"))
40
44
  false
41
45
  end
42
46
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
- module IdcatMobil
4
+ module Valid
5
5
  class ApplicationJob < ActiveJob::Base
6
6
  end
7
7
  end
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
- module IdcatMobil
4
+ module Valid
5
5
  class VerificationJob < ApplicationJob
6
6
  queue_as :default
7
7
 
8
8
  def perform(oauth_data)
9
+ authorization ||= Decidim::Authorization.find_by(unique_id: handler.unique_id)
10
+ return if authorization&.granted?
11
+
9
12
  handler = retrieve_handler(oauth_data)
10
13
  Decidim::Verifications::AuthorizeUser.call(handler) do
11
14
  on(:ok) do
@@ -25,7 +28,7 @@ module Decidim
25
28
 
26
29
  # Retrieves handler from Verification workflows registry.
27
30
  def retrieve_handler(oauth_data)
28
- Decidim::AuthorizationHandler.handler_for("idcat_mobil", oauth_data: oauth_data)
31
+ Decidim::AuthorizationHandler.handler_for(:valid, oauth_data:)
29
32
  end
30
33
 
31
34
  def notify_user(user, status, handler)
@@ -36,7 +39,7 @@ module Decidim
36
39
  # resource: result,
37
40
  recipient_ids: [user.id],
38
41
  extra: {
39
- status: status,
42
+ status:,
40
43
  errors: handler.errors.full_messages
41
44
  }
42
45
  )
@@ -1,2 +1,4 @@
1
1
  // Images
2
2
  require.context("../images", true)
3
+
4
+ import "entrypoints/decidim_valid_idcat_mobil.scss";
@@ -0,0 +1 @@
1
+ @import "stylesheets/decidim/valid_idcat_mobil";
@@ -0,0 +1,11 @@
1
+ .social-register,.cancel {
2
+ margin: 2em 3em;
3
+ }
4
+
5
+ .actions {
6
+ display: none;
7
+ }
8
+
9
+ .skip {
10
+ display: none;
11
+ }
@@ -0,0 +1,29 @@
1
+ <%
2
+ provider_str = t("decidim.authorization_handlers.valid_handler.name")
3
+ %>
4
+ <% if Devise.mappings[:user].omniauthable? && current_organization.enabled_omniauth_providers.dig(:idcat_mobil, :enabled) %>
5
+
6
+ <h5><%= t("decidim.authorization_handlers.trusted_ids_handler.explanation") %></h5>
7
+
8
+ <p><%= t(".description_html", provider: provider_str, link: t("devise.shared.links.log_in_with_provider", provider: provider_str)) %></p>
9
+ <div class="callout secondary"><%= t(".warning_html", email: current_user.email, provider: provider_str) %></div>
10
+
11
+ <div class="social-register">
12
+ <%= link_to decidim.send("user_idcat_mobil_omniauth_authorize_path"), class: "button button--social button--#{normalize_provider_name(idcat_mobil)}", method: :post do %>
13
+ <span class="button--social__icon">
14
+ <%= oauth_icon provider %>
15
+ </span>
16
+ <span class="button--social__text">
17
+ <%= t("devise.shared.links.log_in_with_provider", provider: provider_str) %>
18
+ </span>
19
+ <% end %>
20
+ </div>
21
+ <% else %>
22
+ <p><%= t(".error_provider_html", provider: provider_str) %></p>
23
+ <% end %>
24
+
25
+ <div class="cancel">
26
+ <%= form.submit t(".cancel"), class: "button expanded secondary hollow" %>
27
+ </div>
28
+
29
+ <%= append_stylesheet_pack_tag "valid_idcat_mobil" %>
@@ -1,14 +1,18 @@
1
1
  ---
2
2
  ca:
3
3
  decidim:
4
- components:
5
- idcat_mobil:
6
- name: IdCat Mòbil
4
+ authorization_handlers:
5
+ valid_handler:
6
+ name: VÀLid
7
+ valid:
8
+ explanation: Verificació d'identitat a través de VÀLid
9
+ name: VÀLid
7
10
  verifications:
8
- idcat_mobil:
11
+ valid:
9
12
  errors:
10
13
  invalid_method: No us heu pogut verificar. El mètode de verificació OAuth2 no era "idcat_mobil" tal com s'esperava.
11
14
  invalid_status: No us heu pogut verificar. La verificació OAuth2 ha estat correcta.
15
+ idcat_mobil:
12
16
  invalid:
13
17
  email_intro: No s'ha pogut concedir l'autorització d'IdCat Mòbil.
14
18
  email_outro: Si us plau, poseu-vos en contacte amb el suport de la vostra plataforma per comprovar l'error que s'ha produït.
@@ -1,14 +1,18 @@
1
1
  ---
2
2
  en:
3
3
  decidim:
4
- components:
5
- idcat_mobil:
6
- name: IdCat Mòbil
4
+ authorization_handlers:
5
+ valid_handler:
6
+ name: VÀLid
7
+ valid:
8
+ explanation: Identity verification through VÀLid
9
+ name: VÀLid
7
10
  verifications:
8
- idcat_mobil:
11
+ valid:
9
12
  errors:
10
13
  invalid_method: Could not verify you. OAuth2 verification method was not 'idcat_mobil' as expected.
11
14
  invalid_status: Could not verify you. OAuth2 verification was not ok.
15
+ idcat_mobil:
12
16
  invalid:
13
17
  email_intro: It has not been possible to grant you the IdCat Mòbil authorization.
14
18
  email_outro: Please, contact the support at your platform to check what has gone wrong.
@@ -1,14 +1,18 @@
1
1
  ---
2
2
  es:
3
3
  decidim:
4
- components:
5
- idcat_mobil:
6
- name: IdCat Mòbil
4
+ authorization_handlers:
5
+ valid_handler:
6
+ name: VÀLid
7
+ valid:
8
+ explanation: Verificación de identidad a través de VÀLid
9
+ name: VÀLid
7
10
  verifications:
8
- idcat_mobil:
11
+ valid:
9
12
  errors:
10
13
  invalid_method: No se pudo verificar. El método de verificación OAuth2 no fue 'idcat_mobil' como se esperaba.
11
14
  invalid_status: No se pudo verificar. La verificación OAuth2 no ha sido correcta.
15
+ idcat_mobil:
12
16
  invalid:
13
17
  email_intro: No ha sido posible otorgarle la autorización IdCat Mòbil.
14
18
  email_outro: Por favor, póngase en contacto con el soporte en su plataforma para comprobar qué ha fallado.
@@ -1,14 +1,18 @@
1
1
  ---
2
2
  oc:
3
3
  decidim:
4
- components:
5
- idcat_mobil:
6
- name: IdCat Mòbil
4
+ authorization_handlers:
5
+ valid_handler:
6
+ name: VÀLid
7
+ valid:
8
+ explanation: Verificació d'identitat a través de VÀLid
9
+ name: VÀLid
7
10
  verifications:
8
- idcat_mobil:
11
+ valid:
9
12
  errors:
10
13
  invalid_method: No vos auetz pogut verificar. Eth metòde de verificacion OAuth2 non ère "idcat_mobil" tau coma se demoraue.
11
14
  invalid_status: No vos auetz pogut verificar. Era verificacion OAuth2 a estat corrècta.
15
+ idcat_mobil:
12
16
  invalid:
13
17
  email_intro: Non s'a pogut concedir era autorizacion de IdCat Mòbil.
14
18
  email_outro: Se vos platz, metetz-vos eth contacte damb eth supòrt dera vòsta plataforma entà verificar er error que s'a produsit.
@@ -16,6 +16,13 @@ module Decidim
16
16
  # root to: "idcat_mobil#index"
17
17
  end
18
18
 
19
+ initializer "decidim_valid.authorizations" do
20
+ # Triggers user verification after login/registration
21
+ ActiveSupport::Notifications.subscribe "decidim.user.omniauth_registration" do |_name, data|
22
+ Decidim::Valid::OnOmniauthRegistrationListener.on_omniauth_registration(data)
23
+ end
24
+ end
25
+
19
26
  initializer "decidim_idcat_mobil.webpacker.assets_path" do
20
27
  Decidim.register_assets_path File.expand_path("app/packs", root)
21
28
  end
@@ -4,11 +4,11 @@ module Decidim
4
4
  module IdcatMobil
5
5
  def self.version
6
6
  # See CHANGELOG.md to see what changed
7
- "0.4.0"
7
+ "0.7.0"
8
8
  end
9
9
 
10
10
  def self.decidim_version
11
- "0.27.0"
11
+ "0.29.0"
12
12
  end
13
13
  end
14
14
  end
@@ -3,12 +3,25 @@
3
3
  require "decidim/admin"
4
4
  require "decidim/verifications"
5
5
 
6
- require "decidim/idcat_mobil/on_omniauth_registration_listener"
7
6
  require "decidim/idcat_mobil/engine"
7
+ require "decidim/valid/on_omniauth_registration_listener"
8
8
 
9
9
  module Decidim
10
10
  # This namespace holds the logic of the `IdcatMobil` component. This component
11
11
  # allows users to create idcat_mobil in a participatory space.
12
12
  module IdcatMobil
13
13
  end
14
+
15
+ # The VÀLid module is only used for the user Verification.
16
+ module Valid
17
+ include ActiveSupport::Configurable
18
+
19
+ # how long the verification will be valid, defaults to 90 days
20
+ # if empty or nil, the verification will never expire
21
+ config_accessor :verification_expiration_time do
22
+ ENV.fetch("VERIFICATION_EXPIRATION_TIME", 90).to_i.days
23
+ end
24
+ end
14
25
  end
26
+
27
+ require "decidim/valid/workflow"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
- module IdcatMobil
4
+ module Valid
5
5
  #
6
6
  # Simply delegates the management of verifying IdCat mòbil to the VerificationJob.
7
7
  #
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verify the user with a VÀLid authentication when registered via OAuth
4
+ Decidim::Verifications.register_workflow(:valid) do |workflow|
5
+ workflow.form = "Decidim::Verifications::ValidHandler"
6
+ workflow.expires_in = Decidim::Valid.verification_expiration_time.to_i
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-idcat_mobil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Valls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-26 00:00:00.000000000 Z
11
+ date: 2026-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim
@@ -16,56 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.27.0
19
+ version: 0.29.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.27.0
26
+ version: 0.29.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: decidim-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.27.0
33
+ version: 0.29.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.27.0
40
+ version: 0.29.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: omniauth-idcat_mobil
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.0
47
+ version: 0.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.0
55
- - !ruby/object:Gem::Dependency
56
- name: decidim-dev
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 0.27.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.27.0
54
+ version: 0.6.0
69
55
  description: User registration, login and verification though VÀLid's IdCat mòbil..
70
56
  email:
71
57
  - oliver.vh@coditramuntana.com
@@ -80,13 +66,16 @@ files:
80
66
  - app/controllers/decidim/idcat_mobil/application_controller.rb
81
67
  - app/events/decidim/idcat_mobil/verification_invalid_notification.rb
82
68
  - app/events/decidim/idcat_mobil/verification_success_notification.rb
83
- - app/forms/decidim/verifications/id_cat_mobil_handler.rb
69
+ - app/forms/decidim/verifications/valid_handler.rb
84
70
  - app/helpers/decidim/idcat_mobil/application_helper.rb
85
- - app/jobs/decidim/idcat_mobil/application_job.rb
86
- - app/jobs/decidim/idcat_mobil/verification_job.rb
71
+ - app/jobs/decidim/valid/application_job.rb
72
+ - app/jobs/decidim/valid/verification_job.rb
87
73
  - app/models/decidim/idcat_mobil/application_record.rb
88
74
  - app/packs/entrypoints/decidim-idcat_mobil.js
75
+ - app/packs/entrypoints/decidim_valid_idcat_mobil.scss
89
76
  - app/packs/images/idcat_mobil-icon.svg
77
+ - app/packs/stylesheets/decidim/valid_idcat_mobil.scss
78
+ - app/views/decidim/valid/verifications/_form.html.erb
90
79
  - config/assets.rb
91
80
  - config/i18n-tasks.yml
92
81
  - config/initializers/omniauth_idcat_mobil.rb
@@ -95,13 +84,11 @@ files:
95
84
  - config/locales/es.yml
96
85
  - config/locales/oc.yml
97
86
  - lib/decidim/idcat_mobil.rb
98
- - lib/decidim/idcat_mobil/admin.rb
99
- - lib/decidim/idcat_mobil/admin_engine.rb
100
- - lib/decidim/idcat_mobil/component.rb
101
87
  - lib/decidim/idcat_mobil/engine.rb
102
- - lib/decidim/idcat_mobil/on_omniauth_registration_listener.rb
103
88
  - lib/decidim/idcat_mobil/test/factories.rb
104
89
  - lib/decidim/idcat_mobil/version.rb
90
+ - lib/decidim/valid/on_omniauth_registration_listener.rb
91
+ - lib/decidim/valid/workflow.rb
105
92
  homepage: https://github.com/decidim/decidim-idcat_mobil
106
93
  licenses:
107
94
  - AGPL-3.0
@@ -115,14 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
102
  requirements:
116
103
  - - ">="
117
104
  - !ruby/object:Gem::Version
118
- version: 3.0.6
105
+ version: 3.2.9
119
106
  required_rubygems_version: !ruby/object:Gem::Requirement
120
107
  requirements:
121
108
  - - ">="
122
109
  - !ruby/object:Gem::Version
123
110
  version: '0'
124
111
  requirements: []
125
- rubygems_version: 3.2.33
112
+ rubygems_version: 3.4.19
126
113
  signing_key:
127
114
  specification_version: 4
128
115
  summary: A decidim idcat_mobil module
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # # frozen_string_literal: true
4
-
5
- # module Decidim
6
- # module IdcatMobil
7
- # # This module contains all the domain logic associated to Decidim's IdcatMobil
8
- # # component admin panel.
9
- # module Admin
10
- # end
11
- # end
12
- # end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # # frozen_string_literal: true
4
-
5
- # module Decidim
6
- # module IdcatMobil
7
- # # This is the engine that runs on the public interface of `IdcatMobil`.
8
- # class AdminEngine < ::Rails::Engine
9
- # isolate_namespace Decidim::IdcatMobil::Admin
10
-
11
- # paths["db/migrate"] = nil
12
- # paths["lib/tasks"] = nil
13
-
14
- # routes do
15
- # # Add admin engine routes here
16
- # # resources :idcat_mobil do
17
- # # collection do
18
- # # resources :exports, only: [:create]
19
- # # end
20
- # # end
21
- # # root to: "idcat_mobil#index"
22
- # end
23
-
24
- # def load_seed
25
- # nil
26
- # end
27
- # end
28
- # end
29
- # end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # # frozen_string_literal: true
4
-
5
- # require_dependency "decidim/components/namer"
6
-
7
- # Decidim.register_component(:idcat_mobil) do |component|
8
- # component.engine = Decidim::IdcatMobil::Engine
9
- # component.admin_engine = Decidim::IdcatMobil::AdminEngine
10
- # component.icon = "decidim/idcat_mobil/icon.svg"
11
-
12
- # # component.on(:before_destroy) do |instance|
13
- # # # Code executed before removing the component
14
- # # end
15
-
16
- # # These actions permissions can be configured in the admin panel
17
- # # component.actions = %w()
18
-
19
- # # component.settings(:global) do |settings|
20
- # # # Add your global settings
21
- # # # Available types: :integer, :boolean
22
- # # # settings.attribute :vote_limit, type: :integer, default: 0
23
- # # end
24
-
25
- # # component.settings(:step) do |settings|
26
- # # # Add your settings per step
27
- # # end
28
-
29
- # # component.register_resource(:some_resource) do |resource|
30
- # # # Register a optional resource that can be references from other resources.
31
- # # resource.model_class_name = "Decidim::IdcatMobil::SomeResource"
32
- # # resource.template = "decidim/idcat_mobil/some_resources/linked_some_resources"
33
- # # end
34
-
35
- # # component.register_stat :some_stat do |context, start_at, end_at|
36
- # # # Register some stat number to the application
37
- # # end
38
-
39
- # # component.seeds do |participatory_space|
40
- # # # Add some seeds for this component
41
- # # end
42
- # end