đŸ› ī¸
Developer docs
Start BuildingGuides
  • ✨Getting Started
  • đŸŽ›ī¸Self Hosted Config
  • âœī¸SSO Login
    • Saml Identity Provider (Idp)
    • Oidc Identity Provider (Idp)
  • đŸŽžī¸Framework Specific Guide
    • âš›ī¸Reactjs
    • âš›ī¸Nextjs
    • âš›ī¸Vuejs
    • âš›ī¸Angular
    • âš›ī¸Svelte
    • âš›ī¸Solid
    • âš›ī¸Vanilla JS
  • â„šī¸Token
  • đŸ›ī¸Multi-Tenant Access Control
  • Embed using iFrame (Not Recommended approach)
  • 🔑License Key Validation for Self-Hosted App
  • Test
  • 👩‍đŸ’ģHelpers
    • âœŗī¸Token Body
    • ✅Options
      • Custom Fiscal Year filter setup in DataBrain
    • đŸˆ‚ī¸Server Event
    • Embed Functions
    • Override Language
    • âœˆī¸Embedding Architecture
    • âœˆī¸LLM Architecture
    • ✨LLM Connectors
      • Open AI
      • Claude AI
      • Azure Open AI
      • Llama
      • Mixtral
    • 🆔Dashboard ID
    • 🆔Metric ID
    • 🆔API Token
    • 🆔End User Metric Creation
    • Embedding APIs
      • Sync Datasource
  • Metric App Filter
  • Dashboard App Filter
  • Chat Mode
    • Step 1: Create Datamart and Workspace
    • Step 2: Create Data App and Embed ID
  • ✨Solutions Alchemy
    • Dashboards for Client Groups
    • Dashboard for Multiple Clients
    • Embedding: Role based Dashboard Filtering
    • Localized Currency Symbols
    • Manage Metrics
Powered by GitBook
On this page
  • How Our Row-Level Policies Work?
  • Guest Token
  • Example of Implementing a Row-Level Policy

Multi-Tenant Access Control

Tenancy and Organizational Configuration

For your multi-tenant database architectures, establish atomic access controls through row-level policies (Database Tenancy & Table Tenancy), configurable in the Client Settings of our data source settings.

How Our Row-Level Policies Work?

Set row-level policies for each table using your data source's SQL language.

DataBrain parses and applies these policies as Common Table Expressions (CTEs) during query generation. This step happens post-validation, just before sending the query to your database or warehouse.

This method ensures user-specific data access, e.g., User A sees only their data. You can also define and assign dynamic variables in your SQL queries during token creation.

Guest Token

For a user to view the embedded DataBrain dashboard in your application, your backend must request a guest token from DataBrain. This request is specific to the user and utilizes their userId or clientId.

Example request payload:

{ "clientId": "7807dcd1-1919-474b-aba7-7f23a062d02f" }

These identifiers are then injected into your row-level policies, tailoring the data returned to the user based on these parameters.

Example of Implementing a Row-Level Policy

To ensure each user only sees data relevant to them in a consumers table, you would set up a row-level policy and create a specific token. Here's how you can do it:

  1. Defining the Row-Level Policy for the Customers Table

Write a SQL query to define the policy:

SELECT * FROM consumers WHERE id = {client_id_variable}

This query ensures that each user only accesses rows in the customers table where their unique identifier matches the id column.

  1. Generating a Token

Use a curl command to generate a token for a specific user:

curl -X POST --location 'https://api.usedatabrain.com/api/v1/guest-tokens' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API-KEY>' \
--data '{ "clientId": "7807dcd1-1919-474b-aba7-7f23a062d02f" }'

This process combines secure access control with customized data visibility, aligning with user-specific requirements.

PreviousTokenNextEmbed using iFrame (Not Recommended approach)

Last updated 9 months ago

đŸ›ī¸