* feat: support token blacklist, Close T-799 * feat: clean * fix: possible token does not exist * fix: update * feat: update * feat: add node-cron to delete expired token * fix: findOrCreate not work and add test case * test: add token-blacklist tests * feat: add test cases for blacklist in authManager * test: update better * fix: should hidden token field * test: clean * test: clean * fix: should stop cron in afterStop * refactor: move delete expired token in token blacklist service * feat: remove plugin disable/enable logic * fix: clean * test: revert * fix: cron typo
88 lines
1.8 KiB
TypeScript
88 lines
1.8 KiB
TypeScript
import type { CollectionOptions } from '@nocobase/database';
|
|
|
|
export default {
|
|
namespace: 'api-keys',
|
|
duplicator: 'optional',
|
|
name: 'apiKeys',
|
|
title: '{{t("API keys")}}',
|
|
sortable: 'sort',
|
|
model: 'ApiKeyModel',
|
|
createdBy: true,
|
|
updatedAt: false,
|
|
updatedBy: false,
|
|
logging: true,
|
|
fields: [
|
|
{
|
|
name: 'id',
|
|
type: 'bigInt',
|
|
autoIncrement: true,
|
|
primaryKey: true,
|
|
allowNull: false,
|
|
interface: 'id',
|
|
},
|
|
{
|
|
type: 'string',
|
|
name: 'name',
|
|
interface: 'input',
|
|
uiSchema: {
|
|
type: 'string',
|
|
title: '{{t("name")}}',
|
|
'x-component': 'Input',
|
|
},
|
|
},
|
|
{
|
|
interface: 'obo',
|
|
type: 'belongsTo',
|
|
name: 'role',
|
|
target: 'roles',
|
|
foreignKey: 'roleName',
|
|
uiSchema: {
|
|
type: 'object',
|
|
title: '{{t("Roles")}}',
|
|
'x-component': 'Select',
|
|
'x-component-props': {
|
|
fieldNames: {
|
|
label: 'title',
|
|
value: 'name',
|
|
},
|
|
objectValue: true,
|
|
options: '{{ currentRoles }}',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: 'expiresIn',
|
|
type: 'string',
|
|
interface: 'select',
|
|
uiSchema: {
|
|
type: 'string',
|
|
title: '{{t("Expires")}}',
|
|
'x-component': 'Select',
|
|
enum: [
|
|
{
|
|
label: '{{t("1 day")}}',
|
|
value: '1d',
|
|
},
|
|
{
|
|
label: '{{t("7 days")}}',
|
|
value: '7d',
|
|
},
|
|
{
|
|
label: '{{t("30 days")}}',
|
|
value: '30d',
|
|
},
|
|
{
|
|
label: '{{t("90 days")}}',
|
|
value: '90d',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
name: 'token',
|
|
type: 'string',
|
|
hidden: true,
|
|
},
|
|
],
|
|
} as CollectionOptions;
|