Add "security" commands to api CLI (#9400)

* add command to generate app key

* add command to generate secret

* group security commands under the security group

* add new security commands to cli docs

* add disclaimer on deploy secret generation

* remove duplicate hubspot embed code

* remove .env overwrite feature to security commands

* update the cli docs for security commands

* return key generation directly in output

* restore package-lock.json

* Write secret directly

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Danilo Polani
2022-07-20 22:44:35 +02:00
committed by GitHub
parent 931a7bde46
commit 8b116f6deb
3 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import { v4 as uuidv4 } from 'uuid';
export default async function generateKey(): Promise<void> {
process.stdout.write(uuidv4());
process.exit(0);
}

View File

@@ -0,0 +1,6 @@
import { nanoid } from 'nanoid';
export default async function generateSecret(): Promise<void> {
process.stdout.write(nanoid(32));
process.exit(0);
}

View File

@@ -7,6 +7,8 @@ import count from './commands/count';
import dbInstall from './commands/database/install';
import dbMigrate from './commands/database/migrate';
import init from './commands/init';
import keyGenerate from './commands/security/key';
import secretGenerate from './commands/security/secret';
import rolesCreate from './commands/roles/create';
import usersCreate from './commands/users/create';
import usersPasswd from './commands/users/passwd';
@@ -30,6 +32,11 @@ export async function createCli(): Promise<Command> {
program.command('start').description('Start the Directus API').action(startServer);
program.command('init').description('Create a new Directus Project').action(init);
// Security
const securityCommand = program.command('security');
securityCommand.command('key:generate').description('Generate the app key').action(keyGenerate);
securityCommand.command('secret:generate').description('Generate the app secret').action(secretGenerate);
const dbCommand = program.command('database');
dbCommand.command('install').description('Install the database').action(dbInstall);
dbCommand