daef7ea190
Helper functions (matrix-mas capability group): - mas_client_register_bash_infra: register/sync OAuth clients via mas-cli - mas_syn2mas_migration_bash_infra: dry-run + apply user migration to MAS - synapse_msc3861_enable_go_infra: edit homeserver.yaml MSC3861 block (with diff) - wellknown_oidc_patch_go_infra: patch well-known JSON with msc2965.authentication - synapse_login_flows_check_go_infra: health-check post-migration login flows Flows + issues for custom Matrix clients (PC + Android): - 0010 matrix-client-pc: Wails + React+Mantine (issues 0147-0153) - 0011 matrix-client-android: Kotlin + Compose (issues 0154-0161) - 0162 enable MAS as auth provider (Synapse delegate) — EXECUTED on VPS - 0163 custom admin panel propio (sustituye synapse-admin) Production state (organic-machine.com): - Synapse migrated SQLite -> Postgres - MSC3861 active, password_config disabled - 21 users + 41 access_tokens migrated via syn2mas - 4 MAS clients registered (element, matrix_pc, matrix_android, admin_panel) - synapse-admin container removed + Coolify route deleted - well-known patched with org.matrix.msc2965.authentication Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.6 KiB
4.6 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| mas_client_register | function | bash | infra | 0.1.0 | impure | mas_client_register(ssh_host: string, container: string, config_file: string, dry_run: bool) -> json | Registra y sincroniza clientes OAuth en Matrix Authentication Service (MAS) ejecutando mas-cli config sync dentro del container Docker remoto via SSH. Verifica sintaxis YAML, soporte dry-run para ver diff antes de aplicar, y emite JSON estructurado con resultado. Idempotente: re-ejecucion con misma config no genera cambios. |
|
false | error_go_core |
|
JSON con: status ('ok'|'dry-run'|'error'), applied (bool), clients_total (int), clients_diff (array de lineas del output de mas-cli), stderr (string con logs de error si aplica). | true |
|
bash/functions/infra/mas_client_register_test.sh | bash/functions/infra/mas_client_register.sh |
Ejemplo
# Dry-run: verificar que clients se aplicarian correctamente
source bash/functions/infra/mas_client_register.sh
mas_client_register \
--ssh-host organic-machine.com \
--container element_matrix_chat-mas-1 \
--config-file /home/ubuntu/CodeProyects/element_matrix_chat/mas/config.yaml \
--dry-run
# Aplicar sync real (con --prune para eliminar clients viejos)
mas_client_register \
--ssh-host organic-machine.com \
--container element_matrix_chat-mas-1 \
--config-file /home/ubuntu/CodeProyects/element_matrix_chat/mas/config.yaml
Salida esperada (sync OK):
{
"status": "ok",
"applied": true,
"clients_total": 6,
"clients_diff": ["synced client element-web", "synced client synapse-admin", "..."],
"stderr": ""
}
Salida dry-run:
{
"status": "dry-run",
"applied": false,
"clients_total": 42,
"clients_diff": ["clients:", " - client_id: element-web", " ..."],
"stderr": ""
}
Cuando usarla
Usar despues de editar mas/config.yaml localmente y antes de hacer restart a Synapse con msc3861 habilitado en homeserver.yaml. Ejecutar primero con --dry-run para verificar que los 6 clients OAuth (Element Web, Synapse-Admin, matrix_client_pc, matrix_client_android, matrix_admin_panel, Synapse-internal) estan correctamente definidos, luego sin --dry-run para aplicar el sync.
Gotchas
--pruneelimina clients no declarados en config: el sync real usa--prune, lo que borra cualquier client OAuth que exista en MAS pero no este en elconfig.yaml. Verificar con--dry-runantes de aplicar en produccion.- Requiere
jqen el host local: el JSON output se construye conjq. Si no esta instalado, la funcion falla con error claro antes de conectar al VPS. mas-clidebe estar en el container: la funcion asume quemas-cliesta en el PATH dentro del container MAS. Si el container usa una imagen diferente, verificar condocker exec <container> mas-cli --version.- Config dentro del container siempre en
/data/config.yaml: el--config-fileapunta a la ruta en el VPS (para que el operador sepa que archivo editar), pero el comando dentro del container usa/data/config.yaml(el mount point estandar de MAS). Si el compose monta el archivo en otro path, ajustar la constantecontainer_configen el script. - SSH key debe estar en agent o
~/.ssh/config: la funcion usassh <alias>directamente. Si la key requiere passphrase, ejecutarssh-addantes. - Si
config.yamles invalido, sync aborta sin tocar estado: el paso 1 (mas-cli config check) detecta errores de sintaxis YAML antes de intentar sync. El estado de MAS no se modifica si la config tiene errores. - Idempotente: re-ejecutar con la misma config no genera cambios en MAS (mas-cli detecta que el estado ya coincide).