Skip to main content
Discuss your project
Blog

Laravel/

Single sign-on for multiple web apps: why one login hub is worth it

Why a business with several web apps should use one SSO hub: one login for users, easier onboarding and offboarding, and how it works in Laravel.

Ajay Kumar

Ajay Kumar

Web Developer

Once a business runs more than one web app, the same people end up with more than one login. Each new hire gets added to every app by hand, and each leaver has to be removed from every app by hand. A single sign-on hub fixes that, and it is how we run our own products.

In short

  • If the same people log into more than one of your own web apps, put those apps behind a single sign-on hub. Users sign in once. You add, change or remove access in one place, instead of in every app.
  • The usual pattern is a central identity app that holds the user list and the roles, with each product registered as a client of that hub. In Laravel, you can build the hub with Laravel Passport, Laravel's official OAuth2 server.
  • Our internal tools and customer-facing products share one Passport hub and one role system, so nobody maintains a separate login in each app. When a role changes, the hub pushes the latest entitlements out to every connected app.
  • A hub is extra software to host and keep updated, and if it is down, nobody gets into any of the connected apps. It is not worth building if you only have one custom app, or if the other tools are SaaS products that already offer "Sign in with Google" or Microsoft.
A glass shield with a keyhole stands on a round base in the middle, with lines running out to five glass browser windows around it. Four lines are lit; the fifth, to a grey window, is dim.

Who this is for

This comes up once a business has more than one login. A founder has an internal tool and a customer portal, and staff are already juggling two passwords. An agency's client has a booking app, an admin area and a dashboard, and someone has to add each new person to all three, by hand, every time.

We had the same problem. Each of our internal apps had its own login. We now run a single Laravel Passport hub in front of them, with one login and a shared role system.

The internal apps on that hub include Forge, our prototype builder (our own tool, not Laravel Forge), Lens, which we use to screen prospects, a CRM, and billing. Customer-facing products use the same hub, including Noctora, our monitoring product.

The rest of this post is for a founder or an agency deciding whether to do the same for a set of web apps they own. It covers how the pattern works in Laravel, what changes for users and for whoever manages access, the real costs and failure modes, and when we would tell you not to build it.

What a single SSO hub actually does

A single sign-on hub is one place that proves who someone is and which of your apps they may use. Each app still does its own job. It just stops keeping its own private list of passwords.

In practice it looks like this:

  1. The user opens one of your apps. If they have no session at the hub yet, the app sends them there to sign in.
  2. They sign in once, at the hub. The hub sets a session on its own domain.
  3. The hub sends them back to the app with a short-lived authorization code. The app exchanges that code for tokens, then starts its own local session.
  4. When they open a second app, that app also sends them to the hub. The hub already knows who they are, so it does not ask for a password again.
  5. Roles come from the same central system. Each app reads those roles and enforces its own permissions, meaning what that person can see and change inside that product.

A hub is not a shared cookie across all your domains, and it is not a password manager that types a different password into each site. Each app keeps its own session. The shared part is the identity and the roles.

It is also not, on its own, an accessibility project. When we say this setup makes access easier, we mean one login and roles managed in one place. That is a convenience and an operations change. Meeting the WCAG rules for accessible login forms is separate work on the login page itself.

How single sign-on works in Laravel

OpenID Connect is the usual standard for this pattern. It is an identity layer on top of OAuth 2.0. The hub is the authorization server. Each of your apps is a client, sometimes called a relying party.

Laravel's official package for the hub side is Passport. Passport gives you a full OAuth2 server with client registration, the authorization code flow, token issue and refresh, and token revocation. That is what our hub runs on.

Laravel's docs are clear about when not to use it. If you only need to authenticate one single-page app, a mobile app, or API tokens for a single product, they point you to Sanctum instead. Sanctum does not implement OAuth2. A hub that several apps trust is exactly the case for Passport.

Each Laravel product registers with the hub as its own client, with its own client ID, secret and redirect URL. When a user hits a protected page, the app sends them to the hub's /oauth/authorize endpoint, then posts the returned code to /oauth/token. This is the authorization code flow in the Passport docs. The app then starts a normal Laravel session and reads the shared role system to decide what that user can do.

A few details matter when you scope this:

  • Register each app as a separate client, so redirect URLs and audit trails stay distinct.
  • Keep the user list in one directory, on the hub. Do not let each app become another source of truth for names, emails and whether an account is active.
  • We run one role-based access control system that every connected app reads. The hub answers who the person is and what their role is. The app still decides what that role may do on a given screen.
  • Decide logout in writing. Signing out of one app can clear only that app's session, sign the user out of the hub too, or try to end every app session at once. Teams usually underestimate the third option.
  • Passport's access tokens last one year by default, according to the current docs. For a hub you will almost certainly want a shorter lifetime, and a way to revoke a token when someone leaves.

