jwt
This commit is contained in:
parent
d92eac5727
commit
e1433246ca
|
@ -4,7 +4,7 @@
|
|||
"tls": false
|
||||
},
|
||||
"auth": {
|
||||
"signingKey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
|
||||
"signingKey": "tWB0lUXiCwX4U3qsJZcZ10mKvEH793RHkTJDbDuZVshQTk4uNB6ck59UQ96lhsRi4XNUiEnlIbP8XYQMPabeNtERX3iyHeDcwocgUVAor1nkAajYeq1gNyJszGpMhEOT"
|
||||
},
|
||||
"grpc": {
|
||||
"addr": "127.0.0.1:50006",
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user