Use your secrets manager and sync client secrets
Let LumoAuth read credentials from your secrets manager, and push the client secret of a new or rotated application to the place where your app is deployed.
What it shows
- You connect a secrets manager. Integrations of LumoAuth can then hold a
secret://reference in place of a credential, and LumoAuth reads the value when it uses it. - You add a deploy target: GitHub Actions in this recipe. Vercel, Netlify and Doppler work the same way.
- You regenerate the client secret of an application in the portal, and push it to the deploy target with one click.
- A workflow in your repository gets a token with the synced credentials. Nobody copied the secret by hand.
Before you start
- An account at a secrets manager: 1Password Connect, Doppler, Infisical, AWS Secrets Manager, CyberArk Conjur, or HashiCorp Vault or OpenBao with a KV v2 engine. Its address must be a public HTTPS host.
- A GitHub repository, and a fine-grained personal access token with Secrets: write on it.
- The permission
settings.managein the portal for managers and targets, andclients.editfor the sync. Adding a manager or a target asks for your password again. - An application with a client secret. The setup script creates "Acme deploy check", which may use the client credentials grant. It does not print the secret. Its API key needs
admin:clients:readandadmin:clients:write.
| 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_API_KEY | For the setup script only: an API key with the scopes admin:clients:read and admin:clients:write. |
LUMO_CLIENT_ID | The client ID of the application. The sync writes it to your deploy target, and the setup script prints it. |
LUMO_CLIENT_SECRET | The client secret of the application. Only the sync writes it: no step of the recipe shows it to you. |
The setup script creates the application "Acme deploy check" through the Admin API. It does not print the client secret. You can run it again at any time.
node operations/secrets-managers/setup.mjs
setup.mjs
// Creates the application "Acme deploy check", which a deploy pipeline uses
// with the client credentials grant. Run it again at any time.
//
// node operations/secrets-managers/setup.mjs
//
// The API key needs the scopes admin:clients:read and admin:clients:write.
import { ensure, org, printEnv, url } from '../../_lib/admin.mjs';
const app = await ensure('/admin/clients', (c) => c.name === 'Acme deploy check', {
name: 'Acme deploy check',
description: 'Gets a token from a deploy pipeline, to check the synced credentials.',
grantTypes: ['client_credentials'],
});
// The answer of the create call holds the client secret once. The script
// does not print it: you sync a new secret to your deploy target instead.
console.log(`Application "${app.name}" is ready.`);
console.log(`Open it in the portal, rotate its secret and sync it: ${url}/orgs/${org}/portal/applications`);
printEnv({ LUMO_CLIENT_ID: app.clientId });
Connect a secrets manager
- Open Integrations in the portal, then Secrets & developer sync.
- Under Secrets managers, choose your manager in the list, for example HashiCorp Vault / OpenBao KV, and click Add manager.
- Enter a Name and a Slug. The slug is the part after
secret://in a reference, for examplesecret://vault/lumoauth/prod#twilio_auth_token. - Enter the connection, for example the Vault address and an API token that may only read the paths that LumoAuth needs.
- Under Purposes, turn on Resolve secret:// references, and enter the references that integrations may read under Reference allow-list, one on each line. A line can end with
*, as inlumoauth/prod#*. An empty list resolves nothing. - Click Add secrets manager, then Test connection.
- In an integration that accepts references, enter the reference in place of the credential, for example the Auth token of the SMS provider.
Push the client secret to GitHub Actions
- On the same page, under Deploy targets, choose GitHub Actions and click Add target.
- Enter the Repository owner, the Repository and the API token. Leave Environment empty to write repository secrets.
- Click Add deploy target, then Test connection. The test checks the token without writing anything.
- Open Applications, then "Acme deploy check", the tab Credentials. Click Regenerate, then Regenerate secret, and enter your password when the portal asks for it.
- The page Client secret regenerated shows the card Sync credentials to a deploy target. Choose your target, keep the prefix
LUMO, and click Sync credentials…. - The repository now has the secrets
LUMO_CLIENT_IDandLUMO_CLIENT_SECRET. Add the variablesLUMOAUTH_URLandLUMOAUTH_ORG_IDunder Settings, Secrets and variables, Actions.
These steps were written from the docs. Nobody has followed them for this page yet. The portal steps that need a secrets manager or a deploy target were not followed: they need an account there. The regenerate step and the token request ran against an organization.
Code
The script gets a token with the two values that the sync writes. The workflow runs it in GitHub Actions.
Run each command from the recipes folder of the examples repository. Set the folder up once for your language. The portal steps that need a secrets manager or a deploy target were not followed: they need an account there. The regenerate step and the token request ran against an organization.
- curl
- GitHub Actions
#!/bin/sh
# Get a token with the client credentials that LumoAuth synced to your deploy
# target. LUMO_CLIENT_ID and LUMO_CLIENT_SECRET are the names that the sync
# writes. The script prints no part of the token.
#
# sh operations/secrets-managers/http/token.sh
#
# The script needs curl and jq.
set -eu
ANSWER=$(curl --silent --show-error --fail-with-body \
"$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/api/v1/oauth/token" \
--user "$LUMO_CLIENT_ID:$LUMO_CLIENT_SECRET" \
--data grant_type=client_credentials) || {
# An old secret, after a rotation, answers 401 invalid_client.
printf '%s\n' "$ANSWER" >&2
exit 1
}
printf '%s\n' "$ANSWER" | jq -r --arg id "$LUMO_CLIENT_ID" '"token for \($id): \(.token_type), expires in \(.expires_in) s"'
sh operations/secrets-managers/http/token.sh
Run against a LumoAuth organization.
# Check from GitHub Actions that the client credentials that LumoAuth synced
# to this repository work. Copy this file to .github/workflows/ and
# http/token.sh to scripts/token.sh.
#
# LumoAuth writes the secrets LUMO_CLIENT_ID and LUMO_CLIENT_SECRET. Add the
# variables LUMOAUTH_URL and LUMOAUTH_ORG_ID yourself.
name: Check LumoAuth credentials
on:
workflow_dispatch:
push:
branches: [main]
jobs:
token:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get a token with the synced credentials
env:
LUMOAUTH_URL: ${{ vars.LUMOAUTH_URL }}
LUMOAUTH_ORG_ID: ${{ vars.LUMOAUTH_ORG_ID }}
LUMO_CLIENT_ID: ${{ secrets.LUMO_CLIENT_ID }}
LUMO_CLIENT_SECRET: ${{ secrets.LUMO_CLIENT_SECRET }}
run: sh scripts/token.sh
Compiles. Not run against an organization. The workflow passed actionlint, and its script ran on a local machine with a secret that the portal had just regenerated. No deploy target received it, and the workflow did not run on GitHub Actions.
Check the result
token for client_cb139be6c94780279d569dfdac98f095: Bearer, expires in 3600 s
- Run the workflow Check LumoAuth credentials in GitHub. Its step prints the same line.
- Regenerate the secret again and sync it. The old secret stops working at once: a run with it answers
401 invalid_client. The next run reads the new value. - The secret appears on the page Client secret regenerated only, and LumoAuth stores no copy of it in plain text.
Limits
- LumoAuth only reads from a secrets manager. It does not write a new client secret into the manager. Doppler is the one manager that can also be a deploy target.
- The sync button exists only on the pages that show a new client secret: after you create an application in the portal, and after you regenerate its secret. A secret that the Admin API returns is not synced.
- The sync writes the credentials of applications. Agent credentials are not synced.
- A credential field that sends its value as it is, such as a webhook signing secret or the client secret of a sign-in connection, refuses a
secret://reference. The docs list where references work. - A reference is resolved each time that it is used. When the manager cannot be reached, the call that needs the credential fails, and LumoAuth never sends the reference text instead.