{% extends "space-settings-base.html" %} {% from "ui.html" import csrf_field, action, when with context %} {% set section = "sources" %} {% set base = "/o/" ~ org.slug ~ "/" ~ space.slug ~ "/-/sources" %} {% set auths = {"": _("None"), "bearer": _("Bearer token (Authorization header)"), "header": _("Named header"), "basic": _("Basic (user:password)")} %} {% macro auth_fields(prefix, auth, header) -%}
{%- endmacro %} {% block section %}

{{ _("Services the routines of this space may read over HTTP (GET only): a status page, a ticket tool, another tool's API. A routine's file only names the sources it reads; the address and the secret stay here, and the agent never sees the secret.") }}

{% if not enabled %}

{{ _("External sources are turned off on this instance (SYNAPTANE_ROUTINE_SOURCES): the routines run without them.") }}

{% endif %} {% if error %}{% endif %}
{% for source in sources %}{% set saved = secret_saved(source) %}

{{ source.name }}

{{ auths.get(source.auth, source.auth) }}{% if source.auth == "header" %} · {{ source.header }}{% endif %}

{{ source.base_url }}

{% if saved %}{{ (_("Secret saved on {when}")|e).format(when=when(saved)) }}{% elif source.auth %}{{ _("No secret saved") }}{% else %}{{ _("No secret") }}{% endif %} · {% if used_by[source.name] %}{{ _("Read by: {routines}", routines=used_by[source.name]|join(", ")) }}{% else %}{{ _("No routine reads it yet") }}{% endif %}

{{ action(base ~ "/" ~ source.name ~ "/test", _("Test")) }} {{ action(base ~ "/" ~ source.name ~ "/delete", _("Delete"), confirm=_("Delete the source {name} and its secret? The routines that read it stop running until their file no longer names it.", name=source.name), kind="danger") }}
{{ _("Change") }}
{{ csrf_field() }}
{{ auth_fields("source-" ~ source.name, source.auth, source.header) }}

{{ _("Moving the address to another host asks for the secret again: a saved secret is never sent elsewhere. Choosing no authentication removes it.") }}

{% else %}

{{ _("No external source.") }}

{% endfor %}

{{ _("New external source") }}

{{ csrf_field() }}

{{ _("What a routine's file names: sources: status. Lowercase letters, digits and dashes; it cannot be changed afterwards.") }}

{{ _("Every request of a routine stays under it: same host, same port, a path under this one.") }}

{{ auth_fields("source", draft.auth or "", draft.header or "") }}
{{ _("How it works") }}

{{ _("The agent calls fetch with a source's name and a path under its address; Synaptane adds the secret. Internal addresses are refused, a redirect is followed only under the same source, an answer is read up to 200 KB and only as text (JSON, text, HTML, XML, Markdown), at most {n} calls per run. The run's log lists each call: source, path, status, size.", n=max_calls) }}

{{ _("Every routine of the space may read every source of the space, and anyone who can push can write a routine: declare here only services whose content may end up in this space.") }}

{% endblock %}