Skip to the page

Guides · Integrations

Identity providers & sign-in events

Sign people in through Okta, Entra, Auth0 or Keycloak. Send sign-in email through your own mail provider and sign-up events to your own route.

API
—
In the schema
ext::auth::Identity

What you’ll build#

This guide connects your project’s sign-in to three services you already use. People sign in through a company’s identity provider, such as Okta, Microsoft Entra, Auth0 or Keycloak. Sign-in email goes out through your own mail provider, and your own route receives sign-up events so an analytics tool or CRM learns about each new person.

External OIDC issuers on one Identity model

Okta, Entra, Auth0 and Keycloak handshakes complete at /sign-in/callback and mint standard ext::auth::Identity sessions bound to global caller.

Each connection is a project setting and changes nothing in your schema. A signed-in person is still an ext::auth::Identity, and your rules still compare rows to global caller.

Before you start#

Sign-in for your app turns sign-in on and wires the client’s SignIn into an app. This page assumes you have finished that guide and set the app’s name and redirect addresses.

Sign people in through an identity provider#

oidc takes any OpenID Connect issuer. Register an application with the provider first, give the provider your project’s callback address and bring back the client id and secret.

Each OpenID Connect provider on the main branch is an SSO connection. A connection costs $30 a month, charged by the day. Google, GitHub, Microsoft, Discord and Slack are built in and carry no fee.

Callback address
https://<your project’s address>/sign-in/callback. The provider sends people back to that callback address and refuses any address the application does not list.
Application type
A web application that keeps a secret. The secret stays in your project and never reaches a browser.
Issuer
The address that serves /.well-known/openid-configuration. The table lists each provider’s issuer format.
ProviderIssuer
Oktahttps://<org>.okta.com, or a custom authorization server’s https://<org>.okta.com/oauth2/default
Microsoft Entrahttps://login.microsoftonline.com/<tenant-id>/v2.0
Auth0https://<tenant>.auth0.com
Keycloakhttps://<host>/realms/<realm>
Terminal
# The client's secret is read from NAPALM_CLIENT_SECRETnapalm sign-in provider notes oidc \  --issuer-url https://acme.okta.com \  --display-name "Acme" \  --slug acme \  --client-id <client-id> napalm sign-in show notes

A project holds any number of issuers, each with a unique --slug. Google, GitHub, Microsoft, Discord and Slack are built in and take a client id and secret. In the app, each added provider renders as one more sign-in button.

src/providers.ts
// src/providers.tsimport { signIn } from './napalm' /** The providers that are on, each with the name to sign in with and what to call it on its button. */export const providers = async () => (await signIn.metadata()).providers /** Leaves for the provider. It sends them back to /signed-in, where finish() ends the sign-in. */export async function signInWith(provider: string) {  location.assign(await signIn.providerUrl(provider, { redirectTo: `${location.origin}/signed-in` }))}

Provider tokens stay inside the project. Your app only ever holds the project’s session.

Write rules by identity provider#

Each identity records the issuer that authenticated the person, and access rules read it as (global caller).issuer. An organization can store its company issuer and admit anyone who signs in through it without an invitation. Multi-tenant B2B SaaS builds that rule.

Send sign-in email through your mail provider#

Confirmations, password resets and magic links go through the SMTP server you name. Every mail provider offers an SMTP server.

Terminal
# The password is read from NAPALM_SMTP_PASSWORDnapalm sign-in email notes \  --host smtp.resend.com \  --sender "Notes <sign-in@example.com>" \  --username resend # Now that mail can be sent, have people confirm their addressnapalm sign-in set notes --require-verification
ProviderHostPortUsernamePassword
Resendsmtp.resend.comPort465UsernameresendPasswordAn API key
Postmarksmtp.postmarkapp.comPort587, with --starttlsUsernameA server API tokenPasswordThe same token
Amazon SESemail-smtp.<region>.amazonaws.comPort465, or 587 with --starttlsUsernameSMTP credentials made in the SES consolePasswordThe credentials’ password
SendGridsmtp.sendgrid.netPort465UsernameapikeyPasswordAn API key
Sender
An address on a domain the provider has verified for you. Mail from any other domain is refused or lands in spam.
Without a server
Leave address confirmation off while you build. napalm status notes warns when confirmation is on and no mail server is set.

Send sign-in events to your route#

Subscribe an HTTPS endpoint with napalm sign-in webhooks add to receive JSON notifications whenever someone creates an account, signs in, verifies an address or requests a one-time token.

HMAC-signed sign-in event webhooks

Napalm signs every raw event body with HMAC-SHA256 in x-ext-auth-signature-sha256 under your NAPALM_SIGNING_KEY and delivers only to allowed hosts.

