{# The four shapes a stored credential can take (spec §4), as form fields. Used twice on the add-server form and twice again on the settings page (task 023): the API's credential and the spec URL's are the same four shapes, and writing them out twice is how the two would end up disagreeing about what an API key is. ``group`` is the reveal group the selector above these panels controls, and ``prefix`` is what distinguishes one set of fields from the other in the posted form — the empty string for the API credential, ``spec_`` for the spec one, which is exactly what ``wizard.parse_form`` reads them back with. Every panel is rendered whatever is selected. static/js/forms.js hides the ones that do not apply; with no script at all the operator sees all four and fills in the one they chose, which still submits correctly. #} {% from "partials/field.html" import field, secret, secret_lines %} {% macro credential_fields(group, prefix="", errors={}) -%}
{{ secret(prefix ~ "token", "Token", hint="Sent as an Authorization: Bearer header.", error=errors.get(prefix ~ "token")) }}
{{ field(prefix ~ "header", "Header name", hint="The header the upstream expects the key in.", error=errors.get(prefix ~ "header")) }} {{ secret(prefix ~ "value", "Header value", error=errors.get(prefix ~ "value")) }}
{{ field(prefix ~ "username", "Username", error=errors.get(prefix ~ "username")) }} {{ secret(prefix ~ "password", "Password", error=errors.get(prefix ~ "password")) }}
{{ secret_lines(prefix ~ "headers", "Headers", hint="One per line, written as Name: value.", error=errors.get(prefix ~ "headers")) }}
{%- endmacro %}