BranchLabs_AdminPasswordStrength - Version 1.0.0

Version Notes

Initial release

Download this release

Release Info

Developer BranchLabs
Extension BranchLabs_AdminPasswordStrength
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/BranchLabs/AdminPasswordStrength/Helper/Data.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ class BranchLabs_AdminPasswordStrength_Helper_Data extends Mage_Core_Helper_Abstract {}
app/code/community/BranchLabs/AdminPasswordStrength/Model/Observer.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BranchLabs_AdminPasswordStrength_Model_Observer {
3
+
4
+ // The admin 'Forgot Password' page is constructed in a weird way—without any layout handles.
5
+ // I've resorted to an observer that creates and appends the JS validator block to get updated
6
+ // functionality onto that page.
7
+ public function addValidationToForgotAdminPassword($observer) {
8
+ $template = $observer->getEvent()->getBlock()->getTemplate();
9
+ if($template === "resetforgottenpassword.phtml") {
10
+ $normalOutput = $observer->getTransport()->getHtml();
11
+ $validator = Mage::app()->getLayout()
12
+ ->createBlock('adminhtml/template')
13
+ ->setTemplate('branchlabs/adminpasswordstrength/validator_js.phtml')
14
+ ->toHtml();
15
+ $observer->getTransport()->setHtml($normalOutput . $validator);
16
+ }
17
+ }
18
+ }
app/code/community/BranchLabs/AdminPasswordStrength/etc/config.xml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <BranchLabs_AdminPasswordStrength>
5
+ <version>1.0.0</version>
6
+ </BranchLabs_AdminPasswordStrength>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <branchlabs_adminpasswordstrength>
11
+ <class>BranchLabs_AdminPasswordStrength_Block</class>
12
+ </branchlabs_adminpasswordstrength>
13
+ </blocks>
14
+ <helpers>
15
+ <branchlabs_adminpasswordstrength>
16
+ <class>BranchLabs_AdminPasswordStrength_Helper</class>
17
+ </branchlabs_adminpasswordstrength>
18
+ </helpers>
19
+ <models>
20
+ <branchlabs_adminpasswordstrength>
21
+ <class>BranchLabs_AdminPasswordStrength_Model</class>
22
+ </branchlabs_adminpasswordstrength>
23
+ </models>
24
+ </global>
25
+ <adminhtml>
26
+ <layout>
27
+ <updates>
28
+ <branchlabs_adminpasswordstrength>
29
+ <file>branchlabs/adminpasswordstrength.xml</file>
30
+ </branchlabs_adminpasswordstrength>
31
+ </updates>
32
+ </layout>
33
+ <events>
34
+ <core_block_abstract_to_html_after>
35
+ <observers>
36
+ <add_custom_admin_password_strength_validatior>
37
+ <class>BranchLabs_AdminPasswordStrength_Model_Observer</class>
38
+ <method>addValidationToForgotAdminPassword</method>
39
+ </add_custom_admin_password_strength_validatior>
40
+ </observers>
41
+ </core_block_abstract_to_html_after>
42
+ </events>
43
+ <acl>
44
+ <resources>
45
+ <admin>
46
+ <children>
47
+ <system>
48
+ <children>
49
+ <config>
50
+ <children>
51
+ <adminpasswordstrength>
52
+ <title>Admin Password Strength Settings</title>
53
+ </adminpasswordstrength>
54
+ </children>
55
+ </config>
56
+ </children>
57
+ </system>
58
+ </children>
59
+ </admin>
60
+ </resources>
61
+ </acl>
62
+ </adminhtml>
63
+ <default>
64
+ <adminpasswordstrength>
65
+ <adminpasswordstrength_group>
66
+ <minimum_character_length>10</minimum_character_length>
67
+ </adminpasswordstrength_group>
68
+ </adminpasswordstrength>
69
+ </default>
70
+ </config>
app/code/community/BranchLabs/AdminPasswordStrength/etc/system.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <branchlabs translate="label" module="branchlabs_adminpasswordstrength">
5
+ <label>BranchLabs</label>
6
+ <sort_order>100</sort_order>
7
+ </branchlabs>
8
+ </tabs>
9
+ <sections>
10
+ <adminpasswordstrength translate="label" module="branchlabs_adminpasswordstrength">
11
+ <label>Admin Password Strength</label>
12
+ <tab>branchlabs</tab>
13
+ <sort_order>1000</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>0</show_in_website>
16
+ <show_in_store>0</show_in_store>
17
+ <groups>
18
+ <adminpasswordstrength_group translate="label" module="branchlabs_adminpasswordstrength">
19
+ <label>Admin Password Strength Settings</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>1000</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>0</show_in_website>
24
+ <show_in_store>0</show_in_store>
25
+ <fields>
26
+ <minimum_character_length translate="label">
27
+ <label>Minimum character length: </label>
28
+ <comment>Must be greater than 7.</comment>
29
+ <frontend_type>text</frontend_type>
30
+ <validate>validate-digits</validate>
31
+ <sort_order>20</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>0</show_in_website>
34
+ <show_in_store>0</show_in_store>
35
+ </minimum_character_length>
36
+ </fields>
37
+ </adminpasswordstrength_group>
38
+ </groups>
39
+ </adminpasswordstrength>
40
+ </sections>
41
+ </config>
app/design/adminhtml/default/default/layout/branchlabs/adminpasswordstrength.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+ <!-- Admin user edit/create page under System > Permissions > Users -->
5
+ <adminhtml_permissions_user_edit>
6
+ <reference name="js">
7
+ <block type="adminhtml/template" name="adminhtml.permissions.admin.password.validation.js" template="branchlabs/adminpasswordstrength/validator_js.phtml"/>
8
+ </reference>
9
+ </adminhtml_permissions_user_edit>
10
+
11
+ <!-- 'My Account' page under the System dropdown -->
12
+ <adminhtml_system_account_index>
13
+ <reference name="content">
14
+ <block type="adminhtml/template" name="adminhtml.permissions.admin.password.validation.js" template="branchlabs/adminpasswordstrength/validator_js.phtml"/>
15
+ </reference>
16
+ </adminhtml_system_account_index>
17
+
18
+ </layout>
app/design/adminhtml/default/default/template/branchlabs/adminpasswordstrength/validator_js.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $l = Mage::getStoreConfig('adminpasswordstrength/adminpasswordstrength_group/minimum_character_length');
3
+ $l = (is_numeric($l) && $l >= 7) ? $l : 7;
4
+ ?>
5
+ <script type="text/javascript">
6
+ if(typeof Validation == "function" && typeof Validation.addAllThese == "function" ) {
7
+ Validation.addAllThese([
8
+ ['validate-admin-password', 'Please enter <?php echo $l; ?> or more characters. Password should contain both numeric and alphabetic characters.', function(v) {
9
+ var pass=v.strip();
10
+ if (0 == pass.length) {
11
+ return true;
12
+ }
13
+ if (!(/[a-z]/i.test(v)) || !(/[0-9]/.test(v))) {
14
+ return false;
15
+ }
16
+ return !(pass.length < <?php echo $l; ?>);
17
+ }]
18
+ ]);
19
+ }
20
+ </script>
app/etc/modules/BranchLabs_AdminPasswordStrength.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <BranchLabs_AdminPasswordStrength>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends></depends>
8
+ </BranchLabs_AdminPasswordStrength>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>BranchLabs_AdminPasswordStrength</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Apache Software License (ASL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Get control over your Magento admin security to prevent unwanted attackers from gaining access.</summary>
10
+ <description>Prevent unwanted attackers from gaining access to your Magento admin panel through brute-force attacks. This extension enables you to increase the minimum password length for admin users, making them harder to guess and your admin panel more secure.</description>
11
+ <notes>Initial release</notes>
12
+ <authors><author><name>BranchLabs</name><user>glipsman</user><email>graham@branchlabs.com</email></author></authors>
13
+ <date>2015-07-09</date>
14
+ <time>20:50:11</time>
15
+ <contents><target name="magecommunity"><dir name="BranchLabs"><dir name="AdminPasswordStrength"><dir name="Helper"><file name="Data.php" hash="1282ac9e6581e6dd3f8d3f5334fa11c7"/></dir><dir name="Model"><file name="Observer.php" hash="2cd620007fda6ba7639691bf3c71ff53"/></dir><dir name="etc"><file name="config.xml" hash="62b0ad06a25986d4014c4c66784d36d5"/><file name="system.xml" hash="f067cf23f53283ceb6a81ab914308abf"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="branchlabs"><file name="adminpasswordstrength.xml" hash="de296b573d633a7cb5afdc7f11b652be"/></dir></dir><dir name="template"><dir name="branchlabs"><dir name="adminpasswordstrength"><file name="validator_js.phtml" hash="23fc9d3811f77bc4dc059d0d0e858dc6"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BranchLabs_AdminPasswordStrength.xml" hash="8f987692d997192f9fef71db85f22ec0"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
18
+ </package>