Skip to content

Commit e3d1d59

Browse files
committed
Remove expiration string from session cookie
This change removes the "expires" key from the session cookie. This key is no longer required as it was superseded by the "exp" key in 3.11. It was left is place to support mixed masters (3.10 / 3.11). This logic can be safely removed since mixed masters of 3.11 and 4.0 are aware of the new "exp" key. The "exp" key is represented as an int64 instead of a string which makes it easier to parse. Signed-off-by: Monis Khan <[email protected]>
1 parent ac89a2a commit e3d1d59

File tree

1 file changed

+1
-28
lines changed

1 file changed

+1
-28
lines changed

pkg/oauthserver/server/session/authenticator.go

+1-28
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ package session
22

33
import (
44
"net/http"
5-
"strconv"
65
"time"
76

8-
"github.com/golang/glog"
9-
107
"k8s.io/apiserver/pkg/authentication/user"
118
)
129

@@ -16,9 +13,6 @@ const (
1613

1714
// expKey is stored as an int64 unix time
1815
expKey = "exp"
19-
// expiresKey is the string representation of expKey
20-
// TODO drop in a release when mixed masters are no longer an issue
21-
expiresKey = "expires"
2216
)
2317

2418
type Authenticator struct {
@@ -37,22 +31,8 @@ func (a *Authenticator) AuthenticateRequest(req *http.Request) (user.Info, bool,
3731
values := a.store.Get(req)
3832

3933
expires, ok := values.GetInt64(expKey)
40-
41-
// TODO drop this logic in a release when mixed masters are no longer an issue
4234
if !ok {
43-
// TODO replace with (in a release when mixed masters are no longer an issue):
44-
// return nil, false, nil
45-
46-
expiresString, ok := values.GetString(expiresKey)
47-
if !ok {
48-
return nil, false, nil
49-
}
50-
expiresParse, err := strconv.ParseInt(expiresString, 10, 64)
51-
if err != nil {
52-
glog.Errorf("error parsing expires timestamp: %v", err)
53-
return nil, false, nil
54-
}
55-
expires = expiresParse
35+
return nil, false, nil
5636
}
5737

5838
if expires < time.Now().Unix() {
@@ -92,12 +72,5 @@ func (a *Authenticator) put(w http.ResponseWriter, name, uid string, expires int
9272

9373
values[expKey] = expires
9474

95-
// TODO drop this logic in a release when mixed masters are no longer an issue
96-
if expires == 0 {
97-
values[expiresKey] = ""
98-
} else {
99-
values[expiresKey] = strconv.FormatInt(expires, 10)
100-
}
101-
10275
return a.store.Put(w, values)
10376
}

0 commit comments

Comments
 (0)