Skip to main content

See It in a Sample App

Wayfinder Enterprise is the reference implementation for B2B SaaS applications: a corporate travel app that runs the journeys of this section against ThunderID. Companies register themselves, their admins set travel policies and manage their team, and employees sign in with a password or through their company's own identity provider to book flights.

The Companies​

The walkthroughs use two companies, each an organization unit (OU) beneath the platform organization, Wayfinder Enterprise:

text
Wayfinder Enterprise            the platform organization: the app, its roles, flows and user type
├── Northstar Labs a company whose employees sign in with passwords
└── Initech a company whose employees sign in through Initech's own identity provider

The application, its two roles (Wayfinder Admin and Wayfinder Member), and its sign-in flow are defined once in Wayfinder Enterprise and shared with every company, so a company works the moment it signs up.

Architecture​

The sample is one Next.js app. Its pages sign people in through ThunderID with @thunderid/nextjs, and its API routes serve bookings and travel policies keyed by the company in the access token. The admin pages manage ThunderID resources through the app's own /api/admin route, which pins every call to the admin's company and forwards it with a backend client's token for that company.

A user's token carries only the app's own permissions, never a ThunderID management permission. See Let Organization Admins Manage Teams for why the admin calls go through a backend route.

Get the Sample​

Download the sample above, or copy its source:

bash
npx degit thunder-id/samples/b2b/wayfinder-enterprise wayfinder-enterprise
cd wayfinder-enterprise

Import the Bundle​

The fastest way to create the resources the walkthroughs need. First, get ThunderID running; then import two files through the Console, in this order:

  1. Generate a client secret for each of the two applications, for example with openssl rand -base64 32, and set them as WAYFINDER_ENTERPRISE_CLIENT_SECRET and WAYFINDER_ENTERPRISE_BACKEND_CLIENT_SECRET in thunderid-config/thunderid.env. The file ships without them, and the Console does not import it until both are set. Keep the values for the app's .env.local.
  2. Sign in to the Control Plane console at https://localhost:8095/console.
  3. Choose Import / Export, then Import. Upload thunderid-config/organization-unit.yaml as the configuration file. It needs no environment file. Choose Continue, and once the import test passes, choose Import configuration.
  4. Choose Import / Export, then Import again. Upload thunderid-config/thunderid-config.yaml as the configuration file and thunderid-config/thunderid.env as the environment variables file, to provide the variables the YAML references. Choose Continue, then Import configuration. A secret you left empty can be entered in the Environment variables editor before you import.

The Console tests each import before it runs it, and that test only finds an organization unit that already exists. The second file places every resource in the organization unit the first one creates, so import the first one on its own.

What the Import Creates​

ResourceNameWhat it does
Organization unitWayfinder Enterprise (wayfinder-enterprise)The platform organization, a root organization unit in the Default project. Every company that signs up becomes its child.
User typeWayfinder User (wayfinder-user)The account schema, with self-registration on. Owned by the platform organization, so every company can use it.
Resource serverWayfinder Enterprise API (urn:wayfinder-enterprise:api)The app's own permissions, for bookings, travel policies, and the admin pages
Server configdefaultResourceServerMakes the Wayfinder Enterprise API the default resource server
RolesWayfinder Admin, Wayfinder MemberShared with every company. An admin manages the company; a member books within its travel policy.
FlowWayfinder Enterprise Company Sign-upCreates the company, creates its first admin inside it, and assigns Wayfinder Admin
FlowWayfinder Enterprise Sign-inPassword, enterprise single sign-on (SSO), or company registration. Shared with every company, and each company sets its own enterpriseIdp.
Theme and layoutWayfinder, Wayfinder CenteredThe look of the sign-in and sign-up screens
ApplicationWayfinder EnterpriseThe app's confidential client, with the organization and role claims in its tokens. Shared with every company.
Application and roleWayfinder Enterprise BackendA client_credentials client for the app's admin route, shared with every company

The other defaults in thunderid.env work as they are for a local setup.

Configure the Sample​

Copy the environment template:

bash
cp .env.example .env.local

The other defaults match the import. In .env.local, set THUNDERID_CLIENT_SECRET and WAYFINDER_BACKEND_CLIENT_SECRET to the client secrets you set in thunderid.env, and THUNDERID_SECRET to a long random string; the SDK encrypts the session cookie with it. Generate one with:

bash
openssl rand -base64 32

The app calls ThunderID from its server. A local ThunderID uses a self-signed certificate, so point NODE_EXTRA_CA_CERTS at the certificate the running server uses before you start the app. With the quickstart image, that is the Data Plane's certificate:

bash
export NODE_EXTRA_CA_CERTS=<thunderid-home>/dp/config/certs/server.cert

Run the Sample​

From the sample directory, install dependencies and start the app:

bash
npm install
npm run dev

The sample opens at http://localhost:3000.

Walkthroughs​

After the sample is running, follow a journey through it:

Next Steps​

  • Build a smaller B2B app from scratch with the React or Next.js B2B quickstart, including switching between organizations.
  • Review the Design Decisions behind the pattern.

Explore with AI

ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.