Added configuration

This commit is contained in:
2025-09-21 14:30:33 +01:00
parent 2c92ee61a0
commit d9d64cb067
5 changed files with 70 additions and 4 deletions
+4 -3
View File
@@ -4,6 +4,7 @@ import (
"net/http"
"strings"
"github.com/ESilva15/PTInvCertSWDB/config"
"github.com/gin-gonic/gin"
"github.com/golang-jwt/jwt/v4"
)
@@ -12,11 +13,11 @@ type TokenData struct {
Token string `json:"JWTToken"`
}
const key = "stronk"
func validateToken(tStr string) (bool, error) {
cfg := config.GetInstance()
token, err := jwt.Parse(tStr, func(token *jwt.Token) (any, error) {
return []byte(key), nil
return []byte(cfg.AuthKey), nil
}, jwt.WithValidMethods([]string{jwt.SigningMethodHS256.Alg()}))
if err != nil {
return false, err