rustango 0.64.0

Batteries-included web framework for Rust: ORM + migrations + auto-admin + multi-tenancy + audit log + auth (sessions, JWT, OAuth2/OIDC, HMAC) + APIs (ViewSet, OpenAPI auto-derive, JSON:API) + jobs (in-mem + Postgres) + email + media (S3 / R2 / B2 / MinIO + presigned uploads + collections + tags) + production middleware (CSRF, CSP, rate-limiting, compression, idempotency, etc.).
Documentation
{#- The shared-provider fields, for the add form and the edit page. `f` is the
    prefill (never the secret), `creating` picks the add-only rows. -#}
  <table>
    <tr>
      <th><label for="sso_slug">{{ label.slug }}</label></th>
      <td>
        {% if creating %}
        <input type="text" id="sso_slug" name="slug" required pattern="[A-Za-z0-9_\-]+" maxlength="64"
               value="{{ f.slug }}" placeholder="acme-google" data-mark="{{ slug_mark }}">
        <div class="field-helper">Letters, digits, <code>_</code> and <code>-</code>. {{ help.slug | help_html | safe }} It cannot change later.</div>
        {% else %}
        <code>{{ f.slug }}</code>
        <div class="field-helper">{{ help.slug | help_html | safe }} It cannot change.</div>
        {% endif %}
      </td>
    </tr>
    <tr>
      <th><label for="sso_label">{{ label.label }}</label></th>
      <td><input type="text" id="sso_label" name="label" required maxlength="150"
                 value="{{ f.label }}" placeholder="Sign in with Google">
        <div class="field-helper">{{ help.label | help_html | safe }}</div></td>
    </tr>
    <tr>
      <th><label for="sso_kind">{{ label.kind }}</label></th>
      <td>
        <select id="sso_kind" name="kind">
          {% for k in kinds %}<option value="{{ k.0 }}"{% if f.kind == k.0 %} selected{% endif %}>{{ k.1 }}</option>{% endfor %}
        </select>
        <div class="field-helper">{{ help.kind | help_html | safe }}</div>
        {% if not creating %}<div class="field-helper">Changing the kind or issuer URL unlinks the users who signed in through this provider.</div>{% endif %}
      </td>
    </tr>
    <tr class="sso-issuer-row"{% if f.kind != "oidc" %} hidden{% endif %}>
      <th><label for="sso_issuer_url">{{ label.issuer_url }}</label></th>
      <td>
        <input type="url" id="sso_issuer_url" name="issuer_url" maxlength="255"
               value="{{ f.issuer_url }}" placeholder="https://idp.example.com">
        <div class="field-helper">{{ help.issuer_url | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_client_id">{{ label.client_id }}</label></th>
      <td><input type="text" id="sso_client_id" name="client_id" required maxlength="255"
                 value="{{ f.client_id }}" autocomplete="off">
        <div class="field-helper">{{ help.client_id | help_html | safe }}</div></td>
    </tr>
    <tr>
      <th><label for="sso_client_secret">{{ label.client_secret }}</label></th>
      <td>
        <input type="password" id="sso_client_secret" name="client_secret" autocomplete="new-password"{% if creating %} required{% endif %}>
        <div class="field-helper">{{ help.client_secret | help_html | safe }} {% if creating %}Never shown again.{% else %}Saved — leave blank to keep it.{% endif %}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_scopes">{{ label.scopes }}</label></th>
      <td>
        <input type="text" id="sso_scopes" name="scopes" maxlength="255"
               value="{{ f.scopes }}" placeholder="openid email profile">
        <div class="field-helper">{{ help.scopes | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_sort_order">{{ label.sort_order }}</label></th>
      <td>
        <input type="number" id="sso_sort_order" name="sort_order" value="{{ f.sort_order }}">
        <div class="field-helper">{{ help.sort_order | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_enabled">{{ label.enabled }}</label></th>
      <td><input type="checkbox" id="sso_enabled" name="enabled"{% if f.enabled == "on" %} checked{% endif %}>
        <div class="field-helper">{{ help.enabled | help_html | safe }}</div></td>
    </tr>
    <tr>
      <th><label for="sso_allow_email_link">{{ label.allow_email_link }}</label></th>
      <td>
        <input type="checkbox" id="sso_allow_email_link" name="allow_email_link"{% if f.allow_email_link == "on" %} checked{% endif %}>
        <div class="field-helper">{{ help.allow_email_link | help_html | safe }} It applies in every tenant.</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_allowed_email_domains">{{ label.allowed_email_domains }}</label></th>
      <td>
        <textarea id="sso_allowed_email_domains" name="allowed_email_domains" rows="2" maxlength="2000"
                  placeholder="client.org, *.client.org">{{ f.allowed_email_domains }}</textarea>
        <div class="field-helper">{{ help.allowed_email_domains | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_blocked_email_domains">{{ label.blocked_email_domains }}</label></th>
      <td>
        <textarea id="sso_blocked_email_domains" name="blocked_email_domains" rows="2" maxlength="2000"
                  placeholder="gmail.com">{{ f.blocked_email_domains }}</textarea>
        <div class="field-helper">{{ help.blocked_email_domains | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_allowed_idp_tenants">{{ label.allowed_idp_tenants }}</label></th>
      <td>
        <input type="text" id="sso_allowed_idp_tenants" name="allowed_idp_tenants" maxlength="1000"
               value="{{ f.allowed_idp_tenants }}">
        <div class="field-helper">{{ help.allowed_idp_tenants | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_allowed_hosted_domains">{{ label.allowed_hosted_domains }}</label></th>
      <td>
        <input type="text" id="sso_allowed_hosted_domains" name="allowed_hosted_domains" maxlength="1000"
               value="{{ f.allowed_hosted_domains }}">
        <div class="field-helper">{{ help.allowed_hosted_domains | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_required_claims">{{ label.required_claims }}</label></th>
      <td>
        <textarea id="sso_required_claims" name="required_claims" rows="2"
                  placeholder='{"roles": ["App.User"]}'>{{ f.required_claims }}</textarea>
        <div class="field-helper">{{ help.required_claims | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_sso_only">{{ label.sso_only }}</label></th>
      <td>
        <input type="checkbox" id="sso_sso_only" name="sso_only"{% if f.sso_only == "on" %} checked{% endif %}>
        <div class="field-helper">{{ help.sso_only | help_html | safe }} Superusers are never locked out.</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_auto_deactivate_after_days">{{ label.auto_deactivate_after_days }}</label></th>
      <td>
        <input type="number" min="1" id="sso_auto_deactivate_after_days" name="auto_deactivate_after_days" value="{{ f.auto_deactivate_after_days }}">
        <div class="field-helper">{{ help.auto_deactivate_after_days | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_session_ttl_secs">{{ label.session_ttl_secs }}</label></th>
      <td>
        <input type="number" min="1" id="sso_session_ttl_secs" name="session_ttl_secs" value="{{ f.session_ttl_secs }}">
        <div class="field-helper">{{ help.session_ttl_secs | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th><label for="sso_superuser_session_ttl_secs">{{ label.superuser_session_ttl_secs }}</label></th>
      <td>
        <input type="number" min="1" id="sso_superuser_session_ttl_secs" name="superuser_session_ttl_secs" value="{{ f.superuser_session_ttl_secs }}">
        <div class="field-helper">{{ help.superuser_session_ttl_secs | help_html | safe }}</div>
      </td>
    </tr>
    <tr>
      <th>callback URL</th>
      <td>
        <code class="sso-callback" data-template="{{ callback.pattern }}">{{ callback.pattern }}</code>
        {% if callback.example %}
        <div class="field-helper">For tenant <strong>{{ callback.example_tenant }}</strong>:
          <code class="sso-callback" data-template="{{ callback.example }}">{{ callback.example }}</code></div>
        {% elif callback.example_error %}
        <div class="field-helper">No example for tenant <strong>{{ callback.example_tenant }}</strong>: {{ callback.example_error }}</div>
        {% endif %}
        <div class="field-helper">Register this redirect URI at the IdP once for each tenant host that offers the provider.</div>
      </td>
    </tr>
  </table>
<script nonce="{{ csp_nonce }}">
  (function () {
    const kind = document.getElementById("sso_kind");
    const issuer = document.querySelector(".sso-issuer-row");
    kind.addEventListener("change", () => { issuer.hidden = kind.value !== "oidc"; });
    const slug = document.getElementById("sso_slug");
    if (!slug) return;
    const mark = slug.dataset.mark;
    const show = () => {
      for (const el of document.querySelectorAll(".sso-callback")) {
        el.textContent = el.dataset.template.split(mark).join(slug.value.trim() || mark);
      }
    };
    slug.addEventListener("input", show);
    show();
  })();
</script>