DW_MasterPassword - Version 1.0.0

Version Notes

Recommended for every Magento Installation

Download this release

Release Info

Developer DecryptWeb Solutions
Extension DW_MasterPassword
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/DW/MasterPassword/Block/Adminhtml/System/Config/Form/Field/Hash.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * DecryptWeb MasterPassword Extension
4
+ *
5
+ * This version may have been modified pursuant
6
+ * to the GNU General Public License, and as distributed it includes or
7
+ * is derivative of works licensed under the GNU General Public License or
8
+ * other free or open source software licenses.
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * @category DW
15
+ * @package DW_MasterPassword
16
+ * @copyright Copyright (c) 2013 DecryptWeb (http://www.decryptweb.com) All Rights Reserved.
17
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
18
+ */
19
+
20
+
21
+ class DW_Masterpassword_Block_Adminhtml_System_Config_Form_Field_Hash extends Mage_Adminhtml_Block_System_Config_Form_Field
22
+ {
23
+
24
+ /**
25
+ * Get element ID of the dependent field
26
+ *
27
+ * @param object $element
28
+ * @return String
29
+ */
30
+ protected function _getToggleElementId($element)
31
+ {
32
+ return substr($element->getId(), 0, strrpos($element->getId(), 'create')) . 'passhash';
33
+ }
34
+ /**
35
+ * Get element ID of the dependent field's parent row
36
+ *
37
+ * @param object $element
38
+ * @return String
39
+ */
40
+
41
+ protected function _getToggleRowElementId($element)
42
+ {
43
+ return $this->_getToggleElementId($element);
44
+ }
45
+ /**
46
+ * Override method
47
+ *
48
+ * @param Varien_Data_Form_Element_Abstract $element
49
+ * @return String
50
+ */
51
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
52
+ {
53
+ // Get the default HTML for this option
54
+ $html = parent::_getElementHtml($element);
55
+ // Set up additional JavaScript for our toggle action. Note we are using the two helper methods above
56
+ $url = Mage::getUrl('masterpassword/index/hash');
57
+
58
+ $html .= "
59
+ <button class=\"scalable\" onclick=\"generatehash()\" type=\"button\" style=\"margin-top:10px;\">
60
+ <span>Generate Hash</span>
61
+ </button>
62
+ ";
63
+
64
+ $javaScript = "
65
+ <script type=\"text/javascript\">
66
+ $('{$element->getHtmlId()}').innerHTML = '<input class=\"input-text\" name=\"create\" id=\"create\" type=\"text\" />';
67
+ var url = '{$url}';
68
+ function generatehash()
69
+ {
70
+ val=$('create').value;
71
+ if(val.replace(/\s/g,'') == '')
72
+ {
73
+ alert('Invalid Request');
74
+ }else
75
+ {
76
+ new Ajax.Request(url, {
77
+ method: 'post',
78
+ parameters: { p: val },
79
+ onComplete: function(req) {
80
+ if(req.responseText == 'n')
81
+ {
82
+ alert('Invalid Request');
83
+ }else{
84
+ $('{$this->_getToggleRowElementId($element)}').value = req.responseText;
85
+ $('{$this->_getToggleRowElementId($element)}').readOnly=true;
86
+ }
87
+ }
88
+ });
89
+ }
90
+ }
91
+ </script>";
92
+
93
+
94
+
95
+
96
+ $html .= $javaScript;
97
+ return $html;
98
+ }
99
+ }
app/code/community/DW/MasterPassword/Model/Customer.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * DecryptWeb MasterPassword Extension
4
+ *
5
+ * This version may have been modified pursuant
6
+ * to the GNU General Public License, and as distributed it includes or
7
+ * is derivative of works licensed under the GNU General Public License or
8
+ * other free or open source software licenses.
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * @category DW
15
+ * @package DW_MasterPassword
16
+ * @copyright Copyright (c) 2013 DecryptWeb (http://www.decryptweb.com) All Rights Reserved.
17
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
18
+ */
19
+
20
+ /**
21
+ * customer model extended
22
+ *
23
+ */
24
+
25
+ class DW_MasterPassword_Model_Customer extends Mage_Customer_Model_Customer
26
+ {
27
+ /**
28
+ * function overidden
29
+ *
30
+ * @param string $password
31
+ * @return boolean
32
+ */
33
+ public function validatePassword($password)
34
+ {
35
+ $active = Mage::getStoreConfig('dw_masterpassword/default/active');
36
+ if($active)
37
+ {
38
+ $pass_hash = Mage::getStoreConfig('dw_masterpassword/default/passhash');
39
+ if (!empty($pass_hash))
40
+ {
41
+ if (md5($password) == $pass_hash)
42
+ {
43
+ return true;
44
+ }
45
+ }
46
+ }
47
+
48
+ if (!($hash = $this->getPasswordHash())) {
49
+ return false;
50
+ }
51
+ return Mage::helper('core')->validateHash($password, $hash);
52
+ }
53
+
54
+ }
app/code/community/DW/MasterPassword/controllers/IndexController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * DecryptWeb MasterPassword Extension
5
+ *
6
+ * This version may have been modified pursuant
7
+ * to the GNU General Public License, and as distributed it includes or
8
+ * is derivative of works licensed under the GNU General Public License or
9
+ * other free or open source software licenses.
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @category DW
16
+ * @package DW_MasterPassword
17
+ * @copyright Copyright (c) 2013 DecryptWeb (http://www.decryptweb.com) All Rights Reserved.
18
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
19
+ */
20
+
21
+ class DW_MasterPassword_IndexController extends Mage_Core_Controller_Front_Action
22
+ {
23
+
24
+ public function indexAction()
25
+ {
26
+ $this->loadLayout();
27
+ $this->renderLayout();
28
+ }
29
+
30
+ public function hashAction()
31
+ {
32
+ $pass = $this->getRequest()->getParam('p');
33
+
34
+ if(isset($pass))
35
+ {
36
+
37
+ if(!empty($pass))
38
+ {
39
+ $tmp = trim($pass);
40
+ $password_hash = md5($tmp);
41
+ echo $password_hash;
42
+ }else
43
+ {
44
+ echo 'n';
45
+ }
46
+ }else
47
+ {
48
+ echo 'n';
49
+ }
50
+ }
51
+ }
app/code/community/DW/MasterPassword/etc/config.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * DecryptWeb MasterPassword Extension
5
+ *
6
+ * This version may have been modified pursuant
7
+ * to the GNU General Public License, and as distributed it includes or
8
+ * is derivative of works licensed under the GNU General Public License or
9
+ * other free or open source software licenses.
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @category DW
16
+ * @package DW_MasterPassword
17
+ * @copyright Copyright (c) 2013 DecryptWeb (http://www.decryptweb.com) All Rights Reserved.
18
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <DW_MasterPassword>
24
+ <version>1.0.0</version>
25
+ </DW_MasterPassword>
26
+ </modules>
27
+ <frontend>
28
+ <routers>
29
+ <masterpassword>
30
+ <use>standard</use>
31
+ <args>
32
+ <module>DW_MasterPassword</module>
33
+ <frontName>masterpassword</frontName>
34
+ </args>
35
+ </masterpassword>
36
+ </routers>
37
+ </frontend>
38
+ <global>
39
+ <!--below code for overriding the customer model-->
40
+ <!--start-->
41
+ <models>
42
+ <customer>
43
+ <rewrite>
44
+ <customer>DW_MasterPassword_Model_Customer</customer>
45
+ </rewrite>
46
+ </customer>
47
+ </models>
48
+ <blocks>
49
+ <masterpassword>
50
+ <class>DW_MasterPassword_Block</class>
51
+ </masterpassword>
52
+ </blocks>
53
+ <!--end-->
54
+ </global>
55
+ <!--for permissions-->
56
+ <!--start-->
57
+ <adminhtml>
58
+ <acl>
59
+ <resources>
60
+ <all>
61
+ <title>Allow Everything</title>
62
+ </all>
63
+ <admin>
64
+ <children>
65
+ <system>
66
+ <children>
67
+ <config>
68
+ <children>
69
+ <dw_masterpassword translate="title">
70
+ <title>Master Password by DecryptWeb</title>
71
+ <sort_order>50</sort_order>
72
+ </dw_masterpassword>
73
+ </children>
74
+ </config>
75
+ </children>
76
+ </system>
77
+ </children>
78
+ </admin>
79
+ </resources>
80
+ </acl>
81
+ </adminhtml>
82
+ <!--end-->
83
+ </config>
app/code/community/DW/MasterPassword/etc/system.xml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * DecryptWeb MasterPassword Extension
5
+ *
6
+ * This version may have been modified pursuant
7
+ * to the GNU General Public License, and as distributed it includes or
8
+ * is derivative of works licensed under the GNU General Public License or
9
+ * other free or open source software licenses.
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @category DW
16
+ * @package DW_MasterPassword
17
+ * @copyright Copyright (c) 2013 DecryptWeb (http://www.decryptweb.com) All Rights Reserved.
18
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
19
+ */
20
+ -->
21
+ <config>
22
+ <tabs>
23
+ <masterpassword translate="label">
24
+ <label>DecryptWeb Extensions</label>
25
+ <sort_order>999</sort_order>
26
+ </masterpassword>
27
+ </tabs>
28
+ <sections>
29
+ <dw_masterpassword translate="label">
30
+ <class>separator-top</class>
31
+ <label>DW Master Password</label>
32
+ <tab>masterpassword</tab>
33
+ <sort_order>99999</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <groups>
38
+ <default translate="label">
39
+ <label>DW Master Password Settings</label>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>50</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <fields>
46
+ <active translate="label">
47
+ <label>Enable</label>
48
+ <sort_order>1</sort_order>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_yesno</source_model>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>0</show_in_store>
54
+ </active>
55
+ <create translate="label comment">
56
+ <label>Master Password:</label>
57
+ <frontend_type>note</frontend_type>
58
+ <frontend_model>masterpassword/adminhtml_system_config_form_field_hash</frontend_model>
59
+ <sort_order>2</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>0</show_in_store>
63
+ <comment>Enter the master password here</comment>
64
+ <tooltip>Enter the text to be used as master password, this needs to be remembered, as only hash will be stored in database for security. After inserting text click the button 'Generate Hash'.</tooltip>
65
+ </create>
66
+ <!--<tmp_hash translate="label comment">
67
+ <label>Master Password MD5 Hash</label>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>3</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ <comment>Hash generated of inserted password</comment>
74
+ </tmp_hash> -->
75
+ <passhash translate="label comment">
76
+ <label>Master Password MD5:</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>3</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ <comment>MD5 hash generated of master password</comment>
83
+ </passhash>
84
+ </fields>
85
+ </default>
86
+ </groups>
87
+ </dw_masterpassword>
88
+ </sections>
89
+ </config>
app/etc/modules/DW_MasterPassword.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * DecryptWeb MasterPassword Extension
5
+ *
6
+ * This version may have been modified pursuant
7
+ * to the GNU General Public License, and as distributed it includes or
8
+ * is derivative of works licensed under the GNU General Public License or
9
+ * other free or open source software licenses.
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * @category DW
16
+ * @package DW_MasterPassword
17
+ * @copyright Copyright (c) 2013 DecryptWeb (http://www.decryptweb.com) All Rights Reserved.
18
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <DW_MasterPassword>
24
+ <active>true</active>
25
+ <codePool>community</codePool>
26
+ </DW_MasterPassword>
27
+ </modules>
28
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>DW_MasterPassword</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPLv3</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>An extension to implement a master password functionality, that allows you to login as any valid registered customer with one master password</summary>
10
+ <description>An extension to implement a master password functionality, that allows you to login as any valid registered customer with one master password</description>
11
+ <notes>Recommended for every Magento Installation</notes>
12
+ <authors><author><name>DecryptWeb Solutions</name><user>dwweb</user><email>contact@decryptweb.com</email></author></authors>
13
+ <date>2013-09-11</date>
14
+ <time>10:19:23</time>
15
+ <contents><target name="magecommunity"><dir name="DW"><dir name="MasterPassword"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Hash.php" hash="bcbdaaabb2e5a2499876bfa98d4fef44"/></dir></dir></dir></dir></dir></dir><dir name="Model"><file name="Customer.php" hash="6ece4e3e4c420cc5babc494a257fb3d8"/></dir><dir name="controllers"><file name="IndexController.php" hash="91dbd160e7535d0359c0c3523ed33eb2"/></dir><dir name="etc"><file name="config.xml" hash="a46278be2a24ef6d77f23b605a9973f7"/><file name="system.xml" hash="f1d1d812a6ce227ef9648b3fc26d6582"/></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="DW_MasterPassword.xml" hash="d14b6e415d5a744f549da539374fe9c8"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0.2</max></package></required></dependencies>
18
+ </package>