encoding hmac secret base 64

This commit is contained in:
Lukas Bachschwell 2018-11-16 15:29:57 +01:00
parent 6fe3cb9bd7
commit 4b0a7ebf75

View File

@ -2,6 +2,7 @@ package tokenTools
import ( import (
"crypto/rand" "crypto/rand"
"encoding/base64"
"fmt" "fmt"
jwt "github.com/dgrijalva/jwt-go" jwt "github.com/dgrijalva/jwt-go"
@ -20,7 +21,9 @@ func GenerateSecret() []byte {
// InitJWTService generate the secret to verify JWTs and store it in memory // InitJWTService generate the secret to verify JWTs and store it in memory
func InitTokenToolsService() { func InitTokenToolsService() {
hmacSecret = GenerateSecret() hmacSecret = GenerateSecret()
fmt.Println("InitJWTService", hmacSecret) encodedSecret := base64.StdEncoding.EncodeToString(hmacSecret)
fmt.Println("InitJWTService", encodedSecret)
// TODO: This needs to be replaced with reading rsa keys, there needs to be a automatic generation of these if they do not exist // TODO: This needs to be replaced with reading rsa keys, there needs to be a automatic generation of these if they do not exist
} }