Remove unneeded stuff, make jwt token secret an env variable

This commit is contained in:
Amarpreet Minhas 2019-02-08 18:16:10 -05:00
parent 793ad43c4b
commit 3e7d43e068

View file

@ -10,7 +10,6 @@ import (
"git.minhas.io/asara/sudoscientist/packages/auth" "git.minhas.io/asara/sudoscientist/packages/auth"
"git.minhas.io/asara/sudoscientist/packages/database" "git.minhas.io/asara/sudoscientist/packages/database"
"git.minhas.io/asara/sudoscientist/packages/users" "git.minhas.io/asara/sudoscientist/packages/users"
"github.com/dgrijalva/jwt-go"
"github.com/go-chi/chi" "github.com/go-chi/chi"
"github.com/go-chi/chi/middleware" "github.com/go-chi/chi/middleware"
"github.com/go-chi/jwtauth" "github.com/go-chi/jwtauth"
@ -27,10 +26,8 @@ func main() {
users.Init() users.Init()
// initiate jwt token // initiate jwt token
auth.TokenAuth = jwtauth.New("HS256", []byte("secret"), nil) auth.TokenAuth = jwtauth.New("HS256", []byte(os.Getenv("JWT_SECRET")), nil)
users.TokenAuth = auth.TokenAuth users.TokenAuth = auth.TokenAuth
_, tokenString, _ := auth.TokenAuth.Encode(jwt.MapClaims{"asara": 123})
log.Printf("DEBUG: a sample jwt is %s\n\n", tokenString)
// initiate the routes // initiate the routes
router := Routes() router := Routes()