Using Redash as Muti-Tenant application

Hello There,

We need some information on if we can use current Redash opensource app as Multi tenant app. Where everything would be separated between multiple tenant accounts. (Similar to what was being provided on Redash cloud hosted app which is getting discontinued next month)

What might be the quick way to achieving the same? we need the same for some of our internal departments

The features are there but not documented as they were designed quite specific to the needs of app.redash.io.

What are your requirements for multi-tenant behaviour?

1 Like

For anyone interested: here’s how I got multi-tenant to behave as expected on OSS.

Mind you: this is very rough. Do not think you will do this without some manual wrangling in the database. It’s completely as-is.

Approach

You need to set the environment variable REDASH_MULTI_ORG to "true".

OSS Redash doesn’t have handlers for creating new organizations. So to create a new org and begin using it, you need to duplicate the existing org and set some new values. The default organization is created when you first start Redash.

Once you’ve created a new organization you’ll also need a user who can log-in. And before a user can log-in they will need to be present in a group. So here’s the approach.

SQL Statements

-- ## QUERY 1
-- Use this query to copy the default organization
INSERT INTO organizations (
  updated_at,
  created_at,
  name,
  slug,
  settings
)
SELECT
  updated_at,
  created_at,
  <new organisation name>
  <new organisation slug>,
  settings
FROM
  organizations WHERE id = 1

-- After you insert this organization there should be a new org
-- on the organizations table. SELECT its `id` as you will need 
-- it in the subsequent queries.

-- ## QUERY 2
-- Use the following query to clone the built-in definitions to
-- your new or new organisation, yielding two new ids.
INSERT INTO groups (
  "org_id",
  "type",
  "name",
  "permissions",
  "created_at"
)
SELECT
  <new org id from query 1>,
  "type",
  "name",
  "permissions",
  now()
FROM
  groups WHERE id in (1,2)

-- QUERY #3
-- Finally, you can duplicate an admin user from the default org
-- to your newly created one.

INSERT INTO users (
  updated_at,
  created_at,
  org_id,
  name,
  email,
  password_hash,
  groups,
  api_key,
  details
)
SELECT
  updated_at,
  created_at,
  <new org id from query 1>,
  name,
  email,
  password_hash,
  ARRAY <two new ids from query 2>,
  'abcd',
  details
FROM
  users WHERE id = 1

Now you can log-in to your new organization using the same email and password as your base user on the default org. You should do so and reset the API key from the profile screen, set a new password etc.