-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
143 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Selective\SameSiteCookie; | ||
|
||
/** | ||
* SameSite Cookie Configuration. | ||
*/ | ||
final class SameSiteCookieConfiguration | ||
{ | ||
/** | ||
* @var bool Start the session | ||
*/ | ||
public $startSession = true; | ||
|
||
/** | ||
* @var string Send cookie only via a href link. Values: 'Lax' or 'Strict'. | ||
*/ | ||
public $sameSite = 'Lax'; | ||
|
||
/** | ||
* @var bool Prevents cookies from being read by scripts. Should be enabled. | ||
*/ | ||
public $httpOnly = true; | ||
|
||
/** | ||
* @var bool Provide cookies only via ssl. Should be enabled in production. | ||
*/ | ||
public $secure = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Selective\SameSiteCookie\Test; | ||
|
||
use Nyholm\Psr7\Factory\Psr17Factory; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Relay\Relay; | ||
|
||
/** | ||
* Test. | ||
*/ | ||
trait MiddlewareTestTrait | ||
{ | ||
/** | ||
* Run middleware stack. | ||
* | ||
* @param array $queue The queue | ||
* | ||
* @return ResponseInterface The response | ||
*/ | ||
protected function runQueue(array $queue): ResponseInterface | ||
{ | ||
$queue[] = new ResponseFactoryMiddleware(); | ||
|
||
$request = $this->createRequest(); | ||
$relay = new Relay($queue); | ||
|
||
return $relay->handle($request); | ||
} | ||
|
||
/** | ||
* Factory. | ||
* | ||
* @return ServerRequestInterface | ||
*/ | ||
protected function createRequest(): ServerRequestInterface | ||
{ | ||
return (new Psr17Factory())->createServerRequest('GET', '/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Selective\SameSiteCookie\Test; | ||
|
||
use Nyholm\Psr7\Factory\Psr17Factory; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\MiddlewareInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
|
||
/** | ||
* Middleware. | ||
*/ | ||
final class ResponseFactoryMiddleware implements MiddlewareInterface | ||
{ | ||
/** | ||
* Invoke middleware. | ||
* | ||
* @param ServerRequestInterface $request The request | ||
* @param RequestHandlerInterface $handler The handler | ||
* | ||
* @return ResponseInterface The response | ||
*/ | ||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | ||
{ | ||
return (new Psr17Factory())->createResponse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
ob_start(); |