|
128 | 128 | become: true
|
129 | 129 | become_user: "{{ matrix_user_name }}"
|
130 | 130 |
|
| 131 | +- name: Check if an authenticated media signing key exists |
| 132 | + ansible.builtin.stat: |
| 133 | + path: "{{ matrix_appservice_irc_data_path }}/auth-media.jwk" |
| 134 | + register: matrix_appservice_irc_stat_auth_media_key |
| 135 | + |
| 136 | +- when: not matrix_appservice_irc_stat_auth_media_key.stat.exists |
| 137 | + block: |
| 138 | + - name: Generate IRC appservice signing key for authenticated media |
| 139 | + community.docker.docker_container: |
| 140 | + name: "create-auth-media-jwk-key" |
| 141 | + image: "{{ matrix_appservice_irc_docker_image }}" |
| 142 | + cleanup: yes |
| 143 | + network_mode: none |
| 144 | + entrypoint: "/usr/local/bin/node" |
| 145 | + command: > |
| 146 | + -e "const webcrypto = require('node:crypto'); |
| 147 | + async function main() { |
| 148 | + const key = await webcrypto.subtle.generateKey({ |
| 149 | + name: 'HMAC', |
| 150 | + hash: 'SHA-512', |
| 151 | + }, true, ['sign', 'verify']); |
| 152 | + console.log(JSON.stringify(await webcrypto.subtle.exportKey('jwk', key), undefined, 4)); |
| 153 | + } |
| 154 | + main().then(() => process.exit(0)).catch(err => { throw err });" |
| 155 | + detach: false |
| 156 | + register: matrix_appservice_irc_jwk_result |
| 157 | + |
| 158 | + - name: Write auth media signing key to file |
| 159 | + ansible.builtin.copy: |
| 160 | + content: "{{ matrix_appservice_irc_jwk_result.container.Output }}" |
| 161 | + dest: "{{ matrix_appservice_irc_data_path }}/auth-media.jwk" |
| 162 | + mode: "0644" |
| 163 | + owner: "{{ matrix_user_username }}" |
| 164 | + group: "{{ matrix_user_groupname }}" |
| 165 | + |
131 | 166 | # In the past, we used to generate the passkey.pem file with root, so permissions may not be okay.
|
132 | 167 | # Fix it.
|
133 | 168 | - name: (Migration) Ensure Appservice IRC passkey permissions are okay
|
|
0 commit comments