Deprecate generate-keys

This commit is contained in:
Benjamin Pracht
2026-02-10 16:54:12 -08:00
parent f201abedcc
commit eb0dacb88d
2 changed files with 28 additions and 3 deletions
+16 -3
View File
@@ -37,14 +37,27 @@ import (
"github.com/livekit/livekit-server/pkg/service"
)
func generateKeys(_ context.Context, _ *cli.Command) error {
func generateKeyFile(_ context.Context, c *cli.Command) error {
filename := c.String("key-file")
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600)
if err != nil {
return err
}
defer file.Close()
apiKey := guid.New(utils.APIKeyPrefix)
secret := utils.RandomSecret()
fmt.Println("API Key: ", apiKey)
fmt.Println("API Secret: ", secret)
file.WriteString(fmt.Sprintf("%s: %s", apiKey, secret))
return nil
}
func generateKeys(_ context.Context, _ *cli.Command) error {
return fmt.Errorf("DEPRECATED. Use generete-key-file instead")
}
func printPorts(_ context.Context, c *cli.Command) error {
conf, err := getConfig(c)
if err != nil {
+12
View File
@@ -144,6 +144,18 @@ func main() {
Usage: "generates an API key and secret pair",
Action: generateKeys,
},
{
Name: "generate-key-file",
Usage: "generates an API key and secret pair and write them to a key file",
Action: generateKeyFile,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "key-file",
Usage: "filename for the key file",
Required: true,
},
},
},
{
Name: "ports",
Usage: "print ports that server is configured to use",