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:
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:
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:
- Generate a client secret for each of the two applications, for example with
openssl rand -base64 32, and set them asWAYFINDER_ENTERPRISE_CLIENT_SECRETandWAYFINDER_ENTERPRISE_BACKEND_CLIENT_SECRETinthunderid-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. - Sign in to the Control Plane console at
https://localhost:8095/console. - Choose Import / Export, then Import. Upload
thunderid-config/organization-unit.yamlas the configuration file. It needs no environment file. Choose Continue, and once the import test passes, choose Import configuration. - Choose Import / Export, then Import again. Upload
thunderid-config/thunderid-config.yamlas the configuration file andthunderid-config/thunderid.envas 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
| Resource | Name | What it does |
|---|---|---|
| Organization unit | Wayfinder Enterprise (wayfinder-enterprise) | The platform organization, a root organization unit in the Default project. Every company that signs up becomes its child. |
| User type | Wayfinder User (wayfinder-user) | The account schema, with self-registration on. Owned by the platform organization, so every company can use it. |
| Resource server | Wayfinder Enterprise API (urn:wayfinder-enterprise:api) | The app's own permissions, for bookings, travel policies, and the admin pages |
| Server config | defaultResourceServer | Makes the Wayfinder Enterprise API the default resource server |
| Roles | Wayfinder Admin, Wayfinder Member | Shared with every company. An admin manages the company; a member books within its travel policy. |
| Flow | Wayfinder Enterprise Company Sign-up | Creates the company, creates its first admin inside it, and assigns Wayfinder Admin |
| Flow | Wayfinder Enterprise Sign-in | Password, enterprise single sign-on (SSO), or company registration. Shared with every company, and each company sets its own enterpriseIdp. |
| Theme and layout | Wayfinder, Wayfinder Centered | The look of the sign-in and sign-up screens |
| Application | Wayfinder Enterprise | The app's confidential client, with the organization and role claims in its tokens. Shared with every company. |
| Application and role | Wayfinder Enterprise Backend | A 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:
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:
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:
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:
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.