feat: add SetAuthCookie helper
This commit is contained in:
parent
b03e6815e2
commit
51c7211c39
|
@ -4,6 +4,7 @@ import (
|
|||
"crypto/ed25519"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
@ -89,3 +90,14 @@ func JWTVerifyToken(token string, domain string, privateKey ed25519.PrivateKey,
|
|||
|
||||
return claim, err
|
||||
}
|
||||
|
||||
func SetAuthCookie(w http.ResponseWriter, name, token string) {
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: name,
|
||||
Value: token,
|
||||
Expires: time.Now().Add(24 * time.Hour),
|
||||
Secure: true,
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue