diff --git a/config.json b/config.json index a528c21..83a2ad8 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,7 @@ "tls": false }, "auth": { - "signingKey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" + "signingKey": "tWB0lUXiCwX4U3qsJZcZ10mKvEH793RHkTJDbDuZVshQTk4uNB6ck59UQ96lhsRi4XNUiEnlIbP8XYQMPabeNtERX3iyHeDcwocgUVAor1nkAajYeq1gNyJszGpMhEOT" }, "grpc": { "addr": "127.0.0.1:50006", diff --git a/module/member/signin.go b/module/member/signin.go index cf9fd2c..f4128c5 100644 --- a/module/member/signin.go +++ b/module/member/signin.go @@ -7,13 +7,12 @@ import ( "encoding/json" "log" + "git.loafle.net/commons_go/config" "git.loafle.net/overflow/overflow_server_app/grpc" jwt "github.com/dgrijalva/jwt-go" "github.com/valyala/fasthttp" ) -var ofSigningKey = []byte("secret") - func SignIn(ctx *fasthttp.RequestCtx) { var err error //signinId := string(ctx.FormValue("signinId")) @@ -51,12 +50,14 @@ func SignIn(ctx *fasthttp.RequestCtx) { claims := token.Claims.(jwt.MapClaims) /* Set token claims */ - - claims["uid"] = signinId + claims["iss"] = "overFlow" + claims["iat"] = time.Now().Unix() claims["exp"] = time.Now().Add(time.Hour * 24).Unix() + claims["aud"] = "www.overflow.cloud" + claims["sub"] = signinId /* Sign the token with our secret */ - tokenString, _ := token.SignedString(ofSigningKey) + tokenString, _ := token.SignedString([]byte(config.GetString("auth.signingKey"))) var jwtCookie fasthttp.Cookie jwtCookie.SetKey("AuthToken")