mirror of
https://github.com/directus/directus.git
synced 2026-01-21 03:58:06 -05:00
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:
6
api/src/cli/commands/security/key.ts
Normal file
6
api/src/cli/commands/security/key.ts
Normal 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);
|
||||
}
|
||||
6
api/src/cli/commands/security/secret.ts
Normal file
6
api/src/cli/commands/security/secret.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export default async function generateSecret(): Promise<void> {
|
||||
process.stdout.write(nanoid(32));
|
||||
process.exit(0);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user