Matrix Authentication Support for Jitsi
This extends the collection with support for seamless authentication at the Jitsi server using Matrix OpenID. 1. New role for installing the [Matrix User Verification Service](https://github.com/matrix-org/matrix-user-verification-service) 2. Changes to Jitsi role: Installing Jitsi Prosody Mods and configuring Jitsi Auth 3. Changes to Jitsi and nginx-proxy roles: Serving .well-known/element/jitsi from jitsi.DOMAIN 4. We updated the Jitsi documentation on authentication and added documentation for the user verification service.
This commit is contained in:
@ -67,3 +67,9 @@
|
||||
- setup-all
|
||||
- setup-jitsi
|
||||
- setup-additional-jitsi-jvb
|
||||
|
||||
- block:
|
||||
- when: matrix_jitsi_enable_auth | bool and matrix_jitsi_auth_type == 'matrix'
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check_matrix_auth.yml"
|
||||
tags:
|
||||
- self-check
|
||||
|
62
roles/custom/matrix-jitsi/tasks/self_check_matrix_auth.yml
Normal file
62
roles/custom/matrix-jitsi/tasks/self_check_matrix_auth.yml
Normal file
@ -0,0 +1,62 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_jitsi_prosody_self_check_uvs_health_url: "{{ matrix_jitsi_prosody_auth_matrix_uvs_location }}/health"
|
||||
matrix_jitsi_element_jitsi_well_known_url: "{{ matrix_jitsi_web_public_url }}/.well-known/element/jitsi"
|
||||
|
||||
- name: Check if jitsi serves the .well-known/element/jitsi
|
||||
ansible.builtin.uri:
|
||||
url: "{{ matrix_jitsi_element_jitsi_well_known_url }}"
|
||||
follow_redirects: none
|
||||
return_content: true
|
||||
validate_certs: "{{ matrix_jitsi_self_check_validate_certificates }}"
|
||||
headers:
|
||||
Origin: example.com
|
||||
check_mode: false
|
||||
register: result_well_known_jitsi_element_jitsi
|
||||
ignore_errors: true
|
||||
|
||||
- name: Fail if .well-known not working
|
||||
ansible.builtin.fail:
|
||||
msg: |
|
||||
Failed checking that the Jitsi well-known file for Element auth is configured at `{{ matrix_jitsi_element_jitsi_well_known_url }}`
|
||||
Full error: {{ result_well_known_jitsi_element_jitsi }}
|
||||
when: "result_well_known_jitsi_element_jitsi.failed"
|
||||
|
||||
- name: Parse JSON for well-known payload at the matrix hostname
|
||||
ansible.builtin.set_fact:
|
||||
well_known_matrix_payload: "{{ result_well_known_jitsi_element_jitsi.content | from_json }}"
|
||||
|
||||
- name: Fail if .well-known not CORS-aware
|
||||
ansible.builtin.fail:
|
||||
msg: "The well-known file on `{{ matrix_jitsi_element_jitsi_well_known_url }}` is not CORS-aware. The file needs to be served with an Access-Control-Allow-Origin header set."
|
||||
when: "'access_control_allow_origin' not in result_well_known_jitsi_element_jitsi"
|
||||
|
||||
- name: Report working .well-known
|
||||
ansible.builtin.debug:
|
||||
msg: "well-known is configured correctly at `{{ matrix_jitsi_element_jitsi_well_known_url }}`"
|
||||
|
||||
- name: Check if we can reach the user verification service and if it's healthy
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- "docker"
|
||||
- "exec"
|
||||
- "matrix-jitsi-prosody"
|
||||
- "wget"
|
||||
- "-O"
|
||||
- "-"
|
||||
- "--quiet"
|
||||
- "{{ matrix_jitsi_prosody_self_check_uvs_health_url | quote }}"
|
||||
register: matrix_jitsi_prosody_self_check_uvs_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Fail if user verification service is not (reachable and healthy)
|
||||
ansible.builtin.fail:
|
||||
msg: |
|
||||
Failed checking user verification service is up (checked endpoint: `{{ matrix_jitsi_prosody_self_check_uvs_health_url }}`).
|
||||
Full error: {{ matrix_jitsi_prosody_self_check_uvs_result }}
|
||||
when: "matrix_jitsi_prosody_self_check_uvs_result.failed"
|
||||
|
||||
- name: Report healthy user verification service
|
||||
ansible.builtin.debug:
|
||||
msg: "User verification service is working (checked endpoint: `{{ matrix_jitsi_prosody_self_check_uvs_health_url }}`)"
|
@ -11,6 +11,7 @@
|
||||
- {path: "{{ matrix_jitsi_prosody_base_path }}", when: true}
|
||||
- {path: "{{ matrix_jitsi_prosody_config_path }}", when: true}
|
||||
- {path: "{{ matrix_jitsi_prosody_plugins_path }}", when: true}
|
||||
- {path: "{{ matrix_jitsi_prosody_ext_path }}", when: true}
|
||||
when: item.when | bool
|
||||
|
||||
- name: Ensure jitsi-prosody Docker image is pulled
|
||||
@ -32,6 +33,43 @@
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
mode: 0640
|
||||
|
||||
# Configure matrix authentication.
|
||||
- name: Install user verification plugin
|
||||
ansible.builtin.include_tasks:
|
||||
file: "{{ role_path }}/tasks/util/setup_jitsi_auth_uvs_install.yml"
|
||||
when: matrix_jitsi_enable_auth | bool and matrix_jitsi_auth_type == "matrix"
|
||||
|
||||
- name: Manage Jitsi .well-known
|
||||
when: matrix_jitsi_require_well_known | bool
|
||||
block:
|
||||
- name: Ensure .well-known directories exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0775
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_static_files_base_path }}/.well-known/element", when: "{{ matrix_jitsi_enable_auth | bool and matrix_jitsi_auth_type == 'matrix' }}"}
|
||||
when: item.when | bool
|
||||
|
||||
# Create .well-known/element/jitsi in the static file directory for nginx-proxy.
|
||||
- name: Ensure Jitsi /.well-known/element/jitsi configured
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_jitsi_wellknown_element_jitsi_json }}"
|
||||
dest: "{{ matrix_static_files_base_path }}/.well-known/element/jitsi"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
when: matrix_jitsi_enable_auth | bool and matrix_jitsi_auth_type == "matrix"
|
||||
# END Block
|
||||
|
||||
# Remove matrix authentication if disabled
|
||||
- name: Ensure user verification plugin is not present if matrix auth is disabled
|
||||
ansible.builtin.include_tasks:
|
||||
file: "{{ role_path }}/tasks/util/setup_jitsi_auth_uvs_uninstall.yml"
|
||||
when: (not matrix_jitsi_enable_auth | bool) or (matrix_jitsi_auth_type != "matrix")
|
||||
|
||||
- name: Ensure matrix-jitsi-prosody.service file is installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/prosody/matrix-jitsi-prosody.service.j2"
|
||||
@ -39,7 +77,9 @@
|
||||
mode: 0644
|
||||
register: matrix_jitsi_prosody_systemd_service_result
|
||||
|
||||
- name: Ensure authentication is properly configured
|
||||
# Tasks that require a running prosody container are called in this file.
|
||||
- name: Run prosody related tasks, that require a running container.
|
||||
ansible.builtin.include_tasks:
|
||||
file: "{{ role_path }}/tasks/util/setup_jitsi_auth.yml"
|
||||
when: matrix_jitsi_enable_auth | bool
|
||||
file: "{{ role_path }}/tasks/util/setup_jitsi_prosody_post_setup_hooks.yml"
|
||||
when:
|
||||
- matrix_jitsi_enable_auth | bool and matrix_jitsi_auth_type == "internal"
|
||||
|
@ -0,0 +1,17 @@
|
||||
---
|
||||
#
|
||||
# Tasks related to configuring Jitsi internal authentication on a running prosody instance.
|
||||
#
|
||||
|
||||
- name: Ensure Jitsi internal authentication users are configured
|
||||
ansible.builtin.shell: "{{ devture_systemd_docker_base_host_command_docker }} exec matrix-jitsi-prosody prosodyctl --config /config/prosody.cfg.lua register {{ item.username | quote }} meet.jitsi {{ item.password | quote }}"
|
||||
with_items: "{{ matrix_jitsi_prosody_auth_internal_accounts }}"
|
||||
when:
|
||||
- matrix_jitsi_prosody_auth_internal_accounts|length > 0
|
||||
register: matrix_jitsi_user_configuration_result
|
||||
changed_when: matrix_jitsi_user_configuration_result.rc == 0
|
||||
no_log: true
|
||||
|
||||
#
|
||||
# Tasks related to clean up after configuring internal authentication.
|
||||
#
|
@ -1,42 +0,0 @@
|
||||
---
|
||||
#
|
||||
# Start Necessary Services
|
||||
#
|
||||
|
||||
- name: Ensure matrix-jitsi-prosody container is running
|
||||
ansible.builtin.systemd:
|
||||
state: started
|
||||
name: matrix-jitsi-prosody
|
||||
register: matrix_jitsi_prosody_start_result
|
||||
|
||||
|
||||
#
|
||||
# Tasks related to configuring Jitsi internal authentication
|
||||
#
|
||||
|
||||
- name: Ensure Jitsi internal authentication users are configured
|
||||
ansible.builtin.shell: "{{ devture_systemd_docker_base_host_command_docker }} exec matrix-jitsi-prosody prosodyctl --config /config/prosody.cfg.lua register {{ item.username | quote }} meet.jitsi {{ item.password | quote }}"
|
||||
with_items: "{{ matrix_jitsi_prosody_auth_internal_accounts }}"
|
||||
when:
|
||||
- matrix_jitsi_auth_type == "internal"
|
||||
- matrix_jitsi_prosody_auth_internal_accounts|length > 0
|
||||
register: matrix_jitsi_user_configuration_result
|
||||
changed_when: matrix_jitsi_user_configuration_result.rc == 0
|
||||
no_log: true
|
||||
|
||||
#
|
||||
# Tasks related to configuring other Jitsi authentication mechanisms
|
||||
#
|
||||
|
||||
#
|
||||
# Tasks related to cleaning after Jitsi authentication configuration
|
||||
#
|
||||
|
||||
#
|
||||
# Stop Necessary Services
|
||||
#
|
||||
- name: Ensure matrix-jitsi-prosody container is stopped if necessary
|
||||
ansible.builtin.systemd:
|
||||
state: stopped
|
||||
name: matrix-jitsi-prosody
|
||||
when: matrix_jitsi_prosody_start_result.changed | bool
|
@ -0,0 +1,13 @@
|
||||
- name: Checkout Prosody Auth Matrix User Verification Plugin Repo
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_jitsi_prosody_auth_matrix_user_verification_repo_location }}"
|
||||
dest: "{{ matrix_jitsi_prosody_auth_matrix_user_verification_repo_target }}"
|
||||
version: "{{ matrix_jitsi_prosody_auth_matrix_user_verification_repo_version }}"
|
||||
|
||||
- name: Install Prosody Auth Matrix User Verification Plugin
|
||||
ansible.builtin.copy:
|
||||
remote_src: yes
|
||||
src: "{{ matrix_jitsi_prosody_auth_matrix_user_verification_repo_target }}/{{ item.path }}"
|
||||
dest: "{{ matrix_jitsi_prosody_plugins_path }}/{{ item.path }}"
|
||||
with_items: "{{ matrix_jitsi_prosody_auth_matrix_files }}"
|
||||
when: item.when | bool
|
@ -0,0 +1,26 @@
|
||||
- name: Remove all files regarding prosody mod auth_matrix_user_verification and .well-known/element/jitsi
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_flattened:
|
||||
- "{{ matrix_static_files_base_path }}/.well-known/element/jitsi"
|
||||
- "{{ matrix_jitsi_prosody_auth_matrix_user_verification_repo_target }}"
|
||||
- "{{ matrix_jitsi_prosody_auth_matrix_files | map(attribute='path') | map('regex_replace', '^', matrix_jitsi_prosody_plugins_path+'/') | list }}"
|
||||
register: matrix_jitsi_prosody_auth_matrix_user_verification_uninstalled
|
||||
|
||||
- name: Remove .well-known/element directory if empty
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- rmdir
|
||||
- "{{ matrix_static_files_base_path }}/.well-known/element"
|
||||
removes: "{{matrix_static_files_base_path}}/.well-known/element"
|
||||
ignore_errors: yes
|
||||
|
||||
- when: matrix_jitsi_prosody_auth_matrix_user_verification_uninstalled.changed
|
||||
block:
|
||||
- name: Populate service facts
|
||||
ansible.builtin.service_facts:
|
||||
|
||||
- name: Ensure prosody is restarted later on if currently running
|
||||
set_fact:
|
||||
matrix_jitsi_prosody_require_restart: "{{ true if ansible_facts.services['matrix-jitsi-prosody.service']['state'] == 'running' else false }}"
|
@ -0,0 +1,49 @@
|
||||
---
|
||||
#####
|
||||
#
|
||||
# This tasks file starts and stops (if state before was stopped) a prosody container during setup to run commands,
|
||||
# that require a running prosody container.
|
||||
# The task is called in ../setup_jitsi_prosody_install.yml.
|
||||
#
|
||||
# Important: The task is called conditionally, as to only start if really needed.
|
||||
# So if you add or change anything - remember to also change the 'when' in: ../setup_jitsi_prosody_install.yml
|
||||
#
|
||||
#####
|
||||
|
||||
#
|
||||
# Start Necessary Services
|
||||
#
|
||||
|
||||
- name: Ensure matrix-jitsi-prosody container is running
|
||||
ansible.builtin.systemd:
|
||||
state: "{{ 'restarted' if matrix_jitsi_prosody_require_restart | d(false) | bool else 'started' }}"
|
||||
name: matrix-jitsi-prosody
|
||||
register: matrix_jitsi_prosody_start_result
|
||||
|
||||
# If the flag was set, we can safely disable now.
|
||||
- name: Disable require restart flag
|
||||
set_fact:
|
||||
matrix_jitsi_prosody_require_restart: false
|
||||
|
||||
#
|
||||
# Tasks related to configuring Jitsi internal authentication
|
||||
#
|
||||
|
||||
- name: Ensure internal authentication is properly configured
|
||||
ansible.builtin.include_tasks:
|
||||
file: "{{ role_path }}/tasks/util/prosody_post_setup_hooks/setup_jitsi_auth_internal.yml"
|
||||
when: matrix_jitsi_enable_auth | bool and matrix_jitsi_auth_type == "internal"
|
||||
|
||||
#
|
||||
# Tasks related to ...
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Stop Necessary Services
|
||||
#
|
||||
- name: Ensure matrix-jitsi-prosody container is stopped if necessary
|
||||
ansible.builtin.systemd:
|
||||
state: stopped
|
||||
name: matrix-jitsi-prosody
|
||||
when: matrix_jitsi_prosody_start_result.changed | bool
|
@ -25,16 +25,25 @@
|
||||
- "matrix_jitsi_jvb_auth_password"
|
||||
|
||||
|
||||
- name: Fail if a Jitsi internal authentication account is not defined
|
||||
- name: Fail if authentication is enabled, but not properly configured.
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You have enabled authentication, but the configured auth type is missing required configuration.
|
||||
|
||||
Auth type 'internal':
|
||||
At least one Jitsi user needs to be defined in `matrix_jitsi_prosody_auth_internal_accounts` when using internal authentication.
|
||||
If you're setting up Jitsi for the first time, you may have missed a step.
|
||||
Refer to our setup instructions (docs/configuring-playbook-jitsi.md).
|
||||
|
||||
Auth type 'matrix':
|
||||
If you want to enable matrix_user_verification in jitsi,
|
||||
please provide an auth token for the user verification service (uvs) using `matrix_jitsi_prosody_auth_matrix_uvs_auth_token`.
|
||||
If the user-verfication-service is also managed by this playbook the token is derived from `matrix_homeserver_generic_secret_key` in the group vars.
|
||||
when:
|
||||
- matrix_jitsi_enable_auth | bool
|
||||
- matrix_jitsi_auth_type == 'internal'
|
||||
- matrix_jitsi_prosody_auth_internal_accounts|length == 0
|
||||
- ((matrix_jitsi_auth_type == 'internal' and matrix_jitsi_prosody_auth_internal_accounts|length == 0)
|
||||
or (matrix_jitsi_auth_type == 'matrix' and matrix_jitsi_prosody_auth_matrix_uvs_auth_token|length == 0))
|
||||
|
||||
|
||||
|
||||
- name: (Deprecation) Catch and report renamed settings
|
||||
|
Reference in New Issue
Block a user