deploy.login-gate.put

Require sign-in on an app, or change who may sign in

PUT /deploy/api/apps/{id}/login-gateIAM deploy:PutLoginGateChanges stateDestructive

The gate covers every hostname of the app: its default name, custom domains, compose services’ names and preview environments. The machines enforce it themselves (effective on their next poll, within seconds); a machine whose software predates the gate serves nothing until it updates. A browser without a session is sent to sign in; any other request gets 401. The app receives the signed identity in X-Dcloud-Identity (an RS256 JWT, aud = the app id, verify with jwksUrl) and the email in X-Dcloud-User-Email; copies a client sends are removed. A change of provider, issuer, client, domains or webhook URL ends every existing session.

Request syntax

PUT /deploy/api/apps/{id}/login-gate
{
  "provider": "enum",
  "tokenJwks": "string",
  "tokenCookie": "string",
  "tokenIssuer": "string",
  "tokenAudience": "string",
  "redirectUrl": "string",
  "oidcIssuer": "string",
  "oidcClientId": "string",
  "oidcClientSecret": "string",
  "allowedEmailDomains": "array of json",
  "webhookUrl": "string",
  "webhookSecret": "string",
  "sessionHours": "number",
  "exceptions": "array of string",
  "acknowledgeOpenAccess": "boolean"
}

Path parameters

  • idRequired

    string

    Constraints: uuid

Request body

  • providerRequired

    enum

    console: members of the app’s organization whose policies allow deploy:AccessApp on the app sign in with their console account. oidc: your own identity provider. token: requests must carry a JWT your own service signs with a key you register (tokenJwks); others are sent to redirectUrl.

    One of: console, oidc, token

  • tokenJwksOptional

    string

    provider token: your public keys as a JWKS document ({"keys": [...]}): RSA (2048 bits or more, RS256) or EC P-256 (ES256), never a private key or a secret; up to 10, kids unique

    Constraints: max 65536 chars

  • tokenCookieOptional

    string

    provider token: the cookie that carries the token (an Authorization: Bearer header is read too); default dcloud_token

    Constraints: /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/

  • tokenIssuerOptional

    string

    provider token: require this iss; omitted, iss is not checked

    Constraints: 1-512 chars

  • tokenAudienceOptional

    string

    provider token: require this aud; omitted, aud is not checked

    Constraints: 1-512 chars

  • redirectUrlOptional

    string

    provider token: where a browser without a valid token is sent, with ?return_to=<the URL it asked for>

    Constraints: url, max 2048 chars

  • oidcIssuerOptional

    string

    provider oidc: the issuer URL; its /.well-known/openid-configuration must be reachable

    Constraints: url, max 2048 chars

  • oidcClientIdOptional

    string

    provider oidc: the client ID

    Constraints: 1-512 chars

  • oidcClientSecretOptional

    string

    provider oidc, write-only: the client secret. Required the first time and when the issuer or client changes; omit to keep the stored one.

    Constraints: 1-4096 chars

  • allowedEmailDomainsOptional

    array of json

    Admit only these email domains, matched exactly (example.com does not admit eu.example.com). Only an address the provider marks verified (email_verified) is matched.

    Default: []

  • webhookUrlOptional

    string

    An access webhook called once per sign-in; it answers {"allow": true} to admit. Omit or null for none.

    Constraints: url, max 2048 chars

    May be null.

  • webhookSecretOptional

    string

    Write-only: the HMAC-SHA256 key of the X-Dcloud-Signature header. Required with a new webhook; omit to keep the stored one.

    Constraints: 16-256 chars

  • sessionHoursOptional

    number

    How long a sign-in lasts before the person signs in again (1 to 168 hours)

    Constraints: integer, 1-168

    Default: 24

  • exceptionsOptional

    array of string

    Path prefixes served without sign-in: /healthz matches /healthz and /healthz/…; /hooks/ matches everything under /hooks/. Requests to them carry no identity.

    Constraints: max 200 chars, /^\/[A-Za-z0-9\-._~!$&'()*+,=:@/]*$/

    Default: []

  • acknowledgeOpenAccessOptional

    boolean

    oidc without allowedEmailDomains or a webhook admits everyone the provider signs in. Set true to confirm that is intended (refused for public providers such as Google).

Response

201 with `data` when the gate is switched on, 200 when changed. 409 when the settings would admit anyone (a public provider without allowedEmailDomains or a webhook), a secret is missing, or the app is a preview environment; 422 when the issuer’s discovery document cannot be read.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Fields of data

  • appIdAlways

    string

    The app
  • enabledAlways

    boolean

    Whether the app requires sign-in on every hostname
  • providerAlways

    one of console, oidc, token, may be null

    console accounts, your OpenID Connect provider, or tokens your own keys sign; null while off
  • tokenJwksAlways

    string, may be null

    provider token: the registered public keys (JWKS)
  • tokenCookieAlways

    string, may be null

    provider token: the cookie the token is read from
  • tokenIssuerAlways

    string, may be null

    provider token: the required iss; null = any
  • tokenAudienceAlways

    string, may be null

    provider token: the required aud; null = any
  • redirectUrlAlways

    string, may be null

    provider token: where a browser without a valid token is sent (with return_to)
  • oidcIssuerAlways

    string, may be null

    provider oidc: the issuer URL
  • oidcClientIdAlways

    string, may be null

    provider oidc: the client ID
  • oidcClientSecretSetAlways

    boolean

    A client secret is stored (it is never returned)
  • allowedEmailDomainsAlways

    array of string

    Admitted email domains, exact; empty = any
  • webhookUrlAlways

    string, may be null

    The access webhook, if any
  • webhookSecretSetAlways

    boolean

    A webhook secret is stored (it is never returned)
  • sessionHoursAlways

    number, may be null

    How long a sign-in lasts
  • exceptionsAlways

    array of string

    Path prefixes served without sign-in
  • epochAlways

    number

    Raised by revoke-sessions and by changes of who may sign in; older sessions end
  • updatedAtAlways

    string, may be null

    When the gate was last changed; null for never
  • redirectUriAlways

    string

    The redirect URI to register at your identity provider (the same for every app)
  • issuerAlways

    string

    The `iss` of the identity token
  • jwksUrlAlways

    string

    Where the keys that verify the identity token are published
  • identityHeaderAlways

    string

    The request header the app receives the token in
  • emailHeaderAlways

    string

    The request header with the signed-in email, for convenience
  • signOutPathAlways

    string

    Open this path on any hostname of the app to sign out

Checked against the handlers: every route test validates their answers against this schema.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow deploy:PutLoginGate on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud deploy login-gate put id --provider console

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_deploy_login-gate_put.