feat: add SetAuthCookie helper
This commit is contained in:
parent
b03e6815e2
commit
51c7211c39
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -89,3 +90,14 @@ func JWTVerifyToken(token string, domain string, privateKey ed25519.PrivateKey,
|
||||||
|
|
||||||
return claim, err
|
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