doodle/cmd/doodle-admin/command/key.go
Noah Petherbridge 0449737607 License Key Registration with ECDSA JWT Tokens
* New command-line tool: doodle-admin for signing license keys for
  users. Includes functions to initialize a keypair, sign license keys
  and validate existing keys.
* The Main Menu screen shows a blue "Register Game" button in the bottom
  right corner of the screen, for unregistered users only.
* In Edit Mode, there is a "Help -> Register" menu item that opens the
  License Window.
* The License UI Window lets the user select the license.key file to
  register the game with. If registered, a copy of the key is placed in
  Doodle's profile directory and the licensee name/email is shown in the
  License UI window.
* Unregistered games will show the word "(shareware)" next to the title
  screen version number and Edit Mode status bar.
* No restrictions are yet placed on free versions of the game.
2021-06-16 21:56:30 -07:00

45 lines
1009 B
Go

package command
import (
"git.kirsle.net/apps/doodle/pkg/license"
"git.kirsle.net/apps/doodle/pkg/log"
"github.com/urfave/cli/v2"
)
// Key a license key for Sketchy Maze.
var Key *cli.Command
func init() {
Key = &cli.Command{
Name: "key",
Usage: "generate an admin ECDSA signing key",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "public",
Usage: "Filename to write the public key to (.pem)",
Required: true,
},
&cli.StringFlag{
Name: "private",
Usage: "Filename to write the private key to (.pem)",
Required: true,
},
},
Action: func(c *cli.Context) error {
key, err := license.AdminGenerateKeys()
if err != nil {
return cli.Exit(err.Error(), 1)
}
err = license.AdminWriteKeys(key, c.String("private"), c.String("public"))
if err != nil {
return cli.Exit(err.Error(), 1)
}
log.Info("Written private key: %s", c.String("private"))
log.Info("Written public key: %s", c.String("public"))
return nil
},
}
}