Use your own domain
Serve sign-in on a domain of your own, and point the SDKs at it.
What it shows
- The organization adds and verifies its domain in the portal.
- Each SDK takes the domain in one option. Its addresses then carry no
/orgs/<organization>segment. - The issuer is the bare domain, and the discovery document on the domain names the same issuer and the same sign-in address.
- 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:
- Open Settings, Custom domains, and select Add domain.
- Enter the Domain name, for example
auth.acme.com, with nohttps://, and select Add domain. - 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.
- 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.
| Variable | Value |
|---|---|
LUMOAUTH_URL | The address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region. |
LUMOAUTH_ORG_ID | Your organization, for example acme-corp. |
LUMOAUTH_CUSTOM_DOMAIN | The verified custom domain of your organization, for example auth.acme.com. Leave it empty, and the programs use the platform address. |
LUMOAUTH_CLIENT_ID | The 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_KEY | Only 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.
- Node.js
- Python
- Go
- PHP
- C#
// 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.
"""Point the SDK at the custom domain of your organization, and compare its
addresses with the discovery document that LumoAuth serves there.
python sign-in/custom-domain/python/domain.py
"""
import os
import requests
from lumoauth import LumoAuth
# 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. (The SDK also reads LUMOAUTH_CUSTOM_DOMAIN by itself.)
lumo = LumoAuth(custom_domain=os.environ.get("LUMOAUTH_CUSTOM_DOMAIN"))
issuer = lumo.issuer
url = lumo.auth.authorization_url(client_id=os.environ["LUMOAUTH_CLIENT_ID"], redirect_uri="http://localhost:3000/auth/callback")
sign_in = url.split("?")[0]
print(f"Issuer: {issuer}")
print(f"Sign-in address: {sign_in}")
# The issuer names the place of the discovery document, on both kinds of address.
discovery = f"{issuer}/.well-known/openid-configuration"
metadata = requests.get(discovery).json()
print(f"Discovery document: {discovery}")
print(f"Same issuer in the discovery document: {'yes' if metadata['issuer'] == issuer else 'no'}")
print(f"Same sign-in address in the discovery document: {'yes' if metadata['authorization_endpoint'] == sign_in else 'no'}")
python sign-in/custom-domain/python/domain.py
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.
// Point the SDK at the custom domain of your organization, and compare its
// addresses with the discovery document that LumoAuth serves there.
//
// go run ./sign-in/custom-domain/go
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"strings"
lumoauth "github.com/lumoauth/lumo-auth-go"
)
func main() {
// 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. New also reads LUMOAUTH_API_KEY: the client
// needs a credential, and this program sends no request with it.
client, err := lumoauth.New(lumoauth.WithCustomDomain(os.Getenv("LUMOAUTH_CUSTOM_DOMAIN")))
if err != nil {
log.Fatal(err)
}
issuer, err := client.Issuer()
if err != nil {
log.Fatal(err)
}
url, err := client.Auth.AuthorizationURL(lumoauth.AuthorizationURLParams{
ClientID: os.Getenv("LUMOAUTH_CLIENT_ID"),
RedirectURI: "http://localhost:3000/auth/callback",
})
if err != nil {
log.Fatal(err)
}
signIn, _, _ := strings.Cut(url, "?")
fmt.Printf("Issuer: %s\n", issuer)
fmt.Printf("Sign-in address: %s\n", signIn)
// The issuer names the place of the discovery document, on both kinds of address.
discovery := issuer + "/.well-known/openid-configuration"
resp, err := http.Get(discovery)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
var metadata struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
}
if err := json.NewDecoder(resp.Body).Decode(&metadata); err != nil {
log.Fatal(err)
}
yes := map[bool]string{true: "yes", false: "no"}
fmt.Printf("Discovery document: %s\n", discovery)
fmt.Printf("Same issuer in the discovery document: %s\n", yes[metadata.Issuer == issuer])
fmt.Printf("Same sign-in address in the discovery document: %s\n", yes[metadata.AuthorizationEndpoint == signIn])
}
go run ./sign-in/custom-domain/go
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.
<?php
// Point the SDK at the custom domain of your organization, and compare its
// addresses with the discovery document that LumoAuth serves there.
//
// php sign-in/custom-domain/php/domain.php
require __DIR__ . '/../../../php/vendor/autoload.php';
use LumoAuth\LumoAuth;
// 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. (The SDK also reads LUMOAUTH_CUSTOM_DOMAIN by itself.)
$lumo = new LumoAuth(customDomain: getenv('LUMOAUTH_CUSTOM_DOMAIN') ?: null);
$issuer = $lumo->issuer();
$url = $lumo->auth->authorizationUrl(getenv('LUMOAUTH_CLIENT_ID'), 'http://localhost:3000/auth/callback');
$signIn = explode('?', $url)[0];
echo "Issuer: $issuer\n";
echo "Sign-in address: $signIn\n";
// The issuer names the place of the discovery document, on both kinds of address.
$discovery = "$issuer/.well-known/openid-configuration";
$metadata = json_decode(file_get_contents($discovery), true);
echo "Discovery document: $discovery\n";
echo 'Same issuer in the discovery document: ' . ($metadata['issuer'] === $issuer ? 'yes' : 'no') . "\n";
echo 'Same sign-in address in the discovery document: ' . ($metadata['authorization_endpoint'] === $signIn ? 'yes' : 'no') . "\n";
php sign-in/custom-domain/php/domain.php
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.
#:package LumoAuth@1.7.0
#:property PublishAot=false
// Point the SDK at the custom domain of your organization, and compare its
// addresses with the discovery document that LumoAuth serves there.
//
// dotnet run sign-in/custom-domain/csharp/CustomDomain.cs
using System.Text.Json;
using LumoAuth;
using LumoAuth.Models;
// 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. (The SDK also reads LUMOAUTH_CUSTOM_DOMAIN by itself.)
var lumo = new LumoAuthClient(new LumoAuthOptions
{
CustomDomain = Environment.GetEnvironmentVariable("LUMOAUTH_CUSTOM_DOMAIN"),
// This program only builds addresses, so it needs no API key.
CredentialOptional = true,
});
var issuer = lumo.Issuer;
var url = lumo.Auth.AuthorizationUrl(new AuthorizationUrlRequest(
Environment.GetEnvironmentVariable("LUMOAUTH_CLIENT_ID")!, "http://localhost:3000/auth/callback"));
var signIn = url.Split('?')[0];
Console.WriteLine($"Issuer: {issuer}");
Console.WriteLine($"Sign-in address: {signIn}");
// The issuer names the place of the discovery document, on both kinds of address.
var discovery = $"{issuer}/.well-known/openid-configuration";
using var http = new HttpClient();
var metadata = JsonDocument.Parse(await http.GetStringAsync(discovery)).RootElement;
Console.WriteLine($"Discovery document: {discovery}");
Console.WriteLine($"Same issuer in the discovery document: {(metadata.GetProperty("issuer").GetString() == issuer ? "yes" : "no")}");
Console.WriteLine($"Same sign-in address in the discovery document: {(metadata.GetProperty("authorization_endpoint").GetString() == signIn ? "yes" : "no")}");
dotnet run sign-in/custom-domain/csharp/CustomDomain.cs
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
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 nameshttps://app.lumoauth.dev/orgs/acme-corp/api/v1. - Open
https://auth.acme.com/loginin 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.