mirror of
https://github.com/nais/wonderwall.git
synced 2026-08-23 21:16:14 +00:00
refactor(cookie): use rawurlencoding for base64
This commit is contained in:
@@ -35,13 +35,13 @@ func (in *Cookie) Encrypt(crypter crypto.Crypter) (*Cookie, error) {
|
||||
return nil, fmt.Errorf("unable to encrypt cookie '%s': %w", in.Cookie.Name, err)
|
||||
}
|
||||
|
||||
value := base64.StdEncoding.EncodeToString(ciphertext)
|
||||
value := base64.RawURLEncoding.EncodeToString(ciphertext)
|
||||
in.Cookie.Value = value
|
||||
return in, nil
|
||||
}
|
||||
|
||||
func (in *Cookie) Decrypt(crypter crypto.Crypter) (string, error) {
|
||||
ciphertext, err := base64.StdEncoding.DecodeString(in.Value)
|
||||
ciphertext, err := base64.RawURLEncoding.DecodeString(in.Value)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%w: named '%s': %+v", ErrInvalidValue, in.Name, err)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestFrontChannelLogout(t *testing.T) {
|
||||
|
||||
// Trigger front-channel logout
|
||||
sid := func(r *http.Request) string {
|
||||
ciphertext, err := base64.StdEncoding.DecodeString(sessionCookie.Value)
|
||||
ciphertext, err := base64.RawURLEncoding.DecodeString(sessionCookie.Value)
|
||||
assert.NoError(t, err)
|
||||
|
||||
sessionKey, err := idp.RelyingPartyHandler.GetCrypter().Decrypt(ciphertext)
|
||||
|
||||
Reference in New Issue
Block a user