Change session cookie delimeter to colon from pipe
This is to permit us to store a user's Groups in a pipe-delimited list without fear of bad splits or having to reassemble it in transit.
This commit is contained in:
parent
af7be2d622
commit
6cbed581c2
|
|
@ -72,11 +72,11 @@ func (s *SessionState) EncryptedString(c *cookie.Cipher) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s|%s|%d|%s", s.userOrEmail(), a, s.ExpiresOn.Unix(), r), nil
|
||||
return fmt.Sprintf("%s:%s:%d:%s", s.userOrEmail(), a, s.ExpiresOn.Unix(), r), nil
|
||||
}
|
||||
|
||||
func DecodeSessionState(v string, c *cookie.Cipher) (s *SessionState, err error) {
|
||||
chunks := strings.Split(v, "|")
|
||||
chunks := strings.Split(v, ":")
|
||||
if len(chunks) == 1 {
|
||||
if strings.Contains(chunks[0], "@") {
|
||||
u := strings.Split(v, "@")[0]
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func TestSessionStateSerialization(t *testing.T) {
|
|||
}
|
||||
encoded, err := s.EncodeSessionState(c)
|
||||
assert.Equal(t, nil, err)
|
||||
assert.Equal(t, 3, strings.Count(encoded, "|"))
|
||||
assert.Equal(t, 3, strings.Count(encoded, ":"))
|
||||
|
||||
ss, err := DecodeSessionState(encoded, c)
|
||||
t.Logf("%#v", ss)
|
||||
|
|
|
|||
Loading…
Reference in New Issue