Support setting cookie domain (#6288)

Signed-off-by: Tamal Saha <tamal@appscode.com>
This commit is contained in:
Tamal Saha 2019-07-12 06:57:31 -07:00 committed by techknowlogick
parent d95237b561
commit 2102f9d92d
15 changed files with 58 additions and 46 deletions

View file

@ -50,7 +50,7 @@ func generateTokenAtTime(key, userID, actionID string, now time.Time) string {
h := hmac.New(sha1.New, []byte(key))
fmt.Fprintf(h, "%s:%s:%d", clean(userID), clean(actionID), now.UnixNano())
tok := fmt.Sprintf("%s:%d", h.Sum(nil), now.UnixNano())
return base64.URLEncoding.EncodeToString([]byte(tok))
return base64.RawURLEncoding.EncodeToString([]byte(tok))
}
// Valid returns true if token is a valid, unexpired token returned by Generate.
@ -61,7 +61,7 @@ func ValidToken(token, key, userID, actionID string) bool {
// validTokenAtTime is like Valid, but it uses now to check if the token is expired.
func validTokenAtTime(token, key, userID, actionID string, now time.Time) bool {
// Decode the token.
data, err := base64.URLEncoding.DecodeString(token)
data, err := base64.RawURLEncoding.DecodeString(token)
if err != nil {
return false
}