dcloud_app_login_gate
Requires sign-in on every hostname of an app (default name, custom domains, compose services' names, preview environments): with console accounts of the app's organization (sign_in_with = "console", people whose policies allow deploy:AccessApp) or your own OpenID Connect provider (sign_in_with = "oidc"; register redirect_uri there). Optionally an access webhook decides per person. The app receives the signed identity in X-Dcloud-Identity (an RS256 JWT, aud = the app id, keys at jwks_url). Or sign_in_with = "token": only requests carrying a JWT signed by one of your own keys (token_jwks, e.g. file("jwks.json"); RS256 or ES256, public keys only) in the cookie token_cookie or an Authorization: Bearer header pass; browsers without one go to redirect_url?return_to=<url>. Destroying it makes the app public again.
Example Usage
# Only people from example.com, signed in at your own identity provider, reach the app.
# Register dcloud_app_login_gate.web.redirect_uri as a redirect URI of the client there.
resource "dcloud_app_login_gate" "web" {
app_id = dcloud_app.web.id
sign_in_with = "oidc"
oidc_issuer = "https://login.example.com/realms/staff"
oidc_client_id = "dcloud-web"
oidc_client_secret = var.oidc_client_secret
allowed_email_domains = ["example.com"]
session_hours = 12
exceptions = ["/healthz", "/webhooks/"]
}
# Or: members of the app's organization, with their console account.
resource "dcloud_app_login_gate" "admin" {
app_id = dcloud_app.admin.id
sign_in_with = "console"
}Schema
Required
app_id(String) The id of the parent resource ({id}in the path). Changing it replaces the resource.sign_in_with(String) 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.
Optional
acknowledge_open_access(Boolean) Confirms that an OIDC gate withoutallowed_email_domainsor a webhook may admit everyone the provider signs in (refused for public providers). Never returned by the API: not read back, and empty after an import.allowed_email_domains(List of String) 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.exceptions(List of String) Path prefixes served without sign-in: /healthz matches /healthz and /healthz/…; /hooks/ matches everything under /hooks/. Requests to them carry no identity. Default[].oidc_client_id(String) provider oidc: the client ID. Up to 512 characters.oidc_client_secret(String, Sensitive) The client secret at your provider. Write-only: not read back, absent after an import. Never returned by the API: not read back, and empty after an import.oidc_issuer(String) provider oidc: the issuer URL; its /.well-known/openid-configuration must be reachable. Up to 2048 characters.redirect_url(String) provider token: where a browser without a valid token is sent, with ?return_to=. Up to 2048 characters.session_hours(Number) How long a sign-in lasts before the person signs in again (1 to 168 hours). Default24. From 1 to 168.token_audience(String) provider token: require this aud; omitted, aud is not checked. Up to 512 characters.token_cookie(String) provider token: the cookie that carries the token (an Authorization: Bearer header is read too); default dcloud_tokentoken_issuer(String) provider token: require this iss; omitted, iss is not checked. Up to 512 characters.token_jwks(String) Your public keys as a JWKS document (file("jwks.json")orjsonencode({ keys = [...] })): RSA 2048+ (RS256) or EC P-256 (ES256), never a private key; up to 10, kids unique.webhook_secret(String, Sensitive) The HMAC-SHA256 key of the webhook'sX-Dcloud-Signature. Write-only. Never returned by the API: not read back, and empty after an import.webhook_url(String) An access webhook called once per sign-in; it answers {"allow": true} to admit. Omit or null for none. Up to 2048 characters.
Read-Only
id(String) The resource's id.issuer(String) Theissof the identity token.jwks_url(String) Where the keys that verify the identity token are published.redirect_uri(String) The redirect URI to register at your identity provider.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import dcloud_app_login_gate.web <app-id>Generated from the provider's schema.
Related