Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

jwt-filter-rules

This repository provides an example of how to generate and use JWT authentication tokens with filter rules and parameter values for ThoughtSpot APIs. This API allows administrators to generate a token with a specific set of rules and column filtering conditions that are applied when a user session is created.

Key Usage

// POST /api/rest/2.0/auth/token/custom
const response = await fetch(`${THOUGHTSPOT_HOST}/api/rest/2.0/auth/token/custom`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    username: "your-username",
    validity_time_in_sec: 300,
    password: "your-password",
    auto_create: true,
    // Apply row-level security: restrict to rows where Color = 'sky'
    filter_rules: [
      {
        column_name: "Color",
        operator: "IN",
        values: ["sky"],
      },
    ],
    // Pass parameter values for ThoughtSpot parameters
    parameter_values: [
      {
        name: "Secured",
        values: ["Default"],
      },
    ],
  }),
});
const { token } = await response.json();

File Structure

rest-api/jwt-filter-rules/ │── src/ │ ├── constants.ts # Configuration constants like ThoughtSpot host and credentials │ ├── index.ts # Express server handling API requests │ ├── index.html # Frontend UI for displaying generated tokens │── package.json # Dependencies and scripts │── README.md # Documentation

Demo

Open in Codesandbox

Documentation

Run locally

$ git clone https://github.com/thoughtspot/developer-examples
$ cd rest-api/jwt-filter-rules
$ npm i
$ npm run start

Technology labels

  • Typescript
  • NodeJS
  • Express