Allow setting Store Id per request for multi tenant implementations
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 54
- Forks
- 26
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 9
Description
Describe the problem you'd like to have solved
In multitenant solutions it would be nice to have a single client instance and the possibility to set the store id for each request, this way the connection pool can be reused without the need to have multiple client instances.
Describe the ideal solution
The store id should available as a client option:
var request = new ClientCheckRequest()
.user("user:81684243-9356-4421-8fbf-a4f8d36aa31b")
.relation("writer")
._object("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a");
var options = new ClientCheckOptions()
.additionalHeaders(Map.of("Some-Http-Header", "Some value"))
// You can rely on the model id set in the configuration or override it for this specific request
.authorizationModelId("01GXSA8YR785C4FYS3C0RTG7B1")
// SET THE STORE ID PER REQUEST
.storeId("01ARZ3NDEKTSV4RRFFQ69G5FAV");
var response = fgaClient.check(request, options).get();
// response.getAllowed() = true
Alternatives and current workarounds
There are two alternatives:
- Having one client for each store id
- Explicitly calling
fgaClient.setStoreId(store.getId());on each request, but my guess is there could be race condition issues
Additional context
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the fgaClient.check(request, options) entry point and the ClientCheckOptions API shown in the issue. Determine how the configured store ID is currently selected and how request options are propagated. Done means a request can override the configured store ID without mutating shared client state, while existing configuration behavior remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, authorization, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100