decidim-zitadel 0.1.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 +7 -0
- data/LICENSE.md +661 -0
- data/README.md +115 -0
- data/Rakefile +434 -0
- data/app/forms/decidim/zitadel/admin/config_form.rb +91 -0
- data/app/helpers/decidim/zitadel/omniauth_button_helper.rb +18 -0
- data/app/overrides/decidim_zitadel_account_profile.rb +51 -0
- data/app/overrides/decidim_zitadel_login.rb +35 -0
- data/app/overrides/decidim_zitadel_omniauth_buttons.rb +74 -0
- data/app/views/decidim/zitadel/deface_partials/_account_profile.html.erb +12 -0
- data/app/views/decidim/zitadel/deface_partials/_header_login.html.erb +7 -0
- data/app/views/decidim/zitadel/deface_partials/_omniauth_button_label.html.erb +8 -0
- data/config/locales/de.yml +50 -0
- data/config/locales/en.yml +50 -0
- data/config/locales/fr.yml +50 -0
- data/config/locales/it.yml +50 -0
- data/db/migrate/20260101000001_create_decidim_zitadel_sessions.rb +17 -0
- data/db/seeds.rb +3 -0
- data/lib/decidim/zitadel/account_form_freeze.rb +35 -0
- data/lib/decidim/zitadel/auth_attributes.rb +50 -0
- data/lib/decidim/zitadel/availability.rb +35 -0
- data/lib/decidim/zitadel/complete_session.rb +28 -0
- data/lib/decidim/zitadel/discovery.rb +58 -0
- data/lib/decidim/zitadel/email_linker.rb +43 -0
- data/lib/decidim/zitadel/engine/overrides.rb +23 -0
- data/lib/decidim/zitadel/engine.rb +64 -0
- data/lib/decidim/zitadel/http_clients.rb +18 -0
- data/lib/decidim/zitadel/identity_resolver.rb +44 -0
- data/lib/decidim/zitadel/invite_csv.rb +60 -0
- data/lib/decidim/zitadel/oidc_end_session.rb +79 -0
- data/lib/decidim/zitadel/omniauth_registrations_override.rb +114 -0
- data/lib/decidim/zitadel/omniauth_setup.rb +137 -0
- data/lib/decidim/zitadel/organization_omniauth.rb +14 -0
- data/lib/decidim/zitadel/profile_completion.rb +65 -0
- data/lib/decidim/zitadel/profile_completion_guard.rb +60 -0
- data/lib/decidim/zitadel/profile_updater.rb +49 -0
- data/lib/decidim/zitadel/registrations_override.rb +9 -0
- data/lib/decidim/zitadel/seed_hook.rb +12 -0
- data/lib/decidim/zitadel/seeds.rb +42 -0
- data/lib/decidim/zitadel/sessions_override.rb +53 -0
- data/lib/decidim/zitadel/settings_tab.rb +18 -0
- data/lib/decidim/zitadel/sign_in_button_cache.rb +23 -0
- data/lib/decidim/zitadel/upgrade_hooks.rb +63 -0
- data/lib/decidim/zitadel/user_factory.rb +54 -0
- data/lib/decidim/zitadel/version.rb +13 -0
- data/lib/decidim/zitadel.rb +42 -0
- data/lib/decidim-zitadel.rb +3 -0
- data/lib/tasks/decidim_zitadel_tasks.rake +21 -0
- data/lib/tasks/decidim_zitadel_upgrade.rake +47 -0
- metadata +183 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Locked Zitadel users: hide locale/email/password; replace name with IdP profile link.
|
|
4
|
+
|
|
5
|
+
Deface::Override.new(
|
|
6
|
+
virtual_path: "decidim/account/show",
|
|
7
|
+
name: "decidim_zitadel_hide_account_name",
|
|
8
|
+
surround: "erb[loud]:contains('f.text_field :name')",
|
|
9
|
+
original: "<%= f.text_field :name, autocomplete: \"name\" %>",
|
|
10
|
+
text: <<~ERB
|
|
11
|
+
<%= render "decidim/zitadel/deface_partials/account_profile", zitadel_account_field: :name do %>
|
|
12
|
+
<%= render_original %>
|
|
13
|
+
<% end %>
|
|
14
|
+
ERB
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
Deface::Override.new(
|
|
18
|
+
virtual_path: "decidim/account/show",
|
|
19
|
+
name: "decidim_zitadel_hide_account_email",
|
|
20
|
+
surround: "erb[loud]:contains('f.email_field :email')",
|
|
21
|
+
original: "<%= f.email_field :email, disabled: current_user.unconfirmed_email.present?, autocomplete: \"email\", data: { original: current_user.email } %>",
|
|
22
|
+
text: <<~ERB
|
|
23
|
+
<%= render "decidim/zitadel/deface_partials/account_profile", zitadel_account_field: :email do %>
|
|
24
|
+
<%= render_original %>
|
|
25
|
+
<% end %>
|
|
26
|
+
ERB
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
Deface::Override.new(
|
|
30
|
+
virtual_path: "decidim/account/show",
|
|
31
|
+
name: "decidim_zitadel_hide_account_locale",
|
|
32
|
+
surround: "erb[loud]:contains('f.collection_select')",
|
|
33
|
+
original: "<%= f.collection_select(",
|
|
34
|
+
text: <<~ERB
|
|
35
|
+
<%= render "decidim/zitadel/deface_partials/account_profile", zitadel_account_field: :locale do %>
|
|
36
|
+
<%= render_original %>
|
|
37
|
+
<% end %>
|
|
38
|
+
ERB
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
Deface::Override.new(
|
|
42
|
+
virtual_path: "decidim/account/show",
|
|
43
|
+
name: "decidim_zitadel_hide_password_accordion",
|
|
44
|
+
surround: "div#accordion-password",
|
|
45
|
+
original: "<div data-component=\"accordion\" id=\"accordion-password\">",
|
|
46
|
+
text: <<~ERB
|
|
47
|
+
<%= render "decidim/zitadel/deface_partials/account_profile", zitadel_account_field: :password do %>
|
|
48
|
+
<%= render_original %>
|
|
49
|
+
<% end %>
|
|
50
|
+
ERB
|
|
51
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Header Log in keeps stock main-bar markup; href POSTs Zitadel OmniAuth.
|
|
4
|
+
# closing_selector must cover the link_to block. Surrounding only the opening
|
|
5
|
+
# `do` lets the next <% end %> close the anchor before the icon.
|
|
6
|
+
|
|
7
|
+
Deface::Override.new(
|
|
8
|
+
virtual_path: "layouts/decidim/header/_main_links_desktop",
|
|
9
|
+
name: "decidim_zitadel_header_login_desktop",
|
|
10
|
+
surround: "erb[loud]:contains('new_user_session_path')",
|
|
11
|
+
closing_selector: "erb[silent]:contains('end')",
|
|
12
|
+
original: "<%= link_to decidim.new_user_session_path, class: \"main-bar__links-desktop__item\", \"aria-label\": t(\"layouts.decidim.header.log_in\") do %>",
|
|
13
|
+
text: <<~ERB
|
|
14
|
+
<% if Decidim::Zitadel::Availability.enabled?(current_organization) %>
|
|
15
|
+
<%= render "decidim/zitadel/deface_partials/header_login", item_class: "main-bar__links-desktop__item" %>
|
|
16
|
+
<% else %>
|
|
17
|
+
<%= render_original %>
|
|
18
|
+
<% end %>
|
|
19
|
+
ERB
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
Deface::Override.new(
|
|
23
|
+
virtual_path: "layouts/decidim/header/_main_links_mobile_item_account",
|
|
24
|
+
name: "decidim_zitadel_header_login_mobile",
|
|
25
|
+
surround: "erb[loud]:contains('new_user_session_path')",
|
|
26
|
+
closing_selector: "erb[silent]:contains('end')",
|
|
27
|
+
original: "<%= link_to decidim.new_user_session_path, class: \"main-bar__links-mobile__login\" do %>",
|
|
28
|
+
text: <<~ERB
|
|
29
|
+
<% if Decidim::Zitadel::Availability.enabled?(current_organization) %>
|
|
30
|
+
<%= render "decidim/zitadel/deface_partials/header_login", item_class: "main-bar__links-mobile__login" %>
|
|
31
|
+
<% else %>
|
|
32
|
+
<%= render_original %>
|
|
33
|
+
<% end %>
|
|
34
|
+
ERB
|
|
35
|
+
)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# One selector matches the provider-name span on Decidim 0.29 and 0.30–0.32.
|
|
4
|
+
# 0.29: visible span with titleize. 0.30+: span.sr-only around the same titleize call.
|
|
5
|
+
# original: follows the running decidim-core so the drift check matches that release.
|
|
6
|
+
# Covers sessions/new, registrations/new, and loginModal (shared partial).
|
|
7
|
+
|
|
8
|
+
omniauth_button_original =
|
|
9
|
+
if Gem.loaded_specs.fetch("decidim-core").version >= Gem::Version.new("0.30.0")
|
|
10
|
+
'<span class="sr-only"><%= t("devise.shared.links.log_in_with_provider", provider: normalize_provider_name(provider).titleize) %></span>'
|
|
11
|
+
else
|
|
12
|
+
<<~ERB
|
|
13
|
+
<span>
|
|
14
|
+
<%= normalize_provider_name(provider).titleize %>
|
|
15
|
+
</span>
|
|
16
|
+
ERB
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# span: titleize (0.29 and 0.30–0.32) or t("devise.shared.omniauth_#{provider}_button").
|
|
20
|
+
# erb: the same key when it is not wrapped in that span. link_to is left to the title override.
|
|
21
|
+
omniauth_label_partial = <<~ERB
|
|
22
|
+
<%= render "decidim/zitadel/deface_partials/omniauth_button_label",
|
|
23
|
+
provider: provider,
|
|
24
|
+
organization: current_organization do %>
|
|
25
|
+
<%= render_original %>
|
|
26
|
+
<% end %>
|
|
27
|
+
ERB
|
|
28
|
+
|
|
29
|
+
Deface::Override.new(
|
|
30
|
+
virtual_path: "decidim/devise/shared/_omniauth_buttons",
|
|
31
|
+
name: "decidim_zitadel_omniauth_button_label",
|
|
32
|
+
surround: "span:contains('normalize_provider_name(provider).titleize'), span:contains('devise.shared.omniauth_')",
|
|
33
|
+
original: omniauth_button_original,
|
|
34
|
+
text: omniauth_label_partial
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
Deface::Override.new(
|
|
38
|
+
virtual_path: "decidim/devise/shared/_omniauth_buttons",
|
|
39
|
+
name: "decidim_zitadel_omniauth_button_i18n",
|
|
40
|
+
surround: "erb[loud]:contains('devise.shared.omniauth_')",
|
|
41
|
+
original: "<%= t(\"devise.shared.omniauth_\#{provider}_button\") %>",
|
|
42
|
+
text: omniauth_label_partial
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# title: lives on link_to, outside the span the label override surrounds.
|
|
46
|
+
# The stored Toggle value is the full label, so it is the title itself.
|
|
47
|
+
omniauth_title_original = <<~ERB.squish
|
|
48
|
+
<%= link_to decidim.send("user_\#{provider}_omniauth_authorize_path"),
|
|
49
|
+
class: link_classes, method: :post,
|
|
50
|
+
title: t("devise.shared.links.log_in_with_provider",
|
|
51
|
+
provider: normalize_provider_name(provider).titleize) do %>
|
|
52
|
+
ERB
|
|
53
|
+
|
|
54
|
+
Deface::Override.new(
|
|
55
|
+
virtual_path: "decidim/devise/shared/_omniauth_buttons",
|
|
56
|
+
name: "decidim_zitadel_omniauth_button_title",
|
|
57
|
+
replace: "erb[loud]:contains('title:')",
|
|
58
|
+
original: omniauth_title_original,
|
|
59
|
+
text: <<~ERB
|
|
60
|
+
<%= link_to decidim.send("user_\#{provider}_omniauth_authorize_path"),
|
|
61
|
+
class: link_classes,
|
|
62
|
+
method: :post,
|
|
63
|
+
title: (
|
|
64
|
+
if provider.to_s == Decidim::Zitadel::PROVIDER.to_s
|
|
65
|
+
zitadel_omniauth_button_label(provider, current_organization)
|
|
66
|
+
else
|
|
67
|
+
t(
|
|
68
|
+
"devise.shared.links.log_in_with_provider",
|
|
69
|
+
provider: normalize_provider_name(provider).titleize
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
) do %>
|
|
73
|
+
ERB
|
|
74
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<% if Decidim::Zitadel::Availability.locked_user?(current_user) %>
|
|
2
|
+
<% if local_assigns[:zitadel_account_field] == :name %>
|
|
3
|
+
<% profile_url = Decidim::Zitadel::Availability.config_for(current_user.organization)[:profile_url].to_s %>
|
|
4
|
+
<% if profile_url.present? %>
|
|
5
|
+
<%= link_to t("decidim.zitadel.account.update_personal_data"),
|
|
6
|
+
profile_url,
|
|
7
|
+
class: "button button__sm button__transparent-secondary" %>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% else %>
|
|
11
|
+
<%= yield %>
|
|
12
|
+
<% end %>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<% original = capture { yield } %>
|
|
2
|
+
<%# link_to also contains devise.shared when the title uses that key; the title override owns it. %>
|
|
3
|
+
<% if provider.to_s == Decidim::Zitadel::PROVIDER.to_s && original.exclude?("link_to") %>
|
|
4
|
+
<%# Inline display wins over span.sr-only and .login__omniauth-button span { display: none } (Decidim >= 0.30). %>
|
|
5
|
+
<span style="display: inline"><%= zitadel_omniauth_button_label(provider, local_assigns[:organization]) %></span>
|
|
6
|
+
<% else %>
|
|
7
|
+
<%= original %>
|
|
8
|
+
<% end %>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
de:
|
|
3
|
+
activemodel:
|
|
4
|
+
attributes:
|
|
5
|
+
organization:
|
|
6
|
+
enabled: Zitadel aktivieren
|
|
7
|
+
issuer_url: Issuer-URL
|
|
8
|
+
client_id: Client-ID
|
|
9
|
+
client_secret: Client-Secret
|
|
10
|
+
scopes: Scopes
|
|
11
|
+
profile_url: Profil-URL
|
|
12
|
+
omniauth_button_label: OmniAuth-Buttonbeschriftung
|
|
13
|
+
errors:
|
|
14
|
+
models:
|
|
15
|
+
organization:
|
|
16
|
+
attributes:
|
|
17
|
+
issuer_url:
|
|
18
|
+
discovery_failed: OpenID-Discovery-Dokument konnte nicht geladen werden
|
|
19
|
+
name:
|
|
20
|
+
zitadel_locked: kann nicht geändert werden, solange Sie mit Zitadel angemeldet sind
|
|
21
|
+
email:
|
|
22
|
+
zitadel_locked: kann nicht geändert werden, solange Sie mit Zitadel angemeldet sind
|
|
23
|
+
password:
|
|
24
|
+
zitadel_locked: kann nicht geändert werden, solange Sie mit Zitadel angemeldet sind
|
|
25
|
+
decidim_toggle:
|
|
26
|
+
system:
|
|
27
|
+
decidim_zitadel:
|
|
28
|
+
tab: Zitadel
|
|
29
|
+
enabled: Zitadel aktivieren
|
|
30
|
+
issuer_url: Issuer-URL
|
|
31
|
+
client_id: Client-ID
|
|
32
|
+
client_secret: Client-Secret
|
|
33
|
+
scopes: Scopes
|
|
34
|
+
profile_url: Profil-URL
|
|
35
|
+
omniauth_button_label: OmniAuth-Buttonbeschriftung
|
|
36
|
+
helptext:
|
|
37
|
+
enabled: Wenn aktiviert, melden sich Besucher über Zitadel OpenID Connect an und registrieren sich.
|
|
38
|
+
issuer_url: Basis-Issuer-URL (z. B. http://localhost:8080). Discovery läuft beim Speichern.
|
|
39
|
+
client_id: Client-ID der OIDC-Anwendung aus Zitadel.
|
|
40
|
+
client_secret: Client-Secret der OIDC-Anwendung. Leer lassen, um das aktuelle Secret zu behalten.
|
|
41
|
+
scopes: OpenID-Connect-Scopes, durch Leerzeichen getrennt. Standard ist openid email profile.
|
|
42
|
+
profile_url: URL, die vom Konto-Link «Persönliche Daten aktualisieren» geöffnet wird (z. B. eine benutzerdefinierte Login-UI-Profilseite). Nicht automatisch Issuer oder Issuer/profile. Leer lassen, um den Link auszublenden.
|
|
43
|
+
omniauth_button_label: Text auf dem Zitadel-Anmeldebutton. Leer lassen, um den Providernamen zu verwenden.
|
|
44
|
+
decidim:
|
|
45
|
+
zitadel:
|
|
46
|
+
account:
|
|
47
|
+
update_personal_data: Persönliche Daten aktualisieren
|
|
48
|
+
sessions:
|
|
49
|
+
auth_failed: Wir konnten Sie nicht anmelden. Bitte versuchen Sie es erneut. Wenn der Fehler bestehen bleibt, wenden Sie sich an den Support.
|
|
50
|
+
disconnected: Sie wurden abgemeldet.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
en:
|
|
3
|
+
activemodel:
|
|
4
|
+
attributes:
|
|
5
|
+
organization:
|
|
6
|
+
enabled: Enable Zitadel
|
|
7
|
+
issuer_url: Issuer URL
|
|
8
|
+
client_id: Client ID
|
|
9
|
+
client_secret: Client secret
|
|
10
|
+
scopes: Scopes
|
|
11
|
+
profile_url: Profile URL
|
|
12
|
+
omniauth_button_label: OmniAuth button label
|
|
13
|
+
errors:
|
|
14
|
+
models:
|
|
15
|
+
organization:
|
|
16
|
+
attributes:
|
|
17
|
+
issuer_url:
|
|
18
|
+
discovery_failed: could not load OpenID discovery document
|
|
19
|
+
name:
|
|
20
|
+
zitadel_locked: cannot be changed while signed in with Zitadel
|
|
21
|
+
email:
|
|
22
|
+
zitadel_locked: cannot be changed while signed in with Zitadel
|
|
23
|
+
password:
|
|
24
|
+
zitadel_locked: cannot be changed while signed in with Zitadel
|
|
25
|
+
decidim_toggle:
|
|
26
|
+
system:
|
|
27
|
+
decidim_zitadel:
|
|
28
|
+
tab: Zitadel
|
|
29
|
+
enabled: Enable Zitadel
|
|
30
|
+
issuer_url: Issuer URL
|
|
31
|
+
client_id: Client ID
|
|
32
|
+
client_secret: Client secret
|
|
33
|
+
scopes: Scopes
|
|
34
|
+
profile_url: Profile URL
|
|
35
|
+
omniauth_button_label: OmniAuth button label
|
|
36
|
+
helptext:
|
|
37
|
+
enabled: When enabled, visitors sign in and register through Zitadel OpenID Connect.
|
|
38
|
+
issuer_url: Base issuer URL (e.g. http://localhost:8080). Discovery runs on save.
|
|
39
|
+
client_id: OIDC application client id from Zitadel.
|
|
40
|
+
client_secret: OIDC application client secret. Leave blank to keep the current secret.
|
|
41
|
+
scopes: Space-separated OpenID Connect scopes. Default is openid email profile.
|
|
42
|
+
profile_url: URL opened from the account “update personal data” link (for example a custom Login UI profile page). Not the issuer or issuer/profile unless you set that explicitly. Leave blank to hide the link.
|
|
43
|
+
omniauth_button_label: Text on the Zitadel sign-in button. Leave blank to use the provider name.
|
|
44
|
+
decidim:
|
|
45
|
+
zitadel:
|
|
46
|
+
account:
|
|
47
|
+
update_personal_data: Update personal data
|
|
48
|
+
sessions:
|
|
49
|
+
auth_failed: We couldn't log you in. Please try again. If the error persists, contact support.
|
|
50
|
+
disconnected: You have been disconnected.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
fr:
|
|
3
|
+
activemodel:
|
|
4
|
+
attributes:
|
|
5
|
+
organization:
|
|
6
|
+
enabled: Activer Zitadel
|
|
7
|
+
issuer_url: URL de l'émetteur
|
|
8
|
+
client_id: Identifiant client
|
|
9
|
+
client_secret: Secret client
|
|
10
|
+
scopes: Portées
|
|
11
|
+
profile_url: URL du profil
|
|
12
|
+
omniauth_button_label: Libellé du bouton OmniAuth
|
|
13
|
+
errors:
|
|
14
|
+
models:
|
|
15
|
+
organization:
|
|
16
|
+
attributes:
|
|
17
|
+
issuer_url:
|
|
18
|
+
discovery_failed: impossible de charger le document de découverte OpenID
|
|
19
|
+
name:
|
|
20
|
+
zitadel_locked: ne peut pas être modifié tant que vous êtes connecté avec Zitadel
|
|
21
|
+
email:
|
|
22
|
+
zitadel_locked: ne peut pas être modifié tant que vous êtes connecté avec Zitadel
|
|
23
|
+
password:
|
|
24
|
+
zitadel_locked: ne peut pas être modifié tant que vous êtes connecté avec Zitadel
|
|
25
|
+
decidim_toggle:
|
|
26
|
+
system:
|
|
27
|
+
decidim_zitadel:
|
|
28
|
+
tab: Zitadel
|
|
29
|
+
enabled: Activer Zitadel
|
|
30
|
+
issuer_url: URL de l'émetteur
|
|
31
|
+
client_id: Identifiant client
|
|
32
|
+
client_secret: Secret client
|
|
33
|
+
scopes: Portées
|
|
34
|
+
profile_url: URL du profil
|
|
35
|
+
omniauth_button_label: Libellé du bouton OmniAuth
|
|
36
|
+
helptext:
|
|
37
|
+
enabled: Lorsque c'est activé, les visiteurs se connectent et s'inscrivent via Zitadel OpenID Connect.
|
|
38
|
+
issuer_url: URL de base de l'émetteur (ex. http://localhost:8080). La découverte s'exécute à l'enregistrement.
|
|
39
|
+
client_id: Identifiant client de l'application OIDC Zitadel.
|
|
40
|
+
client_secret: Secret client de l'application OIDC. Laisser vide pour conserver le secret actuel.
|
|
41
|
+
scopes: Portées OpenID Connect séparées par des espaces. Par défaut openid email profile.
|
|
42
|
+
profile_url: URL ouverte depuis le lien « mettre à jour les données personnelles » du compte (par exemple une page profil Login UI personnalisée). Ce n’est pas l’émetteur ni issuer/profile, sauf si vous le définissez ainsi. Laisser vide pour masquer le lien.
|
|
43
|
+
omniauth_button_label: Texte du bouton de connexion Zitadel. Laisser vide pour utiliser le nom du fournisseur.
|
|
44
|
+
decidim:
|
|
45
|
+
zitadel:
|
|
46
|
+
account:
|
|
47
|
+
update_personal_data: Mettre à jour les données personnelles
|
|
48
|
+
sessions:
|
|
49
|
+
auth_failed: Nous n’avons pas pu vous connecter. Veuillez réessayer. Si l’erreur persiste, contactez le support.
|
|
50
|
+
disconnected: Vous avez été déconnecté.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
it:
|
|
3
|
+
activemodel:
|
|
4
|
+
attributes:
|
|
5
|
+
organization:
|
|
6
|
+
enabled: Abilita Zitadel
|
|
7
|
+
issuer_url: URL dell'issuer
|
|
8
|
+
client_id: Client ID
|
|
9
|
+
client_secret: Client secret
|
|
10
|
+
scopes: Scope
|
|
11
|
+
profile_url: URL del profilo
|
|
12
|
+
omniauth_button_label: Etichetta del pulsante OmniAuth
|
|
13
|
+
errors:
|
|
14
|
+
models:
|
|
15
|
+
organization:
|
|
16
|
+
attributes:
|
|
17
|
+
issuer_url:
|
|
18
|
+
discovery_failed: impossibile caricare il documento di discovery OpenID
|
|
19
|
+
name:
|
|
20
|
+
zitadel_locked: non può essere modificato mentre si è autenticati con Zitadel
|
|
21
|
+
email:
|
|
22
|
+
zitadel_locked: non può essere modificato mentre si è autenticati con Zitadel
|
|
23
|
+
password:
|
|
24
|
+
zitadel_locked: non può essere modificata mentre si è autenticati con Zitadel
|
|
25
|
+
decidim_toggle:
|
|
26
|
+
system:
|
|
27
|
+
decidim_zitadel:
|
|
28
|
+
tab: Zitadel
|
|
29
|
+
enabled: Abilita Zitadel
|
|
30
|
+
issuer_url: URL dell'issuer
|
|
31
|
+
client_id: Client ID
|
|
32
|
+
client_secret: Client secret
|
|
33
|
+
scopes: Scope
|
|
34
|
+
profile_url: URL del profilo
|
|
35
|
+
omniauth_button_label: Etichetta del pulsante OmniAuth
|
|
36
|
+
helptext:
|
|
37
|
+
enabled: Se abilitato, i visitatori accedono e si registrano tramite Zitadel OpenID Connect.
|
|
38
|
+
issuer_url: URL base dell'issuer (es. http://localhost:8080). La discovery viene eseguita al salvataggio.
|
|
39
|
+
client_id: Client ID dell'applicazione OIDC da Zitadel.
|
|
40
|
+
client_secret: Client secret dell'applicazione OIDC. Lasciare vuoto per mantenere il secret attuale.
|
|
41
|
+
scopes: Scope OpenID Connect separati da spazi. Predefinito openid email profile.
|
|
42
|
+
profile_url: URL aperta dal link «aggiorna i dati personali» dell’account (ad esempio una pagina profilo Login UI personalizzata). Non è l’issuer né issuer/profile, a meno che non lo imposti tu. Lasciare vuoto per nascondere il link.
|
|
43
|
+
omniauth_button_label: Testo sul pulsante di accesso Zitadel. Lasciare vuoto per usare il nome del provider.
|
|
44
|
+
decidim:
|
|
45
|
+
zitadel:
|
|
46
|
+
account:
|
|
47
|
+
update_personal_data: Aggiorna i dati personali
|
|
48
|
+
sessions:
|
|
49
|
+
auth_failed: Non siamo riusciti ad accedere. Riprova e, se l’errore persiste, contatta il supporto.
|
|
50
|
+
disconnected: Sei stato disconnesso.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# ActiveRecord session store (OIDC nonce/state). Idempotent if host already has sessions.
|
|
4
|
+
class CreateDecidimZitadelSessions < ActiveRecord::Migration[6.1]
|
|
5
|
+
def change
|
|
6
|
+
return if table_exists?(:sessions)
|
|
7
|
+
|
|
8
|
+
create_table :sessions do |t|
|
|
9
|
+
t.string :session_id, null: false
|
|
10
|
+
t.text :data
|
|
11
|
+
t.timestamps null: false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
add_index :sessions, :session_id, unique: true
|
|
15
|
+
add_index :sessions, :updated_at
|
|
16
|
+
end
|
|
17
|
+
end
|
data/db/seeds.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Zitadel
|
|
5
|
+
module AccountFormFreeze
|
|
6
|
+
def valid?(*)
|
|
7
|
+
restore_missing_zitadel_locked_attributes
|
|
8
|
+
super
|
|
9
|
+
apply_zitadel_profile_locks
|
|
10
|
+
errors.empty?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def restore_missing_zitadel_locked_attributes
|
|
16
|
+
user = context&.current_user
|
|
17
|
+
return unless Availability.locked_user?(user)
|
|
18
|
+
|
|
19
|
+
self.name = user.name if name.blank?
|
|
20
|
+
self.email = user.email if email.blank?
|
|
21
|
+
self.locale = user.locale if locale.blank?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def apply_zitadel_profile_locks
|
|
25
|
+
user = context&.current_user
|
|
26
|
+
return unless Availability.locked_user?(user)
|
|
27
|
+
|
|
28
|
+
errors.add(:name, :zitadel_locked) if name != user.name
|
|
29
|
+
errors.add(:email, :zitadel_locked) if email != user.email
|
|
30
|
+
errors.add(:locale, :zitadel_locked) if locale != user.locale
|
|
31
|
+
errors.add(:password, :zitadel_locked) if password.present?
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Zitadel
|
|
5
|
+
class AuthAttributes
|
|
6
|
+
def initialize(auth)
|
|
7
|
+
@auth = auth.deep_symbolize_keys
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def sub
|
|
11
|
+
uid.presence || raw[:sub].presence
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def email
|
|
15
|
+
value = info[:email].presence || raw[:email].presence
|
|
16
|
+
value.to_s.strip.downcase.presence
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def name
|
|
20
|
+
built = "#{given_name} #{family_name}".strip
|
|
21
|
+
built.presence || info[:name].presence || email.to_s.split("@").first
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def given_name
|
|
25
|
+
info[:given_name].presence || raw[:given_name].to_s
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def family_name
|
|
29
|
+
info[:family_name].presence || raw[:family_name].to_s
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def uid
|
|
33
|
+
@auth[:uid].to_s
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def locale
|
|
37
|
+
info[:locale] || raw[:locale]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def raw
|
|
41
|
+
extra = @auth[:extra] || {}
|
|
42
|
+
(extra[:raw_info] || extra[:rawInfo] || {}).to_h.deep_symbolize_keys
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def info
|
|
46
|
+
(@auth[:info] || {}).to_h.deep_symbolize_keys
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Zitadel
|
|
5
|
+
module Availability
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def enabled?(organization)
|
|
9
|
+
return false if organization.blank?
|
|
10
|
+
|
|
11
|
+
ActiveModel::Type::Boolean.new.cast(config_for(organization)[:enabled]) == true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def locked_user?(user)
|
|
15
|
+
return false if user.blank?
|
|
16
|
+
return false unless enabled?(user.organization)
|
|
17
|
+
|
|
18
|
+
user.identities.exists?(provider: PROVIDER)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Raw JSON (includes discovery endpoints). Toggle.config_for would drop
|
|
22
|
+
# keys that are not form attributes.
|
|
23
|
+
def config_for(organization)
|
|
24
|
+
return {} if organization.blank?
|
|
25
|
+
|
|
26
|
+
Decidim::Toggle::OrganizationModuleConfig.find_by(
|
|
27
|
+
decidim_organization_id: organization.id,
|
|
28
|
+
module_name: MODULE_NAME
|
|
29
|
+
)&.config&.with_indifferent_access || {}
|
|
30
|
+
rescue StandardError
|
|
31
|
+
{}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Zitadel
|
|
5
|
+
class CompleteSession < Decidim::Command
|
|
6
|
+
def initialize(auth, organization)
|
|
7
|
+
@attrs = AuthAttributes.new(auth)
|
|
8
|
+
@organization = organization
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
return broadcast(:invalid) if @attrs.sub.blank?
|
|
13
|
+
|
|
14
|
+
user = resolve_user
|
|
15
|
+
return broadcast(:invalid) if user.blank?
|
|
16
|
+
|
|
17
|
+
ProfileUpdater.new(user, @attrs).call
|
|
18
|
+
broadcast(:ok, user)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def resolve_user
|
|
24
|
+
IdentityResolver.new(@attrs, @organization).user
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
module Decidim
|
|
8
|
+
module Zitadel
|
|
9
|
+
class Discovery
|
|
10
|
+
TIMEOUT = 5
|
|
11
|
+
|
|
12
|
+
def initialize(issuer_url)
|
|
13
|
+
@issuer_url = issuer_url.to_s.chomp("/")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call
|
|
17
|
+
payload = fetch_json
|
|
18
|
+
return if payload.blank?
|
|
19
|
+
|
|
20
|
+
slice(payload)
|
|
21
|
+
rescue StandardError
|
|
22
|
+
nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def fetch_json
|
|
28
|
+
response = http.request(Net::HTTP::Get.new(uri))
|
|
29
|
+
return unless response.is_a?(Net::HTTPSuccess)
|
|
30
|
+
|
|
31
|
+
JSON.parse(response.body)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def uri
|
|
35
|
+
@uri ||= URI.parse("#{@issuer_url}/.well-known/openid-configuration")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def http
|
|
39
|
+
client = Net::HTTP.new(uri.host, uri.port)
|
|
40
|
+
client.use_ssl = uri.scheme == "https"
|
|
41
|
+
client.open_timeout = TIMEOUT
|
|
42
|
+
client.read_timeout = TIMEOUT
|
|
43
|
+
client
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def slice(payload)
|
|
47
|
+
{
|
|
48
|
+
"authorization_endpoint" => payload["authorization_endpoint"],
|
|
49
|
+
"token_endpoint" => payload["token_endpoint"],
|
|
50
|
+
"userinfo_endpoint" => payload["userinfo_endpoint"],
|
|
51
|
+
"jwks_uri" => payload["jwks_uri"],
|
|
52
|
+
"end_session_endpoint" => payload["end_session_endpoint"],
|
|
53
|
+
"discovered_issuer" => payload["issuer"]
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Zitadel
|
|
5
|
+
class EmailLinker
|
|
6
|
+
def initialize(attrs, organization)
|
|
7
|
+
@attrs = attrs
|
|
8
|
+
@organization = organization
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
return if @attrs.email.blank?
|
|
13
|
+
return unless candidate&.confirmed?
|
|
14
|
+
return if sub_taken?
|
|
15
|
+
|
|
16
|
+
attach_identity(candidate)
|
|
17
|
+
candidate
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def candidate
|
|
23
|
+
@organization.users.find_by(email: @attrs.email)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def sub_taken?
|
|
27
|
+
Decidim::Identity.exists?(
|
|
28
|
+
organization: @organization,
|
|
29
|
+
provider: PROVIDER,
|
|
30
|
+
uid: @attrs.sub
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def attach_identity(user)
|
|
35
|
+
user.identities.create!(
|
|
36
|
+
provider: PROVIDER,
|
|
37
|
+
uid: @attrs.sub,
|
|
38
|
+
organization: @organization
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|