Laravel Socialite is a client. It helps an app sign users in through an external provider. You might use something like it in each product to talk to your Passport server, but it cannot be the server itself.

The part that caught us out was entitlements. When we updated a role at the hub, how fast would that change reach every connected app? Waiting for the user's next login was too slow, so we built a webhook-based entitlement system that pushes the latest role and entitlement data to the apps.

The sketch below shows the idea. It is not our production code. A connected app receives a POST when the hub has new entitlements for a user, and stores them locally.

// Illustrative only. Not our production code.
Route::post('/entitlements/webhook', function (Request $request) {
    $payload = $request->validate([
        'user_id' => 'required|string',
        'roles' => 'required|array',
    ]);

    Entitlement::updateOrCreate(
        ['hub_user_id' => $payload['user_id']],
        ['roles' => $payload['roles']]
    );

    return response()->noContent();
});

A real endpoint also has to prove the request came from the hub, for example by checking a signature. We left that out of the sketch on purpose.

What changes for users, and for whoever manages access

For users, the change is simple. There is one login. They are not keeping one password for the CRM, another for billing and another for the prototype tool. If you turn on multi-factor authentication, you turn it on once, at the hub, rather than hoping every app implemented it the same way.

CISA's guidance on strong authentication makes the security case. Password reuse means one stolen password can open more than one system, and no technical control stops someone reusing a password across apps that each have their own login. A hub also lets you revoke access in one place when an account should no longer work. That is the main reason to do this. The faster second login is a bonus.

For whoever runs the apps, onboarding and offboarding stop being a tour of admin screens. You create a new teammate once and give them roles in the shared system, and the connected apps pick that up. When someone leaves, you remove or change their roles at the hub. The same entitlement webhooks push that change to every connected app, so nobody has to remember to edit the billing login by hand.

This is also why agencies ask about it. Say a client has several tools you built under a white-label arrangement, and one of their staff leaves. The client should not have to email you to remove that person from each tool. With a hub, it is the client's own admin task, on one screen. The same goes for recovering access after a developer leaves: it is much easier when every login lives in one directory you control.

What this costs, and what can go wrong

You are adding a product. The hub needs its own hosting, backups, monitoring and Laravel upgrades, like any other app. You have to change each existing product so that it trusts the hub instead of its own users table. Then you have to match existing accounts to the new directory, which is usually the slow, careful part.

Our own Passport hub took 2 to 3 months to get live and to move the first apps onto it.

Plan for the failure modes too.

If the hub is down, nobody signs into any connected app. That is the trade you make, so treat the hub as production infrastructure, not an internal side project.

Logout and session length will confuse people if you do not decide them on purpose. A user who signs out of one app and finds they are still signed in elsewhere will think something is broken. Role changes are a different problem, which is why we push them to the apps with webhooks rather than waiting for the next login.

Global roles can surprise you as well. A role name that makes sense in the CRM may be too broad in billing. The shared system only helps if someone owns the role list and reviews it whenever a new app joins.

Hosted identity products such as Auth0, Clerk and Cognito exist so you do not have to run a hub yourself, and Google Workspace and Microsoft 365 come with SSO. The hosted products usually charge per monthly active user, and they are often the right answer when most of the "apps" are third-party SaaS. Our hub is a Passport app in our own Laravel codebase, with a role system we control. That fits a set of apps you own. It is not the right default for every client.

When we would not recommend this

Do not build a single sign-on hub if you only have one custom web app. Laravel's built-in authentication is enough, or Sanctum for a single-page app talking to its own API. A hub would be a second system with no second app to justify it.

Do not build one to sit in front of SaaS tools that already support "Sign in with Google" or Microsoft. Use that. The hub in this post is for web apps you own, where you can register each one as a client and share a role system.

Do not build one if nobody can keep it running. It sits in front of every connected app, so a neglected hub is worse than a slightly annoying set of separate logins.

And do not expect a hub to fix a messy permission model. If each app already has ad hoc admin flags that mean different things, moving them into one place without cleaning them up just centralises the mess.

If you are unsure which side of this you are on, count the apps the same people log into, and count how often you add or remove someone. Two or more apps and a regular stream of joiners and leavers is usually enough to justify a hub. One app, or a set of third-party tools that already have SSO, is not.

What to do next

If you have more than one web app, or you are an agency whose client does, and you want a Passport hub of your own, tell us what those apps are. We build this for clients as well as running it on our own products. The work starts with a free review, then a fixed quote before anyone writes code. We will also tell you if you should keep ordinary Laravel authentication, or use the SSO you already pay for in Google or Microsoft.

New custom web applications can be designed for this from the start. For apps already in production, it is a change to authentication in each one, not a rewrite. If you also need those apps to talk to a CRM, accounting tool or payment provider, that is a separate integration job.

Sources