blob: edc30b73da552fa0b22acbec7b56d2780e0377c0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package kauth
import (
"fmt"
"net/http"
"time"
"github.com/martinlehoux/kagamigo/kcore"
)
func CraftCookie(id kcore.ID, config AuthConfig) http.Cookie {
expiresAt := time.Now().Add(24 * time.Hour)
cookieValue := encrypt(config.CookieSecret, fmt.Sprintf("%s:%d", id.String(), expiresAt.Unix()))
return http.Cookie{
Domain: config.Domain,
Name: "authentication",
Value: cookieValue,
Expires: expiresAt,
Path: "/",
}
}
|