MutliTenancy for Cockpit

Dear all,

it would be great if there could be multiple tenants on one Cockpit installation.
Basically I mean that the data is seperated based on the login and the assigned tenant to the logged in user. This should also apply to the API of course.

If this is already possible, please let me know how I can achieve this.

2 Likes

+1 on this suggestion. I created a new user and i was expecting multiple tenants to be supported as in other platforms but sadly is not.

<?php $app->on('cockpit.bootstrap', function() { echo print_r($this->config, true); });

I made a folder inside addons, created a bootstrap.php and i got access to the config variables. I think it can be easy to override the local variables, detect if someone logged in and simple add a prefix for the logged in user to use another storage path.

2 Likes

create a defines.php in the root of the cockpit folder. this file will get always loaded first:

here you can define eg. a custom COCKPIT_ENV_ROOT based on e.g $_SERVER['SERVER_NAME'] to support multiple instances with one cockpit installation

Can i grab the session in there? To make it based on the logged in user?

I have not tried it but you should get the session id with
$session = session_id()

For me it would be more interesting to fetch the user?
Can this be done directly or do I need to get the token and then use this to fetch the user?

+1 for me but mine would be just grouping of servers into tenants, as an MSP we maintain a bunch of servers for different clients so it would be nice to be able to split these up into groups within the same cockpit server.

any ideas on how i would do this now?

@NeilCavendish Same here - wrong forum