Auth
Choose a Microsoft Entra sign-in path for Rayfin apps: Fabric SSO, direct Entra token exchange, external embed host, and sessions.
Rayfin Auth gives your app managed Microsoft Entra sign-in, session handling, and token refresh.
After sign-in, client.data.* and client.functions.* calls use the authenticated context from the same client.auth instance.
Why use Rayfin Auth
- No separate identity provider to run — Rayfin Fabric apps use Microsoft Entra ID through Fabric SSO or delegated Entra token exchange.
- Pre-integrated SDK clients — once a session is installed on
client.auth, attached Rayfin clients send the authenticated context automatically. - Per-user data isolation — JWT claims drive row-level security policies declared on your entities. See Permissions.
- One session API —
getSession,onSessionChange,refreshSession, andsignOutwork the same way no matter which supported flow installed the session.
Choose an auth path
| Situation | Use | Where it runs |
|---|---|---|
| A browser app needs Fabric to perform interactive sign-in | Fabric SSO popup flow | Any origin in services.auth.allowedRedirectUris, including http://localhost:5173 during local frontend development. |
| A Rayfin app is loaded inside the Fabric portal iframe | Fabric SSO embedded flow | The Fabric portal iframe. The embedded flow requires the app to be loaded by Fabric. |
| A React app needs shared session state and route guarding | React integration | Browser UI code, using the same client.auth instance as the SDK client. |
| Browser or Node.js code already has a delegated Entra token | Direct Entra token sign-in | Browser or Node.js. Requires Rayfin 1.36 packages and externalEntraExchange: true. New in 1.36 |
| Your own portal embeds a Rayfin app in an iframe | External embed host | Parent portal page plus the embedded Rayfin app. Requires Rayfin 1.36 packages and externalEntraExchange: true. New in 1.36 |
| UI code needs to react to sign-in, sign-out, or refresh | Sessions | Any frontend code that can access client.auth. |
Microsoft Entra ID is the only supported identity provider for Rayfin Fabric apps. Do not add alternate sign-in UI to a new Rayfin app.
Note
The Fabric SSO popup flow works from a local dev server as long as the origin is listed in allowedRedirectUris, including http://localhost:5173.
Only the embedded iframe flow requires the app to be loaded inside the Fabric portal or by an external embed host.
Enable auth for browser apps
For Fabric SSO, enable the auth service and the Fabric provider in rayfin/rayfin.yml:
services:
auth:
enabled: true
allowedRedirectUris:
- http://localhost:5173
fabric:
enabled: trueRun npm run dev for the development loop.
Scaffolded projects run rayfin dev, which provisions or reuses the managed Fabric backend, applies auth settings, writes RAYFIN_PUBLIC_* values to rayfin/.env, maps them to framework variables such as VITE_FABRIC_ITEM_ID, then starts the frontend.
Use npx rayfin up when you want to deploy static hosting or update a deployed environment without starting the local frontend.
See Redirect URIs for what allowedRedirectUris controls.
Enable external Entra exchange
Direct Entra token sign-in and the external embed host call Rayfin's external brokered endpoints.
Add externalEntraExchange: true and deploy the setting before using those flows:
services:
auth:
enabled: true
fabric:
enabled: true
externalEntraExchange: trueThis opt-in is not needed for the normal Fabric SSO popup or Fabric iframe flows.
Use sessions after any flow
Every flow installs the same opaque session on client.auth.
Read only the documented fields and subscribe with onSessionChange:
const session = client.auth.getSession();
if (session.isAuthenticated && session.user) {
showApp(session.user);
}
const unsubscribe = client.auth.onSessionChange((nextSession) => {
console.log('Auth changed:', nextSession?.isAuthenticated ?? false);
});
// Later, for example on component unmount:
unsubscribe();See Sessions for refresh, sign-out, and lifecycle details.
In this section
- Fabric SSO — enable it, install the provider package, and call
initEmbeddedAuthplusensureSignedInWithFabric. - Direct Entra token sign-in — exchange an existing delegated Entra token for a Rayfin session. New in 1.36
- External embed host — broker sign-in for a Rayfin app embedded in your own portal. New in 1.36
- Sessions — the opaque session object,
onSessionChange, token refresh, and sign-out. - Delegated access — how Functions, connectors, and entity policies use signed-in identity or app identity.
- React integration — an auth context, a hook, local embedded startup, and route guarding.
In my Rayfin app, choose the correct Microsoft Entra auth flow and wire it up.
Use Fabric SSO with @microsoft/rayfin-auth-provider-fabric when my browser app needs Fabric to perform interactive sign-in. Keep http://localhost:5173 in services.auth.allowedRedirectUris for local frontend development, and use initEmbeddedAuth() at startup plus ensureSignedInWithFabric() from a button click.
If my code already has a delegated Entra access token, use signInWithEntraToken() instead and enable services.auth.fabric.externalEntraExchange: true in rayfin/rayfin.yml. If my own portal embeds the Rayfin app in an iframe, register createEmbedHost() in the parent before mounting the iframe and enable the same externalEntraExchange setting.
Use client.auth.getSession() and client.auth.onSessionChange(...) for UI state. Do not add alternate sign-in flows.Seeding data
Populate @anonymous() Rayfin entities with RayfinServerClient in a Node.js script — @authenticated() entities have no scripted seeding path today.
Fabric SSO
Sign users in with Microsoft Entra ID through Fabric SSO, using the popup flow for browser apps or embedded flow in the Fabric portal.