Skip to content
Snippets Groups Projects
setup.go 557 B
Newer Older
Gabriel Zachmann's avatar
Gabriel Zachmann committed
package main

import (
	"io/ioutil"
Gabriel Zachmann's avatar
Gabriel Zachmann committed
	log "github.com/sirupsen/logrus"
	"github.com/zachmann/mytoken/internal/config"
Gabriel Zachmann's avatar
Gabriel Zachmann committed
	"github.com/zachmann/mytoken/internal/jws"
Gabriel Zachmann's avatar
Gabriel Zachmann committed
	loggerUtils "github.com/zachmann/mytoken/internal/utils/logger"
Gabriel Zachmann's avatar
Gabriel Zachmann committed
)

func main() {
	config.LoadForSetup()
Gabriel Zachmann's avatar
Gabriel Zachmann committed
	loggerUtils.Init()
	sk, _, err := jws.GenerateKeyPair()
	if err != nil {
		log.Fatal(err)
	}
	str := jws.ExportPrivateKeyAsPemStr(sk)
	filepath := config.Get().Signing.KeyFile
Gabriel Zachmann's avatar
Gabriel Zachmann committed
	ioutil.WriteFile(filepath, []byte(str), 0600)
Gabriel Zachmann's avatar
Gabriel Zachmann committed
	log.WithField("filepath", filepath).Info("Wrote key to file.")
Gabriel Zachmann's avatar
Gabriel Zachmann committed
}