package main import ( "flag" "github.com/pborman/uuid" ) // nolint:gochecknoglobals var ( createKeyCmd = false getPublicKeyCmd = false createTokenCmd = false verifyTokenCmd = false debug = false keyFile string tokenFile string tokenIssuer string tokenPeerID = uuid.New() keySize = 2048 ) // nolint:gochecknoinits func init() { flag.BoolVar( &createKeyCmd, "create-key", createKeyCmd, "Create a new encrypted PEM private key to sign authentication tokens", ) flag.BoolVar( &createTokenCmd, "create-token", createTokenCmd, "Create a new signed authentication token", ) flag.BoolVar( &verifyTokenCmd, "verify-token", verifyTokenCmd, "Verify a token generated with the given key", ) flag.BoolVar( &getPublicKeyCmd, "get-public-key", getPublicKeyCmd, "Get the PEM encoded public key associated with the private key", ) flag.BoolVar(&debug, "debug", debug, "Debug mode") flag.StringVar(&keyFile, "key", keyFile, "Path to the encrypted PEM encoded key") flag.StringVar(&tokenFile, "token", tokenFile, "Path to the token to verify") flag.StringVar(&tokenIssuer, "token-issuer", tokenIssuer, "Token issuer") flag.StringVar(&tokenPeerID, "token-peer-id", tokenPeerID, "Token peer ID") flag.IntVar(&keySize, "key-size", keySize, "Size of the private key") } func main() { flag.Parse() switch { case createKeyCmd: createKey() case getPublicKeyCmd: getPublicKey() case createTokenCmd: createToken() case verifyTokenCmd: verifyToken() default: flag.Usage() } }