I'm working on a custom cube.js
database driver that uses a private http service which accepts arbitrary, raw sql and returns the result as json.
The http service uses Authorization
header to identify the user (so that it can enforce appropriate access controls).
I was looking for ways in which I can pass cube.js
security context to the driver.
I tried steps mentioned in their multi-tenancy document, specifically the Multiple Schema and Drivers one.
It only works the first time where I'm able to access the security context in the driverFactory()
callback. There I initialise the new driver instance with the user's token in securityContext
.
For subsequent calls though (event with different user!), cube.js
reuses the same instance. And this is the cause of the problem. I cannot reuse driver between different application users.
Is there a way to solve this? Or am I not implementing multi-tenancy correctly here?