├── .gitignore
├── LICENSE
├── README.md
├── app
├── code
│ └── community
│ │ └── AgentsOf
│ │ └── Shield
│ │ ├── Helper
│ │ └── Data.php
│ │ ├── Model
│ │ ├── Observer.php
│ │ └── Source
│ │ │ ├── Action.php
│ │ │ ├── Area.php
│ │ │ └── Redirect.php
│ │ └── etc
│ │ ├── config.xml
│ │ └── system.xml
└── etc
│ └── modules
│ └── AgentsOf_Shield.xml
└── modman
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Winston Nolan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Magento Shield #
2 |
3 | You run a Magento Store. You want to protect this store's Frontend, or Admin, or both from hackers or search engines.
4 | What can you do?
5 |
6 | 1. You can password protect these endpoints.
7 | A password will give you an error when you try to upload images to products from the admin. It is also difficult to change and manage
8 | 2. You can put the store Admin behind a VPN.
9 | This is difficult to setup, and a little difficult to manage when you just want to protect the Admin
10 | 3. You can allow access based on IP Address
11 | Difficult to manage and IP addresses rotate frequently, so you would have to update/change this whitelist constantly
12 | 4. You can protect the end points based on a set request header - This is where this module comes in
13 |
14 | # What does this module do? #
15 |
16 | This module listens to each request made to Magento Admin, Frontend or Both (configurable) and looks for a request header name (configurable via the admin) and the request header value (configurable) and if this matches, it allow the request through to Magento. If this fails it can either block the request (Send a 403) or redirect the request to a URL (configurable)
17 |
18 | # How to send the request header #
19 |
20 | Use a browser like chrome and the modheader extension, link below
21 | https://chrome.google.com/webstore/detail/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj?hl=en
22 |
23 | # TODO #
24 |
25 | Build a shell script that can enable or disable the shield
26 |
27 |
--------------------------------------------------------------------------------
/app/code/community/AgentsOf/Shield/Helper/Data.php:
--------------------------------------------------------------------------------
1 | getStore()->isAdmin())
42 | {
43 | return true;
44 | }
45 |
46 | if(Mage::getDesign()->getArea() == 'adminhtml')
47 | {
48 | return true;
49 | }
50 |
51 | return false;
52 | }
53 | }
--------------------------------------------------------------------------------
/app/code/community/AgentsOf/Shield/Model/Observer.php:
--------------------------------------------------------------------------------
1 | getHeaderName();
8 | $requestHeaderValue = $helper->getHeaderValue();
9 |
10 | if(!$helper->isEnabled()) {
11 | return;
12 | }
13 |
14 | if($helper->getProtectedArea() == Mage_Core_Model_App_Area::AREA_ADMIN &&
15 | !$helper->isAdmin()) {
16 | return;
17 | }
18 |
19 | if($helper->getProtectedArea() == Mage_Core_Model_App_Area::AREA_FRONTEND &&
20 | $helper->isAdmin()) {
21 | return;
22 | }
23 |
24 | if(Mage::app()->getRequest()->getHeader($requestHeaderName) &&
25 | Mage::app()->getRequest()->getHeader($requestHeaderName) == $requestHeaderValue) {
26 | return;
27 | }
28 |
29 | // block or redirect everything that reaches this point
30 | if($helper->getAction() == AgentsOf_Shield_Model_Source_Action::REDIRECT) {
31 | if($helper->getRedirect() == AgentsOf_Shield_Model_Source_Redirect::CUSTOM) {
32 | Mage::app()->getResponse()
33 | ->setRedirect($helper->getRedirectUrl())
34 | ->sendResponse();
35 |
36 | exit();
37 |
38 | } else {
39 | Mage::app()->getResponse()
40 | ->setRedirect(Mage::getBaseUrl())
41 | ->sendResponse();
42 |
43 | exit();
44 | }
45 |
46 | } else {
47 | Mage::app()->getResponse()
48 | ->setHttpResponseCode(403)
49 | ->setBody('')
50 | ->sendResponse();
51 |
52 | exit();
53 | }
54 |
55 | }
56 | }
--------------------------------------------------------------------------------
/app/code/community/AgentsOf/Shield/Model/Source/Action.php:
--------------------------------------------------------------------------------
1 | self::BLOCK,
13 | 'label' => Mage::helper('agentsof_shield')->__('Block')
14 | ),
15 | array(
16 | 'value' => self::REDIRECT,
17 | 'label' => Mage::helper('agentsof_shield')->__('Redirect')
18 | )
19 | );
20 | }
21 | }
--------------------------------------------------------------------------------
/app/code/community/AgentsOf/Shield/Model/Source/Area.php:
--------------------------------------------------------------------------------
1 | Mage_Core_Model_App_Area::AREA_ADMIN,
10 | 'label' => Mage::helper('agentsof_shield')->__('Admin')
11 | ),
12 | array(
13 | 'value' => Mage_Core_Model_App_Area::AREA_FRONTEND,
14 | 'label' => Mage::helper('agentsof_shield')->__('Frontend')
15 | ),
16 | array(
17 | 'value' => Mage_Core_Model_App_Area::AREA_GLOBAL,
18 | 'label' => Mage::helper('agentsof_shield')->__('Global')
19 | )
20 | );
21 | }
22 | }
--------------------------------------------------------------------------------
/app/code/community/AgentsOf/Shield/Model/Source/Redirect.php:
--------------------------------------------------------------------------------
1 | self::BASE_URL,
13 | 'label' => Mage::helper('agentsof_shield')->__('Base URL')
14 | ),
15 | array(
16 | 'value' => self::CUSTOM,
17 | 'label' => Mage::helper('agentsof_shield')->__('Custom URL')
18 | )
19 | );
20 | }
21 | }
--------------------------------------------------------------------------------
/app/code/community/AgentsOf/Shield/etc/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 0.0.1
6 |
7 |
8 |
9 |
10 |
11 | AgentsOf_Shield_Helper
12 |
13 |
14 |
15 |
16 | AgentsOf_Shield_Model
17 |
18 |
19 |
20 |
21 |
22 |
23 | agentsof_shield/observer
24 | check
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | Shield
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/code/community/AgentsOf/Shield/etc/system.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | general
7 | 25
8 | 1
9 | 1
10 | 1
11 |
12 |
13 |
14 | text
15 | 0
16 | 1
17 | 1
18 | 1
19 |
20 |
21 |
22 |
23 | select
24 | adminhtml/system_config_source_yesno
25 | 0
26 | 1
27 | 1
28 | 1
29 |
30 |
31 |
32 | text
33 | 1
34 | 1
35 | 1
36 | 0
37 | Name of the request header
38 |
39 |
40 |
41 | text
42 | 2
43 | 1
44 | 1
45 | 0
46 | Value of the request header
47 |
48 |
49 |
50 | select
51 | agentsof_shield/source_area
52 | 3
53 | 1
54 | 1
55 | 0
56 | 1
57 |
58 |
59 |
60 | select
61 | agentsof_shield/source_action
62 | 4
63 | 1
64 | 1
65 | 0
66 | 0
67 |
68 |
69 |
70 | select
71 | agentsof_shield/source_redirect
72 | 5
73 | 1
74 | 1
75 | 0
76 | 0
77 | redirect
78 |
79 |
80 |
81 | text
82 | 6
83 | 1
84 | 1
85 | 0
86 | custom_url
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/app/etc/modules/AgentsOf_Shield.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | community
7 |
8 |
9 |
--------------------------------------------------------------------------------
/modman:
--------------------------------------------------------------------------------
1 | # AgentsOf_Shield modman file
2 | app/code/community/AgentsOf app/code/community/AgentsOf
3 | app/etc/AgentsOf_Shield.xml app/etc/modules/AgentsOf_Shield.xml
--------------------------------------------------------------------------------