Skip to main content

Keep data in the EU

Create the organization in the EU region and point every SDK at it.

RecipeReadyView source
Works with
JavaScript / TypeScriptPythonGolumo CLI

What it shows​

  1. You create the organization in the EU region, at https://eu.app.lumoauth.dev.
  2. Each SDK and the CLI get the EU address where you create the client.
  3. A program gets a token, and the issuer of the token starts with the EU address.

The two regions are separate deployments, and nothing is copied between them. An organization belongs to the region where you created it, and you cannot move it later. Its users, sessions, applications, audit logs and signing keys stay in that region.

Before you start​

  • An organization in the EU region. On the sign-up page, choose European Union under Data region.
  • An API key of that organization, created in its portal under Applications & developer tools, API keys. An API key of a US organization does not work in the EU region.
  • The setup script registers an agent, "EU invoice archiver", and prints its client ID and secret.
VariableValue
LUMOAUTH_URLhttps://eu.app.lumoauth.dev, the address of the EU region. The programs use it when the variable is not set.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_API_KEYFor the setup script: an API key with the scopes admin:agents:read and admin:agents:write. The CLI script uses it too, and its check of the Admin API needs admin:settings:read.
AGENT_CLIENT_IDThe client ID of the agent. The setup script prints it.
AGENT_CLIENT_SECRETThe client secret of the agent. The setup script prints it once.

The setup script creates what the recipe needs, through the Admin API. You can run it again at any time.

node b2b/eu-region/setup.mjs
setup.mjs
// Registers the agent of this recipe in your organization, with a client ID
// and secret. The programs use it to get a token. Run it again at any time.
//
// LUMOAUTH_URL=https://eu.app.lumoauth.dev node b2b/eu-region/setup.mjs
//
// The API key needs the scopes admin:agents:read and admin:agents:write.
import { call, ensure, printEnv, url } from '../../_lib/admin.mjs';

const agent = await ensure('/admin/agents', (a) => a.name === 'EU invoice archiver', {
name: 'EU invoice archiver',
description: 'Stores the invoices of European customers in the EU region.',
identityType: 'client_secret',
capabilities: ['invoices:read'],
});

// LumoAuth shows a secret once, in the answer that creates it. On a second
// run the script therefore asks for a new secret, and the old one stops.
const secret =
agent.clientSecret ??
(await call('POST', `/admin/agents/${agent.agentId}/rotate-credentials`)).data.clientSecret;

console.log(`Agent "${agent.name}" is ready at ${url}.`);
printEnv({ AGENT_CLIENT_ID: agent.agentId, AGENT_CLIENT_SECRET: secret });

Code​

Each program reads the address from LUMOAUTH_URL and uses the EU address when the variable is not set. It passes the address to the SDK in the option for it: baseUrl in JavaScript, base_url in Python, BaseURL in Go, and LUMO_BASE_URL for the CLI.

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization. The programs ran against an organization at another address, which LUMOAUTH_URL named. They make the same requests to the EU address.

b2b/eu-region/js/region.mjs
// Points the agent SDK at the EU region, gets a token, and checks its issuer.
//
// node b2b/eu-region/js/region.mjs
import { LumoAgent, decodeJwt } from '@lumoauth/agent';

// The EU region has its own address. An organization exists in one region
// only, so the address and the organization belong together. The other
// clients take the same option: `baseUrl` in LumoAuthBackend and in
// @lumoauth/client.
const baseUrl = process.env.LUMOAUTH_URL ?? 'https://eu.app.lumoauth.dev';

// Reads LUMOAUTH_ORG_ID, AGENT_CLIENT_ID and AGENT_CLIENT_SECRET.
const agent = new LumoAgent({ baseUrl });
console.log(`server: ${baseUrl}`);

// The issuer of the token names the region that signed it.
const token = await agent.authenticate();
console.log(`issuer: ${decodeJwt(token).claims.iss}`);
node b2b/eu-region/js/region.mjs

Check the result​

Output
server: https://eu.app.lumoauth.dev
issuer: https://eu.app.lumoauth.dev/orgs/acme-corp/api/v1
  • The iss claim of every token of the organization starts with https://eu.app.lumoauth.dev. An API that checks the issuer accepts only tokens of this region.
  • In a browser app, the address goes into the domain prop of the provider. See Install the React components.
  • With the CLI, lumo login asks for the region. A profile keeps the address, so that one machine can work with an organization in each region.

Limits​

  • An organization cannot change its region. To move, create an organization in the other region and move the users and settings yourself.
  • Mail, text messages and AI requests can leave the region, depending on the providers that you choose. The data residency page lists each one, and what to set for a flow that stays in the EU.
  • Your own application must also keep its data in the EU. LumoAuth controls only the data that it stores.