1
0

Vikunja now uses viper to handle config

This commit is contained in:
konrad
2018-09-08 13:29:35 +02:00
parent 4f3e016751
commit 427f752990
13 changed files with 256 additions and 109 deletions

View File

@ -6,6 +6,7 @@ import (
"encoding/hex"
"github.com/dgrijalva/jwt-go"
"github.com/labstack/echo"
"github.com/spf13/viper"
"net/http"
"time"
)
@ -57,7 +58,7 @@ func Login(c echo.Context) error {
claims["avatar"] = hex.EncodeToString(avatar[:])
// Generate encoded token and send it as response.
t, err := token.SignedString(models.Config.JWTLoginSecret)
t, err := token.SignedString([]byte(viper.GetString("service.JWTSecret")))
if err != nil {
return err
}

View File

@ -34,6 +34,7 @@ import (
apiv1 "code.vikunja.io/api/routes/api/v1"
_ "code.vikunja.io/api/routes/api/v1/swagger" // for docs generation
"code.vikunja.io/api/routes/crud"
"github.com/spf13/viper"
)
// NewEcho registers a new Echo instance
@ -67,7 +68,7 @@ func RegisterRoutes(e *echo.Echo) {
// ===== Routes with Authetification =====
// Authetification
a.Use(middleware.JWT(models.Config.JWTLoginSecret))
a.Use(middleware.JWT([]byte(viper.GetString("service.JWTSecret"))))
a.POST("/tokenTest", apiv1.CheckToken)
listHandler := &crud.WebHandler{