Skip to content

Commit f1d0608

Browse files
committed
Gate c10y recaptcha config on it being configured.
1 parent 50408d6 commit f1d0608

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

roles/custom/matrix-continuwuity/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ matrix_continuwuity_config_turn_password: ''
191191
matrix_continuwuity_self_check_validate_certificates: true
192192

193193
# If set, registration will require Google ReCAPTCHA verification.
194+
matrix_continuwuity_recaptcha_enabled: "{{ matrix_continuwuity_config_recaptcha_site_key != '' and matrix_continuwuity_config_recaptcha_private_site_key != '' }}"
194195
matrix_continuwuity_config_recaptcha_site_key: ''
195196
matrix_continuwuity_config_recaptcha_private_site_key: ''
196197

roles/custom/matrix-continuwuity/tasks/validate_config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@
3636
- {'old': 'matrix_continuwuity_docker_image_registry_prefix_upstream', 'new': 'matrix_continuwuity_container_image_registry_prefix_upstream'}
3737
- {'old': 'matrix_continuwuity_docker_image_registry_prefix_upstream_default', 'new': 'matrix_continuwuity_container_image_registry_prefix_upstream_default'}
3838
- {'old': 'matrix_continuwuity_container_image_force_pull', 'new': '<removed> (the new community.docker.docker_image_pull module handles this natively)'}
39+
40+
- name: Fail if required Continuwuity variables are undefined
41+
ansible.builtin.fail:
42+
msg: "The `{{ item.name }}` variable must be defined and have a non-null value."
43+
with_items:
44+
- {'name': 'matrix_continuwuity_config_recaptcha_site_key', when: "{{ matrix_continuwuity_config_recaptcha_private_site_key | string | length > 0 }}"}
45+
- {'name': 'matrix_continuwuity_config_recaptcha_private_site_key', when: "{{ matrix_continuwuity_config_recaptcha_site_key | string | length > 0 }}"}
46+
when: "item.when | bool and (lookup('vars', item.name, default='') == '' or lookup('vars', item.name, default='') is none)"

roles/custom/matrix-continuwuity/templates/continuwuity.toml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ registration_token = {{ matrix_continuwuity_config_registration_token | to_json
490490
#
491491
#registration_token_file =
492492

493+
{% if matrix_continuwuity_recaptcha_enabled %}
493494
# The public site key for reCaptcha. If this is provided, reCaptcha
494495
# becomes required during registration. If both captcha *and*
495496
# registration token are enabled, both will be required during
@@ -509,6 +510,7 @@ recaptcha_site_key = {{ matrix_continuwuity_config_recaptcha_site_key | to_json
509510
# even if `recaptcha_site_key` is set.
510511
#
511512
recaptcha_private_site_key = {{ matrix_continuwuity_config_recaptcha_private_site_key | to_json }}
513+
{% endif %}
512514

513515
# Controls whether encrypted rooms and events are allowed.
514516
#

0 commit comments

Comments
 (0)