# Going to Production

From [Descope Operations](https://learn.descope.io/c/operations): Move users in, go live, and find out what broke when something does.

Take this course interactively at https://learn.descope.io/c/operations/production-readiness

---

![Environment Promotion.](video:production-readiness-environment-promotion)

Descope treats development, staging, and production as genuinely separate projects rather than modes of one project. That isolation is a feature (a mistake in staging cannot touch production users), but it means you need a deliberate way to move configuration between them.

The production project usually starts life as a clone of the development project, made from Project Settings in the Console or with the CLI. Cloning copies configuration and nothing else, which is exactly what makes it safe to do.

```bash
descope project clone <existingProjectId> <newProjectName> -e production
```

## What a clone copies, and what it does not

- Flows and styles
- Project settings and authentication configuration
- Email templates
- Not users. A clone never copies user data, so production starts with nobody in it

A clone is how a project begins. Every change after that moves as a snapshot.

A project snapshot is a portable export of a project's configuration: a folder of JSON files covering `auth/` (one file per authentication method), `flows/` (an index plus a subfolder per flow), `connectors/`, `roles.json`, `applications.json`, `attributes.json`, `styles/`, `widgets/`, and, where FGA is configured, `fgaschema.txt`. Exporting from the Console produces the same contents as exporting with the CLI; the difference is only packaging: a zip versus a folder on disk. A snapshot never carries users, tenants, consents or audit logs, so promoting configuration cannot move anybody's data.

> [!WARNING]
> Secrets are handled deliberately. Connector and OAuth provider credentials are stripped on export and replaced with `PLACEHOLDER_VALUE`. On import, leaving the placeholder keeps the destination's existing secret untouched; replacing it with a real value overrides the destination's secret; and blanking it, or removing the line, clears the secret entirely. The CLI accepts secrets at import time with `--secrets-input`.

Descope publishes a GitHub Actions template, and a GitLab equivalent, that turns snapshot promotion into a reviewable pull request rather than a manual export/import. The setup stores a management key scoped to both projects as a repo secret, plus `PRODUCTION_PROJECT_ID` and `STAGING_PROJECT_ID` as repo variables.

## How the CI/CD promotion runs

- Create Pull Request from Staging Project exports staging's current configuration into a ProjectSnapshot folder and opens a PR containing the diff.
- Reviewing and merging that PR automatically triggers Deploy to Production Project, applying the snapshot.
- If a connector or OAuth provider in staging has no matching configuration in production yet, the deployment fails with the exact JSON needed; you re-run the workflow supplying that JSON with real secrets filled in.

Snapshots and CI/CD move static configuration safely. Dynamic resources (users, live SSO connections) stay per-environment and are never promoted this way.

## Key terms

- Project clone: a new project made as a copy of an existing one's configuration, never its users.
- Project snapshot: a portable export of a project's configuration as a folder of JSON files, excluding users, tenants, consents and audit logs.
- `PLACEHOLDER_VALUE`: what connector and OAuth secrets are replaced with on export; leaving it keeps the destination's secret.

## Summary

- That environments are separate projects, and what that buys you
- What a clone copies, and that it never copies users
- What a snapshot contains and how secrets survive the round trip
- How promotion becomes a reviewable pull request
- What a failed deploy tells you, and how to complete it

---

![Terraform and Automation.](video:production-readiness-terraform-and-automation)

Snapshots and CI/CD templates cover promotion between two projects. Terraform takes a different angle: you declare the configuration you want as code, and Terraform reconciles the live project to match (the same infrastructure-as-code discipline teams already apply to servers and cloud resources).

Descope publishes an official provider (`descope/descope`) built around a `descope_project` resource, alongside standalone resources for access keys, management keys, the Descope Engine, Descopers, and inbound apps.

> [!WARNING]
> Terraform only manages what you explicitly declare, and the asymmetry is the single most common footgun with this provider. Omitting a block entirely (say, connectors) means Terraform leaves it alone. But adding that block, even empty, means Terraform now owns everything inside it, and on the next apply it will remove anything present in the live project that is not declared in your configuration.

## Key terms

- `descope_project`: the core resource in Descope's official Terraform provider, alongside standalone resources for access keys, management keys, and inbound apps.

## Summary

- What Terraform adds beyond snapshot promotion
- That omitting a block is safe and declaring an empty one is not
- Which resources the provider exposes

---

![Custom Domains.](video:production-readiness-custom-domains)

A custom domain lets your users see `auth.yourapp.com` instead of a generic Descope address. Part of that is branding, but it also unlocks a meaningfully safer place to keep the refresh token.

By default Descope stores both tokens in localStorage: convenient, but readable by any JavaScript on the page, and therefore exposed to XSS. The refresh token is the critical one: if it leaks, an attacker can mint new sessions indefinitely. Moving it to an HttpOnly cookie fixes that, but `sameSite=strict` requires the cookie domain to be a subdomain of your own site. A custom domain gives Descope a hostname that belongs to you, so the refresh-token cookie can be scoped to it safely.

Setting one up takes a DNS record and two settings, and the order matters: the record has to resolve before Descope can confirm the domain.

## Setting up a custom domain

- Create a CNAME record from a hostname you own to the Descope target for your project's region: `cname.descope.com` for US projects, with a different target for other regions
- In Project Settings, set the App URL and add the custom domain, then refresh until its status reads Setup complete
- In the SDK, set `baseUrl` to your HTTPS origin, and optionally `baseStaticUrl` as well
- Private cloud deployments use different CNAME targets and static IPs, so they start from the private cloud guide instead

> [!WARNING]
> The CNAME target is used only in DNS, never in code. The SDK's `baseUrl` is your own HTTPS origin, the hostname you own, which is the whole point of having the domain.

## What turning on a custom domain changes

- Approved Domains: the allowlist of domains authorized to interact with your project; your custom domain must be reflected here.
- Cookie Domain: the scope of the refresh-token cookie once tokens move into cookies.
- OAuth Callback URL / Callback Domain: the redirect target your OAuth providers return users to; must match what is registered on the provider's side.
- Passkey Top-Level Domain: passkeys are bound to a domain, so this must reflect production before real users enroll.
- Base URL: the value your SDKs use to reach the Descope API.
- SAML ACS URL, per tenant, in SSO configuration: where SAML assertions are posted back to.

> [!NOTE]
> For OIDC SSO connections specifically, the Callback Domain and Callback URL fields update automatically when you change the project's custom domain (one less place to remember during a cutover).

## Key terms

- Custom domain: a hostname you own, letting the refresh-token cookie be scoped safely under `sameSite=strict`.
- Cookie Domain: the scope of the refresh-token cookie once tokens move out of localStorage.
- Passkey Top-Level Domain: the domain passkeys are bound to.

## Summary

- Why the refresh token specifically is the one worth protecting
- What a custom domain unlocks that branding alone does not
- How a custom domain is set up, and where the CNAME target belongs
- The six settings that shift when you enable one
- Which fields update themselves, and which you must remember

---

![Replacing Development Defaults.](video:production-readiness-replace-development-defaults)

Development projects lean on conveniences that make testing easy: a fixed code for test users, a shared OAuth application for social sign-in, and a free allowance of text messages. None of them belong in production. It is like moving from a rehearsal room to a live venue: the stage is the same, but the safety checks are not, and each of these has a specific replacement.

## The defaults to replace

- Static OTP codes: a fixed one-time code for a test user is a fixed credential. Disable it before launch, and if a mobile app review needs one, track audit events for its use
- The default OAuth provider: Descope supplies default OAuth credentials, and the first 100 OAuth logins a month across them, for testing. It cannot show your branding and cannot be used in production, so register your own application with each provider
- Messaging connectors: Descope includes the first 100 SMS messages a month for authentication. Configure your own SMS and email connectors before launch, so authentication keeps working when the allowance runs out

Each of these fails differently, which is why they are easy to miss. A static code fails silently, as a credential nobody remembers is there. The default OAuth provider fails visibly but only partly, with sign-in screens that carry somebody else's name. And the message allowance fails late, on a busy day after launch, when the 101st code of the month does not arrive. A pre-launch review exists to catch all three while they are still cheap to fix.

> [!NOTE]
> Your own connectors bring something beyond the missing ceiling: messages sent through them can use custom, branded templates, so a sign-in code arrives looking like it came from your product rather than from a vendor.

## Key terms

- Static OTP: a fixed one-time code for test users, which is a fixed credential and is disabled in production.
- Default OAuth provider: Descope's shared OAuth credentials for testing, limited to the first 100 logins a month and unable to show your branding.
- Messaging connector: your own SMS or email provider, configured so authentication does not depend on the included message allowance.

## Summary

- Which development conveniences have no place in production
- What replaces static OTP codes, the default OAuth provider and the included messages
- Why each one fails differently, and why that makes them easy to miss
- What your own connectors add beyond removing the limit

---

![Security Hardening Checklist.](video:production-readiness-security-hardening-checklist)

The rest of this module covers getting a project into production. This section covers making sure it is safe once it is there: a checklist to run before go-live, and again on a recurring schedule afterwards.

## Session and token settings

- Session Token Timeout: shorter timeouts shrink the blast radius of a stolen token. Reasonable production defaults are 15–60 minutes for admin-style sessions, 60–120 minutes for standard users.
- Refresh Token Timeout: 1–7 days for admin sessions, 7–30 days for standard users, balancing re-authentication friction against exposure window.
- Refresh Token Rotation (Pro+): each refresh issues a new refresh token and invalidates the old one, so reuse of an old token is itself a theft signal.
- Session Inactivity: expires idle sessions automatically; 15–30 minutes is reasonable for administrative accounts.
- Trusted Device Tokens: reduce MFA prompts on returning devices. Convenient for standard users, generally worth disabling for admins, where you want MFA every time.

> [!WARNING]
> Always populate Approved Domains (web domains, no protocol prefix). Leaving the list empty disables redirect and verification validation entirely, which is a genuine open-redirect risk rather than a stylistic warning.

## Domains, redirects, and access control

- Cross-Company Domain Protection: automatic and requiring no configuration; Descope blocks a flow from one company running on a custom domain belonging to a different company's trusted domain list.
- RBAC least privilege: define roles around the specific job functions that need them, mark internal or system roles Hidden so tenant admins cannot self-assign them, and keep default-role assignment for new users minimal.
- Federated App default access: decide deliberately between granting new users access to all applications versus requiring explicit assignment. The latter is tighter and costs more provisioning work.

The last group is about what a project exposes rather than how it behaves: every flow, widget and API path that is on is something an attacker can reach, so the safest setting for anything you do not use is off.

## Reducing the attack surface

- Block self-registration if users must be invited. They then sign in only after an invitation, or if their email domain has self-registration enabled on the tenant
- Prevent user enumeration: make sure no flow reveals whether an account exists, following the preventing user enumeration guide
- Set your cookie policy deliberately, following the cross-site cookie guide
- Disable unused flows and widgets in the Console
- SDK and API access is on by default for each authentication method. Turn it off if you use Flows without client SDKs, and also if you use backend SDKs, which authenticate with a management key instead
- For access keys and management keys, set an expiry, rotate them regularly, and limit their scope with permitted IPs and roles

Notice that several of these tradeoffs cut both ways depending on the role. Trusted Device Tokens help standard users and weaken admin accounts; a permissive Federated App default speeds onboarding and widens exposure. The checklist is not a set of universally correct values; it is a set of decisions to make deliberately rather than inherit.

## Key terms

- Refresh Token Rotation: each refresh issues a new token and invalidates the old, making reuse a theft signal.
- Cross-Company Domain Protection: an automatic safeguard blocking a flow from running on another company's trusted custom domain.
- User enumeration: a flow revealing whether an account exists, which lets an attacker test addresses for membership.

## Summary

- Reasonable production timeout defaults for admin versus standard sessions
- Why an empty Approved Domains list is an open-redirect risk
- Which protections are automatic and which you must configure
- How to shrink what a live project exposes, from sign-up to key scope
- That several settings are role-dependent tradeoffs, not universal defaults

---

![Audit Logs and Application Safeguards.](video:production-readiness-audit-and-application-safeguards)

Some of a launch checklist lives in Descope and some lives in your own application. Audit history is the Descope half, and it has a limit worth knowing before anyone needs it: Descope stores audit events for 30 days, so an investigation or a compliance request reaching further back than that finds nothing unless something was keeping the history.

## Keeping audit history longer

- A generic audit webhook, sending events to your own API
- Connectors for Sumo Logic, Datadog, AWS S3 and other services

An audit connector streams events to a service that keeps them for as long as you choose. Configure it before the history is needed rather than when somebody first asks for it, because by then Descope's own copy reaches back only 30 days.

The rest of the checklist is in your own code, and it is the part a Console review cannot see.

## Safeguards in your application

- Remove console log messages that could expose email addresses or passwords; the SDK's logger component can be set to ignore info logs
- Make as few API calls as possible. A rate-limited request returns HTTP 429 with a `Retry-After` header saying when to try again
- Use the Descope SDKs where you can, since they have a higher rate limit than direct API calls
- Test every essential use case on every device your users use, with Descope's automated testing guides for Cypress and Playwright

Rate limits are the safeguard most often discovered in production, because development traffic never reaches them. An application that calls Descope on every page load works for one developer and fails for a launch-day crowd, and the 429 it receives is the platform working as designed. Fewer calls, through the SDKs, and honouring `Retry-After` are what keep that from becoming an outage.

## Key terms

- Audit connector: a connector streaming audit events to another service, keeping history beyond Descope's 30 days.
- HTTP 429: the status a rate-limited request receives, with a `Retry-After` header saying when to retry.
- Retry-After: the response header giving the time to wait before retrying a rate-limited request.

## Summary

- How long Descope keeps audit events, and how to keep them longer
- Why an audit connector belongs in place before the history is needed
- What to check in your own code before launch
- Why rate limits appear only in production, and how to stay under them

---
