SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
19.
// $response is unchanged here.
$response->withHeader(‘X-yes’, ‘yes’);
// We need to overwrite $response
$response = $response->withHeader(‘X-yes’, ‘yes’);
Immutability
20.
Present Middleware
Your application as an onion
21.
Present Layers of behavior
Small, focused, and composable
38.
Future New Middleware
CSRF, Cookies, Authentication
39.
use CakeHttpMiddlewareEncryptedCookiesMiddleware;
$middleware->add(new EncryptedCookiesMiddleware([
[‘remember_me’, ‘secrets’],
Configure::read(‘Cookie.aesKey’)
]));
Cookies
42.
// Register middleware, for use in routing scopes
$routes
->registerMiddleware(‘auth’, new AuthenticationMiddleware(..))
->registerMiddleware(‘cookies’, new EncryptedCookieMiddleware(..));
// Create a routing scope (as you do today)
$routes->scope('/api', function ($routes) {
// Enable middleware
$routes->middleware('csrf', 'cors', 'auth');
$routes->connect('/ping', [‘controller’ => ‘Pings’]);
});
Routable Middleware