Create a M2 module that will authorize CloudFlare Access requests. The documentation for CloudFlare Access request validation is linked further down below.
The module should:
- Intercept all HTTP requests to Magento frontend controllers.
- If the request doesn't have a
CF_Authorization
cookie, return a 403 response with a message readingmissing required cf authorization token
. - If the cookie is present, then allow the request to pass through.
- A store configuration setting should determine if the module is Enabled / Disabled. The default value should be
false
.
- Place all your code inside the
src
directory. - You can install Magento inside the
magento
folder.composer install
- Then run
bin/magento install ...
- You can symlink your module into a folder inside
app/code
in order to test it. - Don't forget to add it to the modules list in
app/etc/config.php
and runbin/magento setup:upgrade
.
- If you already know how to, you can use unit tests to check and iterate over your work more quickly without the need of testing manually inside Magento. Place the tests inside the
tests
folder. WRITING UNIT TESTS IS NOT A REQUIREMENT unless explicitly mentioned in the assignment.