Automatic Login
Use a signed embed session to log the same person into the hosted portal from your product.
Automatic login takes the identity you already send to the widget or embed and starts a hosted portal session for that same person.
Workspace owners and admins can also use this path when their workspace explicitly enables it. End-customer automatic login keeps its existing behavior. This does not replace workspace SSO.
What it solves
Widget and embed sessions already know userId, email, and name. Opening your-workspace.boarbs.com used to treat that visitor as a guest.
Automatic login closes that gap. The same signed embed session can:
- create a portal end-user if one does not exist
- start a portal session for that person
- keep votes, comments, and posts attached to the same email
How it works
- Your backend creates an embed session with an organization API key. That is the same
POST /api/embed/sessionscall used by the widget and iframe embed. - The response includes
sessionTokenandportalLoginUrl. - Send people to the hosted portal with
?sso=SESSION_TOKEN, or let the widget attach that parameter to portal links. - Boarbs validates the session and identity, checks the additional rules for workspace admins, and sets a portal session cookie.
The token is the existing embed session token. The identity fields are the same shape you already send: userId, email, firstName, lastName, and avatarUrl.
1. Create the signed session on your backend
Never create the session in browser code. Keep the API key on the server.
const response = await fetch("https://YOUR_BOARBS_DOMAIN/api/embed/sessions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BOARBS_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
boardId: process.env.BOARBS_BOARD_ID,
userId: user.id,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
avatarUrl: user.avatarUrl,
company: { id: "account-123", name: "Acme Inc." },
mrr: { amount: 149.99, currency: "USD" },
expiresInSeconds: 604800,
}),
});
const { sessionToken, portalLoginUrl } = await response.json();email is required for automatic login. Boarbs uses it to create or find the portal user. Keep sending a stable userId as well so widget and embed identity stay consistent.
2. Link to the hosted portal
Use the returned portalLoginUrl, or append sso to any portal deep link:
https://your-workspace.boarbs.com/?sso=SESSION_TOKEN
https://your-workspace.boarbs.com/roadmap?sso=SESSION_TOKEN
https://your-workspace.boarbs.com/p/post-slug?sso=SESSION_TOKENTreat these URLs like credentials. Prefer short expiresInSeconds values when you put the token in a query string.
3. Widget links
If the widget is identified with sessionToken, it attaches sso to links that point at the widget origin (your workspace portal).
window.Boarbs.init({
workspace: "acme",
sessionToken,
});
// Build a portal URL yourself:
const roadmapUrl = window.Boarbs.portalUrl("/roadmap");The widget iframe also stores the session in a cookie on the workspace domain. Visiting the portal on that same host can reuse the cookie when ?sso= is missing.
Automatic login for workspace admins
An owner or admin must first enable Allow admin automatic login in Settings → General → Portal Settings. It defaults off. Only owners and admins using a normal signed-in workspace session can change it; an API key cannot enable it.
Create the embed session through the same backend endpoint and pass the admin’s email. The API key must belong to the same workspace as both the board and the admin’s owner/admin membership. Admins must belong to exactly one workspace. Plain members, members of another workspace, and platform admins are refused. Existing sessions created before this feature have no issuer information and cannot log in admins; create a new session.
For admin logins, explicitly set expiresInSeconds to 600 or less (for example 300). The default is still 30 days for end customers, so omitting this field will not work for an admin. The session’s entire lifetime from creation to expiry must be at most 10 minutes; presenting a longer-lived token soon after creation does not qualify it. The opaque session token is generated cryptographically on the server. Never accept an email supplied by an untrusted browser as proof of admin identity.
Use the returned portalLoginUrl or the same ?sso=SESSION_TOKEN links above. An embed session can be exchanged for an admin login once, including when requests arrive at the same time. Generate a fresh short-lived session for the next login. Admin login does not change the admin’s profile or membership, and sends no email.
The resulting authentication session expires after 10 minutes and cannot refresh to the normal session lifetime. Its exchange cookie is host-only, HttpOnly, SameSite=Lax, and Secure in production.
Permission limitation: this installation uses the same Better Auth account session for portal and workspace access. This is not a portal-only authorization boundary: anyone who can obtain and use the issued session can exercise that admin’s existing account permissions in the single workspace during those 10 minutes, including dashboard/API access. Enabling the feature therefore trusts holders of that workspace’s API keys with this short-lived access. Keep the setting off unless that is acceptable.
Rejected logins return sso_error on the portal redirect:
admin_auto_login_disabled: the workspace has not enabled admin automatic login.admin_token_lifetime: the embed credential has a total lifetime above 10 minutes or invalid creation timing.admin_token_used: the embed session has already been exchanged for an admin login.admin_impersonation: the account does not meet the role or single-workspace rules.org_mismatch: the portal, board, or API-key issuer workspace does not match.invalid_token: the token is unknown or expired.login_failed: the exchange could not be completed; no credential details are returned.
Longer-lived and reusable end-customer sessions keep working as before. SAML/OIDC and additional identity fields are separate features.
What automatic login will not do
- It will not sign in plain workspace members, admins of a different workspace, admins with memberships in multiple workspaces, or platform admins.
- It will not create a team membership or give end customers
/appaccess. Admin sessions retain the account permissions described above. - It will not accept a session with no email.
- It will not accept a session that belongs to a different workspace.
If the token is missing, expired, or refused, the visitor stays a guest on the public portal.
Security notes
- create sessions only on your server
- never put the Boarbs API key in browser code
- enable admin automatic login only when you trust every holder of your workspace API keys
- prefer HTTPS in production
- strip
ssofrom analytics and server logs when you can
This is not SAML or OIDC. Those remain out of scope for this flow.
Next steps
- Embed — Create the session used by both the iframe and automatic login
- Widget — Identify the user inside your product
- Portal — Where the hosted session is used
- Deep Links — Add
ssoto a specific post or roadmap URL - Permissions and Visibility — End-users vs team members
Company and monthly recurring revenue
POST /api/embed/sessions accepts optional company and mrr objects:
company.nameis required whencompanyis supplied;company.idis optional. Both must be strings of 1–200 characters.mrr.amountmust be a finite number from0to1000000000, with at most two decimal places.mrr.currencyis an uppercase ISO-4217 currency code and defaults toUSD.- Invalid values return HTTP
400. Unknown properties inside either object are rejected. Null is not an omission.
Company and MRR are team-only: workspace members see them in the portal users list and beside post authors and voters. Public portals, widget post details, comments, votes, and browser-facing session responses do not include them. Keep the API key and this customer context on your backend.
Customer profile sync requires email. Identity-only sessions keep their existing behavior. Immediately after an embed session is created with company or mrr, Boarbs attempts one server-side customer sync. Page loads, widget identification, navigations, and refreshes do not repeat it. Automatic login continues to sync the stored customer context. A supplied company or MRR replaces that person's existing value in this workspace. Omitting either object preserves its existing value. A company supplied without id replaces the name and clears the previous company ID. Zero MRR is a supplied value. Amounts are stored as integer hundredths of the currency unit and formatted for the workspace viewer's locale; no currency conversion is performed. Session-creation sync skips workspace members and does not create a login cookie or grant workspace membership. If that sync fails, Boarbs logs a generic message without the payload and still returns the session. Automatic login can sync the stored context later.