Path: blob/master/src/packages/util/db-schema/auth.ts
1447 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Table } from "./types";6import { SCHEMA as schema } from "./index";78Table({9name: "remember_me",10fields: {11hash: {12type: "string",13pg_type: "CHAR(127)",14},15value: {16type: "map",17},18account_id: {19type: "uuid",20},21expire: {22type: "timestamp",23},24},25rules: {26primary_key: "hash",27durability: "soft", // dropping this would just require a user to login again28pg_indexes: ["account_id"],29},30});3132Table({33name: "auth_tokens",34fields: {35auth_token: {36type: "string",37pg_type: "CHAR(24)",38},39account_id: {40desc: "User who this auth token grants access to become",41type: "uuid",42render: { type: "account" },43},44expire: {45type: "timestamp",46render: { type: "timestamp", editable: false },47},48created: {49desc: "When this auth token was created",50type: "timestamp",51render: { type: "timestamp" },52},53created_by: {54desc: "User who created the auth token.",55type: "uuid",56render: { type: "account" },57},58is_admin: {59desc: "True if wser who created the auth token did so as an admin.",60type: "boolean",61},62},63rules: {64primary_key: "auth_token",65},66});6768Table({69name: "crm_auth_tokens",70rules: {71virtual: "auth_tokens",72primary_key: "auth_token",73user_query: {74get: {75admin: true, // only admins can do get queries on this table76fields: {77account_id: null,78expire: null,79created: null,80created_by: null,81is_admin: null,82},83},84},85},86fields: schema.auth_tokens.fields,87});888990