Skip to content

Portal

A portal is an application a client runs for its own customers. Those customers are portal identities (ptu_...): a population separate from platform users, with no roles, client access or API access. The platform proves who they are; what they mean to your portal (organisation, portal role) is your data, keyed by the identity id. The model is in Portal identity and the language-neutral walk-through in Build a portal. This page covers the Laravel half.

Once per portal, on the platform: create a portal app (this also provisions its portal OAuth client and returns the client id and, for a confidential client, a secret shown once), and a service account holding the platform:portal-administrator role for the backend’s user management calls. Details are in Build a portal.

FLOWCATALYST_BASE_URL=https://your-platform.example.com
# Browser login through the portal plane
FLOWCATALYST_OIDC_ENABLED=true
FLOWCATALYST_OIDC_CLIENT_ID=<portal OAuth client_id>
FLOWCATALYST_OIDC_CLIENT_SECRET=<secret>
FLOWCATALYST_OIDC_PORTAL=true
# Backend access for portal-user management
FLOWCATALYST_CLIENT_ID=<service account client id>
FLOWCATALYST_CLIENT_SECRET=<service account secret>

With FLOWCATALYST_OIDC_PORTAL=true the login route (/flowcatalyst/login) redirects to /portal/authorize instead of /oauth/authorize. The callback and token exchange are unchanged. provider and client settings are ignored in portal mode: the platform’s portal login page routes organisation identity providers from the email domain. The portal plane never touches the platform session, so every portal login is a fresh authentication. There are no refresh tokens; when your session ends, send the user back through the login route.

The id_token’s sub is the portal identity id. FlowCatalystUser exposes the portal claims:

Method Claim
getPortalAppCode() portal_app_code (for an app-linked OAuth client)
getPortalAppId() portal_app_id
getPortalClientId() portal_client_id (the operating client)

The roles claim is empty by design, and the access token is deliberately useless for platform APIs.

Implement your own OidcUserHandler to check that the identity belongs to your portal and to start your session. Leave FLOWCATALYST_NATIVE_LOGIN off: the database handler’s local-user upsert targets platform employees, not portal identities.

use FlowCatalyst\Auth\Contracts\OidcUserHandler;
use FlowCatalyst\Auth\DTOs\FlowCatalystUser;
final class PortalUserHandler implements OidcUserHandler
{
public function handleAuthenticatedUser(FlowCatalystUser $user): mixed
{
// $user->sub is the portal identity id (ptu_...): your join key.
$memberships = OrgMembership::where('identity_id', $user->sub)->get();
if ($memberships->isEmpty()) {
abort(403, 'No portal access. Ask your administrator for an invite.');
}
session()->put('portal_user', [
'id' => $user->sub, 'email' => $user->email, 'name' => $user->name,
]);
return $user;
}
public function handleLogout(): void { session()->flush(); }
public function getPostLoginRedirect(): string { return '/'; }
public function getPostLogoutRedirect(): string { return '/'; }
}
// AppServiceProvider::register()
$this->app->bind(OidcUserHandler::class, PortalUserHandler::class);

Give the portal its own session cookie name (SESSION_COOKIE=portal_session) and deploy it on its own hostname. A sibling subdomain of the platform is fine; the same hostname is not.

The generated client carries the full admin surface. Get it with FlowCatalyst::generated(); calls use the service account.

use FlowCatalyst\Facades\FlowCatalyst;
use FlowCatalyst\Generated\Model\{PortalUserClientBody, PortalUserRequest};
$api = FlowCatalyst::generated();
// Invite (idempotent). With returnInviteLink the platform sends nothing and
// returns the set-password URL for your own mailer.
$result = $api->ensurePortalUser((new PortalUserRequest())
->setClientId($clientId)
->setEmail('pat@customer.example')
->setName('Pat Jones')
->setPortalAppCode('customer-portal')
->setReturnInviteLink(true)
->setRedirectUri('https://portal.example.com/auth/entry'));
$result->getIdentityId(); // ptu_...
$result->getCreated();
$result->getInviteUrl(); // a live bearer credential: never log it
$result->getSsoManaged(); // true when the email domain belongs to an identity provider
$list = $api->listPortalUsers(['clientId' => $clientId, 'q' => 'pat', 'portalAppCode' => 'customer-portal']);
$body = (new PortalUserClientBody())->setClientId($clientId);
$api->deactivatePortalUser($identityId, $body);
$api->activatePortalUser($identityId, $body);
$api->deletePortalUser($identityId, ['clientId' => $clientId]);

Behaviour worth knowing, all enforced by the platform:

  • ensurePortalUser is idempotent. It reactivates a suspended identity and re-sends the invite while the identity has no password yet; identities that can already sign in are left alone.
  • portalAppCode grants that app (other grants are untouched) and picks the OAuth client for the invite’s default redirect.
  • redirectUri must match a registered redirect URI of one of the client’s portal OAuth clients. When omitted it defaults to the portal’s origin.
  • For an email domain owned by an identity provider there is no set-password step; the response carries ssoManaged: true and the invite URL is the portal login destination.
  • The list is paged (default 100 rows, maximum 1000); total tells you when to continue. state is INVITED, INVITE_EXPIRED, ACTIVE or SUSPENDED.
  • Delete is offboarding from every portal of the client. In your own application, remove your membership row and end the session first, then delete the platform identity.

App grants and portal apps are covered by the same client:

use FlowCatalyst\Generated\Model\{CreatePortalAppRequest, PortalUserAppGrantBody};
$api->grantPortalUserApp($identityId, (new PortalUserAppGrantBody())
->setClientId($clientId)->setPortalAppCode('supplier-portal'));
$api->revokePortalUserApp($identityId, 'supplier-portal', ['clientId' => $clientId]);
$api->listPortalApps(['clientId' => $clientId]);
$api->createPortalApp((new CreatePortalAppRequest())
->setClientId($clientId)->setCode('customer-portal')->setName('Customer portal')
->setRedirectUris(['https://portal.example.com/flowcatalyst/callback']));

updatePortalApp, deletePortalApp and assignUnassignedPortalUsers complete the set. All credential UX (login page, invites, forgot-password) is hosted by the platform; the portal builds none of it.

A suspended identity, or one without the app grant, comes back on your redirect URI as error=access_denied; the callback sends the user to FLOWCATALYST_ERROR_REDIRECT. Admin calls throw the generated client’s exceptions (HTTP errors from the platform: 403 without the portal-administrator role, 404 for an unknown identity). The HTTP shapes are in the portal user API reference.

Test the gate by calling your OidcUserHandler with a constructed FlowCatalystUser; no login is needed. See Testing.