fix: cookies sent to us don't include the expiry time, so we need to parse from thr jwt echo it.
This commit is contained in:
parent
da19a2e287
commit
4a3028f61a
|
@ -143,10 +143,22 @@ func EchoAuthCookie(jc jape.Context, apiName string) {
|
|||
continue
|
||||
}
|
||||
|
||||
unverified, _, err := jwt.NewParser().ParseUnverified(cookies[0].Value, &jwt.RegisteredClaims{})
|
||||
if err != nil {
|
||||
http.Error(jc.ResponseWriter, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
exp, err := unverified.Claims.GetExpirationTime()
|
||||
if err != nil {
|
||||
http.Error(jc.ResponseWriter, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.SetCookie(jc.ResponseWriter, &http.Cookie{
|
||||
Name: cookies[0].Name,
|
||||
Value: cookies[0].Value,
|
||||
Expires: cookies[0].Expires,
|
||||
Expires: exp.Time,
|
||||
Secure: true,
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
|
|
Loading…
Reference in New Issue