From c70362e5efc4c5348e96ad024358d27c7edc6f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Wed, 8 Oct 2025 12:26:20 +0200 Subject: [PATCH] [int] --- roles/hedgedoc/cfg.schema.json | 312 +++++++++++------------- roles/hedgedoc/defaults/main.json | 22 +- roles/hedgedoc/tasks/main.json | 4 +- roles/hedgedoc/templates/config.json.j2 | 24 +- 4 files changed, 178 insertions(+), 184 deletions(-) diff --git a/roles/hedgedoc/cfg.schema.json b/roles/hedgedoc/cfg.schema.json index 11bd79b..d45def3 100644 --- a/roles/hedgedoc/cfg.schema.json +++ b/roles/hedgedoc/cfg.schema.json @@ -27,205 +27,181 @@ "default": "hedgedoc.example.org" }, "database": { - "anyOf": [ - { + "nullable": false, + "type": "object", + "properties": { + "kind": { "nullable": false, - "type": "object", - "properties": { - "kind": { - "nullable": false, - "type": "string", - "enum": ["sqlite"] - }, - "data": { - "nullable": false, - "type": "object", - "properties": { - "path": { - "nullable": false, - "type": "string", - "default": "/var/hedgedoc/data.sqlite" - } - }, - "additionalProperties": false, - "required": [ - ], - "default": { - } - } - }, - "additionalProperties": false, - "required": [ - "kind" - ] + "type": "string", + "enum": [ + "sqlite", + "postgresql" + ], + "default": "sqlite" }, - { - "nullable": false, - "type": "object", - "properties": { - "kind": { - "nullable": false, - "type": "string", - "enum": ["postgresql"] - }, - "data": { + "data": { + "anyOf": [ + { "nullable": false, "type": "object", "properties": { - "host": { + "sqlite": { "nullable": false, - "type": "string", - "default": "localhost" - }, - "port": { - "nullable": false, - "type": "integer", - "default": 5432 - }, - "username": { - "nullable": false, - "type": "string", - "default": "hedgedoc_user" - }, - "password": { - "nullable": false, - "type": "string" - }, - "schema": { - "nullable": false, - "type": "string", - "default": "hedgedoc" + "type": "object", + "properties": { + "path": { + "nullable": false, + "type": "string", + "default": "/var/hedgedoc/data.sqlite" + } + }, + "additionalProperties": false, + "required": [ + ], + "default": { + } } }, "additionalProperties": false, "required": [ - "password" + "sqlite" + ] + }, + { + "nullable": false, + "type": "object", + "properties": { + "postgresql": { + "nullable": false, + "type": "object", + "properties": { + "host": { + "nullable": false, + "type": "string", + "default": "localhost" + }, + "port": { + "nullable": false, + "type": "integer", + "default": 5432 + }, + "username": { + "nullable": false, + "type": "string", + "default": "hedgedoc_user" + }, + "password": { + "nullable": false, + "type": "string" + }, + "schema": { + "nullable": false, + "type": "string", + "default": "hedgedoc" + } + }, + "additionalProperties": false, + "required": [ + "password" + ] + } + }, + "additionalProperties": false, + "required": [ + "postgresql" ] } - }, - "additionalProperties": false, - "required": [ - "kind", - "data" - ] - }, - { - "nullable": false, - "type": "object", - "properties": { - "kind": { - "nullable": false, - "type": "string", - "enum": ["mariadb"] - }, - "data": { - "nullable": false, - "type": "object", - "properties": { - "host": { - "nullable": false, - "type": "string", - "default": "localhost" - }, - "port": { - "nullable": false, - "type": "integer", - "default": 3306 - }, - "username": { - "nullable": false, - "type": "string", - "default": "hedgedoc_user" - }, - "password": { - "nullable": false, - "type": "string" - }, - "schema": { - "nullable": false, - "type": "string", - "default": "hedgedoc" - } - }, - "additionalProperties": false, - "required": [ - "password" - ] - } - }, - "additionalProperties": false, - "required": [ - "kind", - "data" ] } + }, + "additionalProperties": false, + "required": [ + "kind", + "data" ] }, "authentication": { - "anyOf": [ - { + "nullable": false, + "type": "object", + "properties": { + "kind": { "nullable": false, - "type": "object", - "properties": { - "kind": { - "nullable": false, - "type": "string", - "enum": ["internal"] - }, - "data": { - "nullable": false, - "type": "object", - "properties": { - }, - "additionalProperties": false, - "required": [ - ] - } - }, - "additionalProperties": false, - "required": [ - "kind" - ] + "type": "string", + "enum": [ + "internal", + "authelia" + ], + "default": "internal" }, - { - "nullable": false, - "type": "object", - "properties": { - "kind": { - "nullable": false, - "type": "string", - "enum": ["authelia"] - }, - "data": { + "data": { + "anyOf": [ + { "nullable": false, "type": "object", "properties": { - "url_base": { + "internal": { "nullable": false, - "type": "string" - }, - "client_id": { - "nullable": false, - "type": "string", - "default": "hedgedoc" - }, - "client_secret": { - "nullable": false, - "type": "string" + "type": "object", + "properties": { + }, + "additionalProperties": false, + "required": [ + ], + "default": { + } } }, "additionalProperties": false, "required": [ - "url_base", - "client_secret" + "internal" + ] + }, + { + "nullable": false, + "type": "object", + "properties": { + "authelia": { + "nullable": false, + "type": "object", + "properties": { + "url_base": { + "nullable": false, + "type": "string" + }, + "client_id": { + "nullable": false, + "type": "string", + "default": "hedgedoc" + }, + "client_secret": { + "nullable": false, + "type": "string" + }, + "provider_name": { + "nullable": false, + "type": "string", + "default": "Authelia" + } + }, + "additionalProperties": false, + "required": [ + "url_base", + "client_secret" + ] + } + }, + "additionalProperties": false, + "required": [ + "authelia" ] } - }, - "additionalProperties": false, - "required": [ - "kind" ] } + }, + "additionalProperties": false, + "required": [ + "kind", + "data" ] }, "log_level": { diff --git a/roles/hedgedoc/defaults/main.json b/roles/hedgedoc/defaults/main.json index 98e2b3d..11a2904 100644 --- a/roles/hedgedoc/defaults/main.json +++ b/roles/hedgedoc/defaults/main.json @@ -6,11 +6,29 @@ "database": { "kind": "sqlite", "data": { - "path": "/var/hedgedoc/data.sqlite" + "sqlite": { + "path": "/var/hedgedoc/data.sqlite" + }, + "postgresql": { + "host": "localhost", + "port": 5432, + "username": "hedgedoc_user", + "password": "hedgedoc", + "schema": "hedgedoc" + } } }, "authentication": { - "kind": "internal" + "kind": "internal", + "data": { + "internal": { + }, + "authelia": { + "client_id": "hedgedoc", + "client_secret": "hedgedoc", + "provider_name": "Authelia" + } + } }, "log_level": "error", "guest_allow_create": false, diff --git a/roles/hedgedoc/tasks/main.json b/roles/hedgedoc/tasks/main.json index b1325ea..626c6cc 100644 --- a/roles/hedgedoc/tasks/main.json +++ b/roles/hedgedoc/tasks/main.json @@ -47,7 +47,7 @@ "become": true, "ansible.builtin.file": { "state": "directory", - "path": "{{cfg_hedgedoc.database.data.path | dirname}}", + "path": "{{cfg_hedgedoc.database.data.sqlite.path | dirname}}", "owner": "{{cfg_hedgedoc.user_name}}" } }, @@ -56,7 +56,7 @@ "become": true, "ansible.builtin.file": { "state": "touch", - "path": "{{cfg_hedgedoc.database.data.path}}", + "path": "{{cfg_hedgedoc.database.sqlite.data.path}}", "owner": "{{cfg_hedgedoc.user_name}}" } } diff --git a/roles/hedgedoc/templates/config.json.j2 b/roles/hedgedoc/templates/config.json.j2 index b4dddc1..2dc3b76 100644 --- a/roles/hedgedoc/templates/config.json.j2 +++ b/roles/hedgedoc/templates/config.json.j2 @@ -4,17 +4,17 @@ {% if cfg_hedgedoc.database.kind == 'sqlite' %} "db": { "dialect": "sqlite", - "storage": "{{cfg_hedgedoc.database.data.path}}" + "storage": "{{cfg_hedgedoc.database.data.sqlite.path}}" }, {% endif %} {% if cfg_hedgedoc.database.kind == 'postgresql' %} "db": { "dialect": "postgres", - "host": "{{cfg_hedgedoc.database.data.host}}", - "port": {{cfg_hedgedoc.database.data.port | to_json}}, - "username": "{{cfg_hedgedoc.database.data.username}}", - "password": "{{cfg_hedgedoc.database.data.password}}", - "database": "{{cfg_hedgedoc.database.data.schema}}" + "host": "{{cfg_hedgedoc.database.data.postgresql.host}}", + "port": {{cfg_hedgedoc.database.data.postgresql.port | to_json}}, + "username": "{{cfg_hedgedoc.database.data.postgresql.username}}", + "password": "{{cfg_hedgedoc.database.data.postgresql.password}}", + "database": "{{cfg_hedgedoc.database.data.postgresql.schema}}" }, {% endif %} "sessionSecret": "{{cfg_hedgedoc.session_secret}}", @@ -31,16 +31,16 @@ {% endif %} {% if cfg_hedgedoc.authentication.kind == 'authelia' %} "oauth2": { - "providerName": "{{cfg_hedgedoc.authentication.data.provider_name}}", - "clientID": "{{cfg_hedgedoc.authentication.data.client_id}}", - "clientSecret": "{{cfg_hedgedoc.authentication.data.client_secret}}", + "providerName": "{{cfg_hedgedoc.authentication.data.authelia.provider_name}}", + "clientID": "{{cfg_hedgedoc.authentication.data.authelia.client_id}}", + "clientSecret": "{{cfg_hedgedoc.authentication.data.authelia.client_secret}}", "scope": "openid email profile", "userProfileUsernameAttr": "sub", "userProfileDisplayNameAttr": "name", "userProfileEmailAttr": "email", - "userProfileURL": "{{cfg_hedgedoc.authentication.data.url_base}}/api/oidc/userinfo", - "tokenURL": "{{cfg_hedgedoc.authentication.data.url_base}}/api/oidc/token", - "authorizationURL": "{{cfg_hedgedoc.authentication.data.url_base}}/api/oidc/authorization" + "userProfileURL": "{{cfg_hedgedoc.authentication.data.authelia.url_base}}/api/oidc/userinfo", + "tokenURL": "{{cfg_hedgedoc.authentication.data.authelia.url_base}}/api/oidc/token", + "authorizationURL": "{{cfg_hedgedoc.authentication.data.authelia.url_base}}/api/oidc/authorization" }, "email": false, "allowEmailRegister": false,