Skip to main content

Use your own domain

Serve sign-in on a domain of your own, and point the SDKs at it.

RecipeDraftView source
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
Works with
JavaScript / TypeScriptPythonGoPHPC# / .NET

What it shows​

  1. The organization adds and verifies its domain in the portal.
  2. Each SDK takes the domain in one option. Its addresses then carry no /orgs/<organization> segment.
  3. The issuer is the bare domain, and the discovery document on the domain names the same issuer and the same sign-in address.
  4. Without the option, the same program uses the platform address. That is how it ran for this page.

Before you start​

Check that your plan includes custom domains in the plans matrix. The Admin API has no endpoint for custom domains, so add the domain in the portal:

  1. Open Settings, Custom domains, and select Add domain.
  2. Enter the Domain name, for example auth.acme.com, with no https://, and select Add domain.
  3. Open DNS records on the card of the domain. Add both records at your DNS provider: the TXT record that proves that you own the domain, and the CNAME record that sends its traffic to LumoAuth.
  4. Choose Verify now from the actions menu of the domain. LumoAuth reads the TXT record twice, so choose Verify now again after 30 seconds.

LumoAuth then gets a TLS certificate for the domain. This usually takes a few minutes. The custom domains guide describes each step.

VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_CUSTOM_DOMAINThe verified custom domain of your organization, for example auth.acme.com. Leave it empty, and the programs use the platform address.
LUMOAUTH_CLIENT_IDThe client ID of an application, for example the Starter App. The programs put it into the sign-in address and send no request with it.
LUMOAUTH_API_KEYOnly the Go version reads it: the Go client needs a credential to start. The program sends no request with it.

In a browser app, the provider of @lumoauth/react takes the same option:

<LumoAuthProvider customDomain="auth.acme.com" clientId="…" redirectUri="…">

The route handler of @lumoauth/nextjs reads NEXT_PUBLIC_LUMOAUTH_CUSTOM_DOMAIN. Pass the same value to customDomain of the provider.

Code​

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Without a custom domain, every program printed the platform addresses and two lines with yes. With LUMOAUTH_CUSTOM_DOMAIN set to a domain that does not exist, every program printed the first two lines above and then stopped at the request for the discovery document. The last three lines come from the documentation, not from a run.

sign-in/custom-domain/js/domain.mjs
// Point the SDK at the custom domain of your organization, and compare its
// addresses with the discovery document that LumoAuth serves there.
//
// node sign-in/custom-domain/js/domain.mjs
import { AuthModule } from '@lumoauth/client';

// One option. With a custom domain, no address carries /orgs/<organization>,
// and the base URL and the organization are not used. Without one, the SDK
// uses the platform address.
const auth = new AuthModule({
customDomain: process.env.LUMOAUTH_CUSTOM_DOMAIN || undefined,
baseUrl: process.env.LUMOAUTH_URL,
orgId: process.env.LUMOAUTH_ORG_ID,
clientId: process.env.LUMOAUTH_CLIENT_ID,
});

const issuer = auth.address.issuer;
const { url } = await auth.buildAuthorizationUrl({ redirectUri: 'http://localhost:3000/auth/callback' });
const signIn = url.split('?')[0];
console.log(`Issuer: ${issuer}`);
console.log(`Sign-in address: ${signIn}`);

// The issuer names the place of the discovery document, on both kinds of address.
const discovery = `${issuer}/.well-known/openid-configuration`;
const metadata = await (await fetch(discovery)).json();
console.log(`Discovery document: ${discovery}`);
console.log(`Same issuer in the discovery document: ${metadata.issuer === issuer ? 'yes' : 'no'}`);
console.log(`Same sign-in address in the discovery document: ${metadata.authorization_endpoint === signIn ? 'yes' : 'no'}`);
node sign-in/custom-domain/js/domain.mjs

Compiles. Not run against an organization. It ran against the platform address of an organization. No custom domain was available, so it was not run on one.

Check the result​

Output
Issuer: https://auth.acme.com
Sign-in address: https://auth.acme.com/api/v1/oauth/authorize
Discovery document: https://auth.acme.com/.well-known/openid-configuration
Same issuer in the discovery document: yes
Same sign-in address in the discovery document: yes
  • A token that LumoAuth issues on the custom domain names it in iss: "iss": "https://auth.acme.com". A token from the platform address names https://app.lumoauth.dev/orgs/acme-corp/api/v1.
  • Open https://auth.acme.com/login in a browser. The sign-in page of your organization appears on your domain.

Limits​

  • Use one address for each application. A code that is issued on the custom domain and redeemed on the platform address gives a token with an issuer that your app rejects.
  • A path that starts with /orgs/ answers 404 on the custom domain. An SDK without the option builds such paths.
  • The published Java SDK and the Spring Boot starter have no option for a custom domain.
  • Links in emails (sign-in links, password resets, invitations) point at the platform address.
  • The LumoAuth MCP server is not served on custom domains.