update for version 1.0.1
This commit is contained in:
168
code/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php
vendored
Normal file
168
code/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php namespace Illuminate\Cookie;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Illuminate\Contracts\Cookie\QueueingFactory as JarContract;
|
||||
|
||||
class CookieJar implements JarContract {
|
||||
|
||||
/**
|
||||
* The default path (if specified).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $path = '/';
|
||||
|
||||
/**
|
||||
* The default domain (if specified).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $domain = null;
|
||||
|
||||
/**
|
||||
* All of the cookies queued for sending.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $queued = array();
|
||||
|
||||
/**
|
||||
* Create a new cookie instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param int $minutes
|
||||
* @param string $path
|
||||
* @param string $domain
|
||||
* @param bool $secure
|
||||
* @param bool $httpOnly
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
|
||||
{
|
||||
list($path, $domain) = $this->getPathAndDomain($path, $domain);
|
||||
|
||||
$time = ($minutes == 0) ? 0 : time() + ($minutes * 60);
|
||||
|
||||
return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a cookie that lasts "forever" (five years).
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param string $path
|
||||
* @param string $domain
|
||||
* @param bool $secure
|
||||
* @param bool $httpOnly
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true)
|
||||
{
|
||||
return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expire the given cookie.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
* @param string $domain
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
public function forget($name, $path = null, $domain = null)
|
||||
{
|
||||
return $this->make($name, null, -2628000, $path, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a cookie has been queued.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function hasQueued($key)
|
||||
{
|
||||
return ! is_null($this->queued($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a queued cookie instance.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
public function queued($key, $default = null)
|
||||
{
|
||||
return array_get($this->queued, $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue a cookie to send with the next response.
|
||||
*
|
||||
* @param mixed
|
||||
* @return void
|
||||
*/
|
||||
public function queue()
|
||||
{
|
||||
if (head(func_get_args()) instanceof Cookie)
|
||||
{
|
||||
$cookie = head(func_get_args());
|
||||
}
|
||||
else
|
||||
{
|
||||
$cookie = call_user_func_array(array($this, 'make'), func_get_args());
|
||||
}
|
||||
|
||||
$this->queued[$cookie->getName()] = $cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a cookie from the queue.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function unqueue($name)
|
||||
{
|
||||
unset($this->queued[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path and domain, or the default values.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $domain
|
||||
* @return array
|
||||
*/
|
||||
protected function getPathAndDomain($path, $domain)
|
||||
{
|
||||
return array($path ?: $this->path, $domain ?: $this->domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default path and domain for the jar.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $domain
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultPathAndDomain($path, $domain)
|
||||
{
|
||||
list($this->path, $this->domain) = array($path, $domain);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookies which have been queued for the next request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getQueuedCookies()
|
||||
{
|
||||
return $this->queued;
|
||||
}
|
||||
|
||||
}
|
||||
22
code/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php
vendored
Normal file
22
code/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php namespace Illuminate\Cookie;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class CookieServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('cookie', function($app)
|
||||
{
|
||||
$config = $app['config']['session'];
|
||||
|
||||
return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain']);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
46
code/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php
vendored
Normal file
46
code/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php namespace Illuminate\Cookie\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Routing\Middleware;
|
||||
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
|
||||
|
||||
class AddQueuedCookiesToResponse implements Middleware {
|
||||
|
||||
/**
|
||||
* The cookie jar instance.
|
||||
*
|
||||
* @var \Illuminate\Cookie\CookieJar
|
||||
*/
|
||||
protected $cookies;
|
||||
|
||||
/**
|
||||
* Create a new CookieQueue instance.
|
||||
*
|
||||
* @param \Illuminate\Cookie\CookieJar $cookies
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CookieJar $cookies)
|
||||
{
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
foreach ($this->cookies->getQueuedCookies() as $cookie)
|
||||
{
|
||||
$response->headers->setCookie($cookie);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
130
code/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php
vendored
Normal file
130
code/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php namespace Illuminate\Cookie\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Illuminate\Contracts\Routing\Middleware;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
|
||||
|
||||
class EncryptCookies implements Middleware {
|
||||
|
||||
/**
|
||||
* The encrypter instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
||||
*/
|
||||
protected $encrypter;
|
||||
|
||||
/**
|
||||
* Create a new CookieGuard instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(EncrypterContract $encrypter)
|
||||
{
|
||||
$this->encrypter = $encrypter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
return $this->encrypt($next($this->decrypt($request)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt the cookies on the request.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected function decrypt(Request $request)
|
||||
{
|
||||
foreach ($request->cookies as $key => $c)
|
||||
{
|
||||
try
|
||||
{
|
||||
$request->cookies->set($key, $this->decryptCookie($c));
|
||||
}
|
||||
catch (DecryptException $e)
|
||||
{
|
||||
$request->cookies->set($key, null);
|
||||
}
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt the given cookie and return the value.
|
||||
*
|
||||
* @param string|array $cookie
|
||||
* @return string|array
|
||||
*/
|
||||
protected function decryptCookie($cookie)
|
||||
{
|
||||
return is_array($cookie)
|
||||
? $this->decryptArray($cookie)
|
||||
: $this->encrypter->decrypt($cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt an array based cookie.
|
||||
*
|
||||
* @param array $cookie
|
||||
* @return array
|
||||
*/
|
||||
protected function decryptArray(array $cookie)
|
||||
{
|
||||
$decrypted = array();
|
||||
|
||||
foreach ($cookie as $key => $value)
|
||||
{
|
||||
$decrypted[$key] = $this->encrypter->decrypt($value);
|
||||
}
|
||||
|
||||
return $decrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt the cookies on an outgoing response.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function encrypt(Response $response)
|
||||
{
|
||||
foreach ($response->headers->getCookies() as $key => $cookie)
|
||||
{
|
||||
$response->headers->setCookie($this->duplicate(
|
||||
$cookie, $this->encrypter->encrypt($cookie->getValue())
|
||||
));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate a cookie with a new value.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Cookie $c
|
||||
* @param mixed $value
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
protected function duplicate(Cookie $c, $value)
|
||||
{
|
||||
return new Cookie(
|
||||
$c->getName(), $value, $c->getExpiresTime(), $c->getPath(),
|
||||
$c->getDomain(), $c->isSecure(), $c->isHttpOnly()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
34
code/vendor/laravel/framework/src/Illuminate/Cookie/composer.json
vendored
Normal file
34
code/vendor/laravel/framework/src/Illuminate/Cookie/composer.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "illuminate/cookie",
|
||||
"description": "The Illuminate Cookie package.",
|
||||
"license": "MIT",
|
||||
"homepage": "http://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"illuminate/support": "5.0.*",
|
||||
"symfony/http-kernel": "2.6.*",
|
||||
"symfony/http-foundation": "2.6.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Cookie\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
Reference in New Issue
Block a user