Selaa lähdekoodia

mautrix-twitter: expose bridge HTTP API (for mautrix-manager and similar)

Route the whole mautrix-twitter HTTP port via Traefik under
`<matrix-fqn>/bridges/twitter` and populate the existing
appservice.public_address, reusing the matrix_bridges_exposure_*
mechanism. The provisioning shared secret is already auto-generated in
group_vars, so the provisioning API is enabled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pull/4317/merge
Slavi Pantaleev 1 päivä sitten
vanhempi
commit
44c8736c08
3 muutettua tiedostoa jossa 58 lisäystä ja 2 poistoa
  1. +5
    -0
      group_vars/matrix_servers
  2. +20
    -2
      roles/custom/matrix-bridge-mautrix-twitter/defaults/main.yml
  3. +33
    -0
      roles/custom/matrix-bridge-mautrix-twitter/templates/labels.j2

+ 5
- 0
group_vars/matrix_servers Näytä tiedosto

@@ -2150,6 +2150,11 @@ matrix_mautrix_twitter_metrics_proxying_enabled: "{{ matrix_mautrix_twitter_metr
matrix_mautrix_twitter_metrics_proxying_hostname: "{{ matrix_metrics_exposure_hostname }}" matrix_mautrix_twitter_metrics_proxying_hostname: "{{ matrix_metrics_exposure_hostname }}"
matrix_mautrix_twitter_metrics_proxying_path_prefix: "{{ matrix_metrics_exposure_path_prefix }}/mautrix-twitter" matrix_mautrix_twitter_metrics_proxying_path_prefix: "{{ matrix_metrics_exposure_path_prefix }}/mautrix-twitter"


matrix_mautrix_twitter_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}"
matrix_mautrix_twitter_exposure_enabled: "{{ matrix_bridges_exposure_enabled }}"
matrix_mautrix_twitter_exposure_hostname: "{{ matrix_bridges_exposure_hostname }}"
matrix_mautrix_twitter_exposure_path_prefix: "{{ matrix_bridges_exposure_path_prefix }}/twitter"

matrix_mautrix_twitter_database_hostname: "{{ postgres_connection_hostname if postgres_enabled else '' }}" matrix_mautrix_twitter_database_hostname: "{{ postgres_connection_hostname if postgres_enabled else '' }}"
matrix_mautrix_twitter_database_password: "{{ (matrix_homeserver_generic_secret_key + ':mau.twt.db') | hash('sha512') | to_uuid if postgres_enabled else '' }}" matrix_mautrix_twitter_database_password: "{{ (matrix_homeserver_generic_secret_key + ':mau.twt.db') | hash('sha512') | to_uuid if postgres_enabled else '' }}"




+ 20
- 2
roles/custom/matrix-bridge-mautrix-twitter/defaults/main.yml Näytä tiedosto

@@ -44,8 +44,12 @@ matrix_mautrix_twitter_appservice_address: 'http://matrix-mautrix-twitter:29327'
matrix_mautrix_twitter_msc4190_enabled: "{{ matrix_bridges_msc4190_enabled }}" matrix_mautrix_twitter_msc4190_enabled: "{{ matrix_bridges_msc4190_enabled }}"
matrix_mautrix_twitter_self_sign_enabled: "{{ matrix_bridges_self_sign_enabled }}" matrix_mautrix_twitter_self_sign_enabled: "{{ matrix_bridges_self_sign_enabled }}"


# A public address that external services can use to reach this appservice.
matrix_mautrix_twitter_appservice_public_address: ''
# Scheme of the bridge's public address (see `matrix_mautrix_twitter_appservice_public_address`).
matrix_mautrix_twitter_scheme: https

# A public address that external services can use to reach this appservice (when exposed).
# Used for the provisioning API's external-server (OpenID) flow and for public media links.
matrix_mautrix_twitter_appservice_public_address: "{{ (matrix_mautrix_twitter_scheme + '://' + matrix_mautrix_twitter_exposure_hostname + matrix_mautrix_twitter_exposure_path_prefix) if matrix_mautrix_twitter_exposure_enabled else '' }}"


# Displayname template for Twitter users. # Displayname template for Twitter users.
# {{ .DisplayName }} is replaced with the display name of the Twitter user. # {{ .DisplayName }} is replaced with the display name of the Twitter user.
@@ -86,6 +90,15 @@ matrix_mautrix_twitter_container_labels_metrics_middleware_basic_auth_enabled: f
# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users # See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users
matrix_mautrix_twitter_container_labels_metrics_middleware_basic_auth_users: '' matrix_mautrix_twitter_container_labels_metrics_middleware_basic_auth_users: ''


