ing
This commit is contained in:
parent
d8dba557e3
commit
c38073b8d0
|
@ -5,6 +5,7 @@ import (
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -78,6 +79,8 @@ func SignIn(ctx *fasthttp.RequestCtx) {
|
||||||
/* Create a map to store our claims */
|
/* Create a map to store our claims */
|
||||||
claims := token.Claims.(jwt.MapClaims)
|
claims := token.Claims.(jwt.MapClaims)
|
||||||
|
|
||||||
|
expireTime := time.Now().Add(time.Hour * 24)
|
||||||
|
|
||||||
/* Set token claims */
|
/* Set token claims */
|
||||||
claims["iss"] = "overFlow"
|
claims["iss"] = "overFlow"
|
||||||
claims["iat"] = time.Now().Unix()
|
claims["iat"] = time.Now().Unix()
|
||||||
|
@ -88,9 +91,15 @@ func SignIn(ctx *fasthttp.RequestCtx) {
|
||||||
/* Sign the token with our secret */
|
/* Sign the token with our secret */
|
||||||
tokenString, _ := token.SignedString(signKey)
|
tokenString, _ := token.SignedString(signKey)
|
||||||
|
|
||||||
|
log.Printf("%s \n", tokenString)
|
||||||
|
|
||||||
var jwtCookie fasthttp.Cookie
|
var jwtCookie fasthttp.Cookie
|
||||||
jwtCookie.SetKey("AuthToken")
|
jwtCookie.SetKey("AuthToken")
|
||||||
jwtCookie.SetValue(tokenString)
|
jwtCookie.SetValue(tokenString)
|
||||||
|
// jwtCookie.SetHTTPOnly(true)
|
||||||
|
jwtCookie.SetSecure(true)
|
||||||
|
jwtCookie.SetExpire(expireTime)
|
||||||
|
jwtCookie.SetPath("/")
|
||||||
ctx.Response.Header.SetCookie(&jwtCookie)
|
ctx.Response.Header.SetCookie(&jwtCookie)
|
||||||
|
|
||||||
commons.SendRESTResponse(ctx, r)
|
commons.SendRESTResponse(ctx, r)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user