{"id":50564181,"url":"https://github.com/quarkiverse/quarkus-multitenancy","last_synced_at":"2026-06-07T16:01:01.476Z","repository":{"id":362054958,"uuid":"1255973671","full_name":"quarkiverse/quarkus-multitenancy","owner":"quarkiverse","description":"A fully decoupled Quarkus extension providing a generic tenant resolution API and request-scoped TenantContext, with pluggable resolvers for HTTP, JWT, cookies","archived":false,"fork":false,"pushed_at":"2026-06-05T04:49:01.000Z","size":324,"stargazers_count":5,"open_issues_count":7,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-06T15:24:43.656Z","etag":null,"topics":["java","microservices","multitenancy","quarkiverse","quarkus-extension","tenant-resolution"],"latest_commit_sha":null,"homepage":"https://docs.quarkiverse.io/quarkus-multitenancy/dev","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quarkiverse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-01T10:46:26.000Z","updated_at":"2026-06-05T22:05:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/quarkiverse/quarkus-multitenancy","commit_stats":null,"previous_names":["quarkiverse/quarkus-multitenancy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/quarkiverse/quarkus-multitenancy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quarkiverse%2Fquarkus-multitenancy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quarkiverse%2Fquarkus-multitenancy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quarkiverse%2Fquarkus-multitenancy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quarkiverse%2Fquarkus-multitenancy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quarkiverse","download_url":"https://codeload.github.com/quarkiverse/quarkus-multitenancy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quarkiverse%2Fquarkus-multitenancy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34027670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","microservices","multitenancy","quarkiverse","quarkus-extension","tenant-resolution"],"created_at":"2026-06-04T13:01:39.888Z","updated_at":"2026-06-07T16:01:00.733Z","avatar_url":"https://github.com/quarkiverse.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧩 Quarkus Multitenancy Extension\r\n\r\n[![Build](https://github.com/quarkiverse/quarkus-multitenancy/actions/workflows/build.yml/badge.svg)](https://github.com/quarkiverse/quarkus-multitenancy/actions/workflows/build.yml)\r\n[![Documentation](https://img.shields.io/badge/docs-Quarkiverse-blue)](https://docs.quarkiverse.io/quarkus-multitenancy/dev/)\r\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\r\n![Java](https://img.shields.io/badge/Java-21%2B-blue)\r\n![Quarkus](https://img.shields.io/badge/Quarkus-3.x-red)\r\n![Status](https://img.shields.io/badge/status-preview-orange)\r\n\r\n\u003e A modular, decoupled multitenancy extension for Quarkus  \r\n\u003e supporting HTTP tenant resolution, ORM integration, and future integrations.\r\n\r\nQuarkus Multitenancy is a Quarkiverse extension that provides a generic tenant resolution API and reusable building blocks for Quarkus applications.\r\n\r\nIt abstracts tenant identification logic away from any specific technology and exposes a consistent `TenantContext` that can be injected by application code or reused by integrations such as HTTP and ORM.\r\n\r\n## Why this exists\r\n\r\n- Quarkus already provides powerful building blocks such as OIDC multitenancy and Hibernate ORM multitenancy.\r\n- Applications still often need a consistent way to resolve and propagate the current tenant.\r\n- This extension provides a reusable tenant resolution layer across HTTP, ORM, and custom integrations.\r\n- It is now maintained as a Quarkiverse extension.\r\n\r\n---\r\n\r\n💡 Designed for REST microservices and backend modules, it can provide tenant resolution for HTTP requests, persistence, cache, messaging, or custom application layers.\r\n\r\n## 📌 About This Project\r\n\r\n**Quarkus Multitenancy** is an extension designed to standardize and simplify tenant resolution for Quarkus services. It provides a decoupled multi-layer architecture.\r\n\r\n- A core runtime module that defines `TenantResolver`, `TenantContext`, and tenant resolution contracts.\r\n- Independent HTTP, ORM, and deployment layers built on top of the core.\r\n- Built-in support for tenant resolution from headers, cookies, JWT claims, and request paths.\r\n\r\nThis makes the extension modular, lightweight, and framework-friendly, so you can plug tenant resolution into HTTP requests, ORM integrations, or custom application code.\r\n\r\n- Consistent tenant identification per request\r\n- Pluggable resolvers: header, cookie, JWT claim, path, and custom resolvers\r\n- Minimal boilerplate code\r\n- Integration point for datasources, caches, identity providers, and other tenant-aware components\r\n- Quarkiverse migration completed\r\n- First preview release preparation in progress\r\n\r\n---\r\n\r\n## 📚 Modules\r\n\r\n| Module | Description | Docs |\r\n|--------|-------------|------|\r\n| 🧠 **Core Runtime** | Defines `TenantContext`, `TenantResolver`, and tenant resolution contracts | [Read more →](quarkus-multitenancy-core-runtime/README.md) |\r\n| ⚙️ **Core Deployment** | Build-time Quarkus integration for core | [Read more →](quarkus-multitenancy-core-deployment/README.md) |\r\n| 🌐 **HTTP Runtime** | Resolves tenants from header, cookie, JWT claim, or path | [Read more →](quarkus-multitenancy-http-runtime/README.md) |\r\n| 🧩 **HTTP Deployment** | Registers HTTP tenant resolution support | [Read more →](quarkus-multitenancy-http-deployment/README.md) |\r\n| 🧱 **ORM Runtime** | Integrates tenant context with Hibernate ORM multitenancy use cases | [Read more →](quarkus-multitenancy-orm-runtime/README.md) |\r\n| ⚙️ **ORM Deployment** | Quarkus feature registration for ORM integration | [Read more →](quarkus-multitenancy-orm-deployment/README.md) |\r\n| 🧪 **Demo App** | PostgreSQL multi-tenant REST demo | [Read more →](quarkus-multitenancy-demo/README.md) |\r\n\r\n---\r\n\r\n# 🧠 Quarkus Multitenancy Core Runtime\r\n\r\nThe **core foundation** of the Quarkus Multitenancy extension.\r\n\r\nIt defines the base APIs used to resolve and propagate tenants across layers, from HTTP requests to ORM and custom application code.\r\n\r\n---\r\n\r\n## 🚀 What It Does\r\n\r\nThis module provides:\r\n\r\n- The **`TenantContext`** – a request-scoped CDI bean exposing the active tenant.\r\n- The **`TenantResolver`** – an interface for resolving tenant identifiers dynamically.\r\n- The **`TenantResolution`** contract – a three-state result model: `Resolved`, `NotApplicable`, and `Rejected`.\r\n- The **`CompositeTenantResolver`** – allows multiple resolvers such as header, JWT, cookie, or path to cooperate.\r\n\r\n---\r\n\r\n## 🧩 Tenant-Aware Isolation\r\n\r\nUsing this module together with the HTTP and ORM runtimes, each incoming request can be associated with a resolved tenant identifier.\r\n\r\n✅ Each request can carry a tenant identifier, for example `X-Tenant: tenant1`.  \r\n✅ The active tenant is exposed through `TenantContext`.  \r\n✅ The ORM runtime can use the resolved tenant to route persistence operations.  \r\n✅ Actual database isolation depends on how the application configures Hibernate ORM, datasources, schemas, or databases.\r\n\r\nFor example:\r\n\r\n| Request | Header | Tenant Resolved |\r\n|----------|---------|----------------|\r\n| `GET /api/users` | `X-Tenant: tenant1` | `tenant1` |\r\n| `GET /api/users` | `X-Tenant: tenant2` | `tenant2` |\r\n\r\nThis means the extension provides the tenant resolution layer. The application remains responsible for configuring the actual persistence isolation model.\r\n\r\n---\r\n\r\n## ⚙️ Required Dependencies\r\n\r\nTo enable HTTP tenant resolution:\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n    \u003cgroupId\u003eio.quarkiverse.multitenancy\u003c/groupId\u003e\r\n    \u003cartifactId\u003equarkus-multitenancy-http\u003c/artifactId\u003e\r\n    \u003cversion\u003e${quarkus-multitenancy.version}\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\nTo enable ORM integration:\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n    \u003cgroupId\u003eio.quarkiverse.multitenancy\u003c/groupId\u003e\r\n    \u003cartifactId\u003equarkus-multitenancy-orm\u003c/artifactId\u003e\r\n    \u003cversion\u003e${quarkus-multitenancy.version}\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\nReplace `${quarkus-multitenancy.version}` with the latest released version once the first preview release is published.\r\n\r\n---\r\n\r\n## 💡 Example Usage\r\n\r\n```java\r\nimport io.quarkiverse.multitenancy.core.runtime.context.TenantContext;\r\nimport jakarta.inject.Inject;\r\nimport jakarta.ws.rs.GET;\r\nimport jakarta.ws.rs.Path;\r\n\r\n@Path(\"/tenant\")\r\npublic class TenantResource {\r\n\r\n    @Inject\r\n    TenantContext tenantContext;\r\n\r\n    @GET\r\n    public String getTenant() {\r\n        return tenantContext.getTenantId().orElse(\"NO TENANT FOUND\");\r\n    }\r\n}\r\n```\r\n\r\nWhen you send:\r\n\r\n```bash\r\ncurl -H \"X-Tenant: tenant1\" http://localhost:8080/tenant\r\n```\r\n\r\nOutput:\r\n\r\n```text\r\ntenant1\r\n```\r\n\r\n| Layer | Module | Responsibility |\r\n|------|--------|----------------|\r\n| **HTTP Runtime** | `quarkus-multitenancy-http` | Resolves tenant per HTTP request |\r\n| **ORM Runtime** | `quarkus-multitenancy-orm` | Connects ORM layer to tenant context |\r\n\r\nTogether, they provide tenant-aware request handling and persistence integration in Quarkus.\r\n\r\n---\r\n\r\n## 🔐 JWT Tenant Resolution\r\n\r\nThe JWT strategy resolves the tenant from a claim in a **verified bearer token**.\r\n\r\nApplications must configure SmallRye JWT or Quarkus OIDC before enabling the `jwt` strategy.\r\n\r\nExample:\r\n\r\n```properties\r\nquarkus.multi-tenant.http.strategy=jwt\r\nquarkus.multi-tenant.http.jwt-claim-name=tenant\r\n\r\nmp.jwt.verify.publickey.location=publicKey.pem\r\nmp.jwt.verify.publickey.algorithm=RS256\r\nmp.jwt.verify.issuer=https://my-issuer.example.com\r\n```\r\n\r\nOIDC can also be used as the verification source:\r\n\r\n```properties\r\nquarkus.oidc.auth-server-url=https://issuer.example.com\r\n```\r\n\r\nNamed OIDC tenants are also supported:\r\n\r\n```properties\r\nquarkus.oidc.customer.auth-server-url=https://customer-issuer.example.com\r\n```\r\n\r\nIf a bearer token is present but cannot be verified, or if the configured tenant claim is missing, non-string, or blank, the request is rejected with HTTP 401 and does not fall back to the default tenant.\r\n\r\n---\r\n\r\n## 🚦 Resolution Outcomes\r\n\r\nTenant resolution uses a three-state result contract:\r\n\r\n| Outcome | Meaning |\r\n|---------|---------|\r\n| `Resolved` | A resolver successfully resolved a tenant identifier |\r\n| `NotApplicable` | The resolver had no input to process, so the next strategy may be tried |\r\n| `Rejected` | The resolver found invalid input and the request must be rejected |\r\n\r\nThis distinction is important for security.\r\n\r\nFor example, a missing bearer token can be `NotApplicable`, but a malformed or unverifiable bearer token is `Rejected` and must not silently fall back to `defaultTenant`.\r\n\r\n---\r\n\r\n## 🚀 Quick Start\r\n\r\n```bash\r\nmvn clean install\r\ncd quarkus-multitenancy-demo\r\nmvn quarkus:dev\r\n```\r\n\r\nTo test the demo, import the `demo.postman_collection.json` file into Postman.\r\n\r\n---\r\n\r\n## 🧭 Architecture Overview\r\n\r\n```text\r\n[HTTP Request]\r\n     ↓\r\n[HTTP TenantResolver] (header/JWT/cookie/path)\r\n     ↓\r\n[TenantContext] (request-scoped)\r\n     ↓\r\n[ORM / Application / Custom Integration]\r\n```\r\n\r\n👉 See the `quarkus-multitenancy-demo` README for full setup with Docker, PostgreSQL, Postman, and sample tenants.\r\n\r\n---\r\n\r\n## 📖 Documentation\r\n\r\nFull documentation is available at:\r\n\r\n```text\r\nhttps://docs.quarkiverse.io/quarkus-multitenancy/dev/\r\n```\r\n\r\n---\r\n\r\n## 📄 License\r\n\r\nThis project is licensed under the Apache License 2.0.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquarkiverse%2Fquarkus-multitenancy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquarkiverse%2Fquarkus-multitenancy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquarkiverse%2Fquarkus-multitenancy/lists"}