Tasukaru Healthcare: Multi-Tenant Auth from Single-Company Software
Tasukaru’s healthcare platform served one company well. We turned it into multi-tenant SaaS by rebuilding authentication and authorization (identity, tenancy and permissions) without rewriting the product from scratch.
- Service
- Software Solutions
- Industry
- Healthcare & Social Care
- Region
- Japan
Outcomes
- Single-company app productized into multi-tenant SaaS
- Tenant isolation enforced on every protected request
- Facility-scoped logins without username collisions
Stack
Ory Kratos · Ory Keto
Written byAbdullah Chaudhary
Tasukaru built healthcare software that their own organization already relied on every day. The workflows were proven. The domain logic was paid for in real usage. What they needed next was commercial: sell that same system to other facilities as a multi-tenant product, without cloning servers per customer or risking cross-facility data leaks.
Oriental Nippon partnered with Tasukaru on the control plane that makes that shift possible. This case study focuses on authentication and authorization only: how we took single-tenant identity assumptions and replaced them with a SaaS-grade tenant boundary.
For the general patterns behind this work, see the companion article: Authentication and Authorization When Productizing SaaS.
Starting point: one company, fragile auth assumptions
Tasukaru’s application worked well for a single organization:
| Problem | Impact |
|---|---|
Plain login IDs (admin, reception) with no tenant baked in | Same username can exist across customers, creating collisions |
| “You are in the app” ≠ “You are in this facility” | No tenant boundary enforcement in the application logic |
| App-level roles, no shared policy engine | Permissions hardcoded and scattered; hard to audit |
| Shared parent-domain cookies leak across hosts | A valid session does not mean a safe tenant |
Result: The product invited accidental cross-tenant access the moment a second paying facility came online.
What we changed: identity + authorization for many facilities
We kept the healthcare product Tasukaru’s teams already trusted, and replaced the fragile auth layer with a multi-tenant control plane built on Ory Kratos (identity) and Ory Keto (authorization).
| Layer | Before | After |
|---|---|---|
| Identity (Ory Kratos) | Plain login ID, single org | Compound ID {branchid}:{loginid}; identity traits carry the branch |
| Tenant address | One shared host | Subdomain (when enabled) fixes the facility before login |
| Session check | “Is the cookie valid?” | Valid session and traits.branch matches the request subdomain |
| Permissions (Ory Keto) | Ad-hoc / app-local roles | Central RBAC on every protected path |
| Downstream trust | Client or session guesses | Gateway injects trusted user + branch headers after authz passes |
The key difference: Login resolves the branch first (from the hostname, or via a public lookup on the root domain), then creates a Kratos browser flow and submits the compound identifier. After login, every API call hits an internal authz step that asks Kratos who is this? and Keto are they allowed?, and rejects the request if the session’s branch does not match the subdomain on the wire.
The request flow on Tasukaru
On the multi-facility platform, each facility can live on its own subdomain, authenticate through Ory Kratos, and stay isolated from every other facility, even when cookies live on a shared parent domain.
Mental model we shipped
| Layer | Role | Tool | Decision |
|---|---|---|---|
| 1. Tenant resolution | Where are they coming from? | URL hostname | tokyo.example.com → tenant tokyo |
| 2. Identity | Who are they? | Ory Kratos | Session for tokyo:admin with branch trait |
| 3. Tenant match | Are they in the right place? | Auth gateway | Does session.branch == URL tenant? |
| 4. Permissions | What can they do? | Ory Keto | tokyo:admin can GET /reports? |
| 5. Trust handoff | Who do we tell downstream? | Injected headers | API receives X-Tenant: tokyo as truth |
Rules we enforced on Tasukaru:
- Tenant = facility (branch).
- URL (subdomain) chooses the tenant before login when enabled.
- Kratos login uses tenant-scoped identity:
branchid:loginid. - Every API request re-checks session validity, branch match, and Keto permission.
- Downstream services trust server-injected headers only.
Outcome
Tasukaru kept their healthcare domain product. Facilities can onboard as tenants on one codebase. Isolation is architectural: cookies alone never decide which customer’s data you see.
If you have a single-company system ready to sell as SaaS, the same auth and authorization control plane is where we start. Contact Oriental Nippon to talk through your stack.
Related blog
From Internal Users to SaaS Customers: Rebuilding Auth for Multi-Tenancy
