diff --git a/source/conf.ts b/source/conf.ts index 324d515..544580e 100644 --- a/source/conf.ts +++ b/source/conf.ts @@ -198,10 +198,11 @@ namespace _espe.conf } | { - kind : "authelia_call"; + kind : "arc"; data : { http_scheme : ("http" | "https"); http_host : string; + http_port : int; hash_salt : string; } } @@ -957,7 +958,55 @@ namespace _espe.conf })) (conf_raw["settings"] ?? {}) ), "admins": (conf_raw["admins"] ?? []), - "outputs": (conf_raw["outputs"] ?? []), + "outputs": ( + ((node_outputs) => node_outputs.map( + (output_description : {kind : string; data : any;}) => { + const kind : string = output_description["kind"]; + const node_options_data_raw = (output_description["data"] ?? {}); + switch (kind) { + case "authelia_file": { + return { + "kind": kind, + "data": { + "path": (node_options_data_raw["path"] ?? "/var/authelia/users.yaml"), + } + }; + break; + } + case "http": { + return { + "kind": kind, + "data": { + "scheme": (node_options_data_raw["scheme"] ?? "http"), + "host": (node_options_data_raw["host"] ?? "localhost"), + "path": (node_options_data_raw["path"] ?? ""), + "method": (node_options_data_raw["method"] ?? "post"), + "query": (node_options_data_raw["query"] ?? null), + "headers": (node_options_data_raw["headers"] ?? {"Content-Type": "application/json"}), + }, + }; + break; + } + case "arc": { + return { + "kind": kind, + "data": { + "http_scheme": (node_options_data_raw["scheme"] ?? "http"), + "http_host": (node_options_data_raw["http_host"] ?? "localhost"), + "http_port": (node_options_data_raw["http_port"] ?? 7463), + "hash_salt": node_options_data_raw["hash_salt"], + } + }; + break; + } + default: { + throw (new Error("unhandled")); + break; + } + } + } + )) (conf_raw["outputs"] ?? []) + ), }; break; } diff --git a/source/main.ts b/source/main.ts index 18fa155..5134291 100644 --- a/source/main.ts +++ b/source/main.ts @@ -340,7 +340,7 @@ async function main( return (() => _espe.service.member.output_http(output_description.data)); break; } - case "authelia_call": { + case "arc": { return (() => _espe.service.member.output_authelia_call(output_description.data)); break; } diff --git a/source/services/member.ts b/source/services/member.ts index 933e8e9..6205bbf 100644 --- a/source/services/member.ts +++ b/source/services/member.ts @@ -941,6 +941,7 @@ namespace _espe.service.member output_parameters : { http_scheme : ("http" | "https"); http_host : string; + http_port : int; hash_salt : string; } ) : Promise @@ -953,7 +954,13 @@ namespace _espe.service.member ); const http_request : lib_plankton.http.type_request = { "scheme": output_parameters.http_scheme, - "host": output_parameters.http_host, + "host": lib_plankton.string.coin( + "{{host}}:{{port}}", + { + "host": output_parameters.http_host, + "port": output_parameters.http_port.toFixed(0), + } + ), "path": "/users/set", "version": "HTTP/1.1", "method": lib_plankton.http.enum_method.put,