Terminal
# The route's host, if the branch keeps a list of allowed hostsnapalm webhooks hosts notes --add app.example.com # A key you make, which signs every event. It's read from NAPALM_SIGNING_KEY.napalm sign-in webhooks add notes https://app.example.com/hooks/sign-in \  --event IdentityCreated --event EmailVerified
EventSent whenFields besides the identity id
IdentityCreatedA new identity is created at sign-up.Fields besides the identity idNothing more
IdentityAuthenticatedSomeone signs in.Fields besides the identity idNothing more
EmailFactorCreatedAn identity gets an email address.Fields besides the identity idemail_factor_id
EmailVerifiedAn address is confirmed.Fields besides the identity idemail_factor_id
OneTimeCodeVerifiedA verification code, reset code or magic link code is used.Fields besides the identity idemail_factor_id, otc_id
EmailVerificationRequestedA verification link is requested.Fields besides the identity idemail_factor_id, verification_token
PasswordResetRequestedA password reset link is requested.Fields besides the identity idemail_factor_id, reset_token
MagicLinkRequestedA magic link is requested on a project that sends links.Fields besides the identity idemail_factor_id, magic_link_token, magic_link_url
OneTimeCodeRequestedA verification code, reset code or magic link code is requested.Fields besides the identity idemail_factor_id, otc_id, one_time_code
Sent once
Napalm does not resend a sign-in event when your route fails. Use events where a missed event is acceptable, like analytics. Create the rows a person needs with a query at first sign-in rather than from an event.
No addresses
An event names an identity by id and carries no email address or name.
Changing a destination
--replace <url> swaps one destination for another. The signing key cannot be read back, so pass the key again on every save.

Verify and handle events#

Verify x-ext-auth-signature-sha256 against the raw request bytes in constant time with crypto.subtle.verify before parsing JSON, since re-serializing a parsed body alters whitespace and breaks the digest.

An incoming event
POST /hooks/sign-in HTTP/1.1Content-Type: application/jsonx-ext-auth-signature-sha256: 5d41402abc4b2a76b9719d911017c592… {"event_type":"IdentityCreated","event_id":"6b1a7d8e-9f00-4a2b-8c4d-5e6f0192c3f4", "timestamp":"2026-11-10T08:00:00+00:00","identity_id":"8f2c1e64-0b7a-4f4e-9d2b-3a6c5e1f7d90"}
src/app/hooks/sign-in/route.ts
// src/app/hooks/sign-in/route.tsimport { analytics } from '@/lib/analytics' type SignInEvent = { event_type: string; event_id: string; timestamp: string; identity_id: string } /** Whether your project signed these bytes. The header is the body's HMAC-SHA256 under your key, in hex. */async function isFromSignIn(body: ArrayBuffer, signature: string | null) {  if (!signature || !/^[0-9a-f]{64}$/.test(signature)) return false  const key = await crypto.subtle.importKey(    'raw',    new TextEncoder().encode(process.env.NAPALM_SIGNING_KEY!),    { name: 'HMAC', hash: 'SHA-256' },    false,    ['verify'],  )  const signed = Uint8Array.from(signature.match(/../g)!, (pair) => parseInt(pair, 16))  // verify compares in constant time.  return crypto.subtle.verify('HMAC', key, signed, body)} export async function POST(request: Request) {  // The raw bytes. A body parsed and written again wouldn't match its signature.  const body = await request.arrayBuffer()  if (!(await isFromSignIn(body, request.headers.get('x-ext-auth-signature-sha256')))) {    return new Response(null, { status: 401 })  }  const event = JSON.parse(new TextDecoder().decode(body)) as SignInEvent  if (event.event_type === 'IdentityCreated') {    // The identity's id is the person's id in every rule and row of your project.    await analytics.track(event.identity_id, 'signed_up', { id: event.event_id, time: event.timestamp })  }  return new Response(null, { status: 204 })}

The header carries the body’s HMAC-SHA256 digest under your signing key as lowercase hex with no prefix. Sign-in events use a separate signature header from notify deliveries, which sign with Napalm-Signature.

Check the identity setup#

Verify the OIDC provider, outbound SMTP sender and signed webhook receiver end to end before opening sign-in to production users.

  1. List the settings

    napalm sign-in show notes lists the issuer by slug, the mail server status and each event destination with its subscribed events. No secret is shown.

  2. Sign in through the provider

    The app’s sign-in page shows the new button. Signing in through it lands on /signed-in with a session, and a query that selects (global caller).issuer returns the issuer’s address.

  3. Request a password reset

    The email arrives from your sender through your provider.

  4. Sign up as someone new

    Napalm calls your route once with IdentityCreated. Send the route a body with a wrong signature, and the route returns 401.

Sign-in documents the underlying routes. The Control API sets the same settings from code.

Type a word or two to search every docs page.