Skip to content

Commit

Permalink
Remove encrpytion features from individual cookies.
Browse files Browse the repository at this point in the history
With an encryption middleware in place, we no longer need to have
encryption features on individual cookies. Cookies are now simple
immutable value objects and the middleware handles encryption concerns.
  • Loading branch information
markstory committed Apr 15, 2017
1 parent 437cc51 commit 7cc5693
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 472 deletions.
36 changes: 0 additions & 36 deletions src/Http/Cookie/Cookie.php
Expand Up @@ -48,8 +48,6 @@
class Cookie implements CookieInterface
{

use CookieCryptTrait;

/**
* Expires attribute format.
*
Expand Down Expand Up @@ -598,40 +596,6 @@ public function read($path = null)
return Hash::get($this->value, $path);
}

/**
* Encrypts the cookie value
*
* @param string|null $key Encryption key
* @return $this
*/
public function encrypt($key = null)
{
if ($key !== null) {
$this->setEncryptionKey($key);
}

$this->value = $this->_encrypt($this->value);

return $this;
}

/**
* Decrypts the cookie value
*
* @param string|null $key Encryption key
* @return $this
*/
public function decrypt($key = null)
{
if ($key !== null) {
$this->setEncryptionKey($key);
}

$this->value = $this->_decrypt($this->value);

return $this;
}

/**
* Checks if the cookie value was expanded
*
Expand Down
209 changes: 0 additions & 209 deletions src/Http/Cookie/CookieCryptTrait.php

This file was deleted.

40 changes: 0 additions & 40 deletions src/Http/Cookie/RequestCookies.php

This file was deleted.

36 changes: 0 additions & 36 deletions src/Http/Cookie/ResponseCookies.php

This file was deleted.

38 changes: 0 additions & 38 deletions tests/TestCase/Http/Cookie/CookieTest.php
Expand Up @@ -22,13 +22,6 @@
class CookieTest extends TestCase
{

/**
* Encryption key used in the tests
*
* @var string
*/
protected $encryptionKey = 'someverysecretkeythatisatleast32charslong';

/**
* Generate invalid cookie names.
*
Expand Down Expand Up @@ -70,37 +63,6 @@ public function testValidateNameEmptyName()
new Cookie('', '');
}

/**
* Test decrypting the cookie
*
* @return void
*/
public function testDecrypt()
{
$value = 'cakephp-rocks-and-is-awesome';
$cookie = new Cookie('cakephp', $value);
$cookie->encrypt($this->encryptionKey);
$this->assertTextStartsWith('Q2FrZQ==.', $cookie->getValue());
$cookie->decrypt($this->encryptionKey);
$this->assertSame($value, $cookie->getValue());
}

/**
* Testing encrypting the cookie
*
* @return void
*/
public function testEncrypt()
{
$value = 'cakephp-rocks-and-is-awesome';

$cookie = new Cookie('cakephp', $value);
$cookie->encrypt($this->encryptionKey);

$this->assertNotEquals($value, $cookie->getValue());
$this->assertNotEmpty($cookie->getValue());
}

/**
* Tests the header value
*
Expand Down

0 comments on commit 7cc5693

Please sign in to comment.