Adjust function names

This commit is contained in:
Andrew-71 2024-10-13 21:26:03 +03:00
parent b15c942e64
commit 29d8197ba3
5 changed files with 13 additions and 13 deletions

View file

@ -15,7 +15,7 @@ import (
var rootCmd = &cobra.Command{
Use: "pye",
Short: "Pye is a simple JWT system",
Long: `A bare-bones authentication system with RS256`,
Long: `An HTTP JSON Web Token authentication system`,
}
var (

View file

@ -23,10 +23,10 @@ var serveCmd = &cobra.Command{
Use: "serve",
Short: "Start JWT service",
Long: `Start a simple authentication service`,
Run: serveAuth,
Run: serve,
}
func serveAuth(cmd *cobra.Command, args []string) {
func serve(cmd *cobra.Command, args []string) {
if port == 0 {
port = config.Cfg.Port
}

View file

@ -27,10 +27,10 @@ var verifyCmd = &cobra.Command{
Short: "Verify a JWT token",
Long: `Pass a JWT token (and optionally a path to a PEM-formatted file with the public key)
to verify whether it is valid.`,
Run: verifyFunc,
Run: verify,
}
func verifyFunc(cmd *cobra.Command, args []string) {
func verify(cmd *cobra.Command, args []string) {
if verifyToken == "" {
fmt.Println("Empty token supplied!")
return
@ -40,14 +40,14 @@ func verifyFunc(cmd *cobra.Command, args []string) {
var err error
if verifyFile == "" {
fmt.Println("No PEM file supplied, assuming local")
t, err = auth.VerifyLocal(verifyToken)
t, err = auth.VerifyLocalToken(verifyToken)
} else {
key, err_k := os.ReadFile(verifyFile)
if err_k != nil {
slog.Error("error reading file", "error", err, "file", verifyFile)
return
}
t, err = auth.Verify(verifyToken, key)
t, err = auth.VerifyToken(verifyToken, key)
}
slog.Debug("result", "token", t, "error", err, "ok", err == nil)
if err == nil {