# Controls whether labels will be added that expose mautrix-twitter's HTTP API
# (used by tools like mautrix-manager for bridge login) at `https://<hostname><path_prefix>`.
matrix_mautrix_twitter_container_labels_exposure_enabled: "{{ matrix_mautrix_twitter_exposure_enabled }}"
matrix_mautrix_twitter_container_labels_exposure_traefik_rule: "Host(`{{ matrix_mautrix_twitter_exposure_hostname }}`) && PathPrefix(`{{ matrix_mautrix_twitter_exposure_path_prefix }}`)"
matrix_mautrix_twitter_container_labels_exposure_traefik_priority: 0
matrix_mautrix_twitter_container_labels_exposure_traefik_entrypoints: "{{ matrix_mautrix_twitter_container_labels_traefik_entrypoints }}"
matrix_mautrix_twitter_container_labels_exposure_traefik_tls: "{{ matrix_mautrix_twitter_container_labels_exposure_traefik_entrypoints != 'web' }}"
matrix_mautrix_twitter_container_labels_exposure_traefik_tls_certResolver: "{{ matrix_mautrix_twitter_container_labels_traefik_tls_certResolver }}" # noqa var-naming

# matrix_mautrix_twitter_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file. # matrix_mautrix_twitter_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.
# See `../templates/labels.j2` for details. # See `../templates/labels.j2` for details.
# #
@@ -166,6 +179,11 @@ matrix_mautrix_twitter_metrics_proxying_enabled: false
matrix_mautrix_twitter_metrics_proxying_hostname: '' matrix_mautrix_twitter_metrics_proxying_hostname: ''
matrix_mautrix_twitter_metrics_proxying_path_prefix: '' matrix_mautrix_twitter_metrics_proxying_path_prefix: ''


# Controls whether mautrix-twitter's HTTP API is exposed publicly (used by tools like mautrix-manager for bridge login).
matrix_mautrix_twitter_exposure_enabled: false
matrix_mautrix_twitter_exposure_hostname: ''
matrix_mautrix_twitter_exposure_path_prefix: ''

# Default configuration template which covers the generic use case. # Default configuration template which covers the generic use case.
# You can customize it by controlling the various variables inside it. # You can customize it by controlling the various variables inside it.
# #


+ 33
- 0
roles/custom/matrix-bridge-mautrix-twitter/templates/labels.j2 Näytä tiedosto

@@ -46,6 +46,39 @@ traefik.http.routers.matrix-mautrix-twitter-metrics.tls.certResolver={{ matrix_m
############################################################ ############################################################
{% endif %} {% endif %}


{% if matrix_mautrix_twitter_container_labels_exposure_enabled %}
############################################################
# #
# Bridge API exposure #
# #
############################################################

traefik.http.services.matrix-mautrix-twitter-exposure.loadbalancer.server.port=29327

traefik.http.middlewares.matrix-mautrix-twitter-exposure-strip-prefix.stripprefix.prefixes={{ matrix_mautrix_twitter_exposure_path_prefix }}
traefik.http.routers.matrix-mautrix-twitter-exposure.middlewares=matrix-mautrix-twitter-exposure-strip-prefix

traefik.http.routers.matrix-mautrix-twitter-exposure.rule={{ matrix_mautrix_twitter_container_labels_exposure_traefik_rule }}

{% if matrix_mautrix_twitter_container_labels_exposure_traefik_priority | int > 0 %}
traefik.http.routers.matrix-mautrix-twitter-exposure.priority={{ matrix_mautrix_twitter_container_labels_exposure_traefik_priority }}
{% endif %}

traefik.http.routers.matrix-mautrix-twitter-exposure.service=matrix-mautrix-twitter-exposure
traefik.http.routers.matrix-mautrix-twitter-exposure.entrypoints={{ matrix_mautrix_twitter_container_labels_exposure_traefik_entrypoints }}

traefik.http.routers.matrix-mautrix-twitter-exposure.tls={{ matrix_mautrix_twitter_container_labels_exposure_traefik_tls | to_json }}
{% if matrix_mautrix_twitter_container_labels_exposure_traefik_tls %}
traefik.http.routers.matrix-mautrix-twitter-exposure.tls.certResolver={{ matrix_mautrix_twitter_container_labels_exposure_traefik_tls_certResolver }}
{% endif %}

############################################################
# #
# /Bridge API exposure #
# #
############################################################
{% endif %}



{% endif %} {% endif %}




Ladataan…
Peruuta
Tallenna