Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/jetpack protect #1501

Merged
merged 157 commits into from
Feb 2, 2015
Merged

Add/jetpack protect #1501

merged 157 commits into from
Feb 2, 2015

Conversation

roccotripaldi
Copy link
Member

No description provided.

Adding a function to get the jetpack blog id, or the jetpack blog
id of the main blog in a network.
For the duration of development, i'll be using my .com sandbox
for obtaining a jetpack protect key.
Adding some params to our request to .com for an api key. Sending
them the blog id ( or the blog id of the main blog in the network ),
the bruteprotect api key ( if one exists ), and the number of sites
in their network.
Adding an endpoint to get the whitelist. The whitelist will be stored as a
site option. This allows us, if we are on multisite, to have one option that
applies to the entire network.
Added a new POST endpoint for updating a site's protect whitelist.
I still need to add some IP Address validation.
Adding proper parameters to the validate_input method. It needs
to match the parent class in order to jibe with Travis CI.
in a previous commit, i changed the api base to my dotcom sandbox.
i realize that it is not a good practice, so i'm changing it back.
from now on i'll do this in wp-config.php
On activation, if we can't find the main blog id, that means we are
on multisite, and the main blog hasn't connected to Jetpack. If this
is the case, we will bail on getting the protect api key.

since there will be cases where getting the protect api key will fail,
we'll need to make a configuration page for this module that will give
more information, and give them a chance to retry. the next commits will
focus on the config page.
Getting an api key for protect is now in its own function.
adding in some more error checking and saving the api key to a
site option.
I'm adding the standard configuration logic to the module so we can
ensure that they received an api key and their site is protected.
If there was an error getting their api key, they'll be able to use
the configuration screen to retry.
I've decided that I do not want to automatiaclly deactivate bruteprotect
when Protect is activated. There's a small chance there could be an error
while generating a key for Protect, in which case the site could be without
protection. I'm going to build some custom logic for deactivating bruteprotect.
moving the config ui to it's own file as it's about to grow a bit
On the protect config page, adding some javascript functionallity
to the whitelist management form
@georgestephanis
Copy link
Member

@roccotripaldi: I'm seeing a lot of JSHint errors on protect.js -- you can check by running grunt jshint on your branch to see them.

They're all mostly trivial (I think nearly all are just using doublequote strings instead of singlequote), but should be tidied before merging.

Running "jshint:src" (jshint) task

   modules/protect/protect.js
      6 |    jQuery( "#editable-whitelist").on( "click", ".delete-ip-address", function() {
                                          ^ Strings must use singlequote.
      6 |    jQuery( "#editable-whitelist").on( "click", ".delete-ip-address", function() {
                                                       ^ Strings must use singlequote.
      6 |    jQuery( "#editable-whitelist").on( "click", ".delete-ip-address", function() {
                                                                             ^ Strings must use singlequote.
      7 |        var id = jQuery( this).data( "id" );
                                                  ^ Strings must use singlequote.
      8 |        jQuery("#editable-whitelist #row-" + id).detach();
                                                   ^ Strings must use singlequote.
     12 |    jQuery( ".ip-add" ).click( function() {
                              ^ Strings must use singlequote.
     13 |        var template = jQuery( this).data( "template" );
                                                              ^ Strings must use singlequote.
     14 |        var row = _.template(
                     ^ Too many var statements.
     15 |            jQuery("script." + template ).html()
                                     ^ Strings must use singlequote.
     17 |        jQuery( ".editable-whitelist-rows").append( row( { id : "new" + whitelist_item_index } ) );
                                                   ^ Strings must use singlequote.
     17 |        jQuery( ".editable-whitelist-rows").append( row( { id : "new" + whitelist_item_index } ) );
                                                                              ^ Strings must use singlequote.
     24 |    jQuery( "#whitelist-save-button" ).removeAttr( "disabled" );
                                             ^ Strings must use singlequote.
     24 |    jQuery( "#whitelist-save-button" ).removeAttr( "disabled" );
                                                                      ^ Strings must use singlequote.
      3 |function protectInit() {
                             ^ 'protectInit' is defined but never used.

>> 14 errors in 52 files
Warning: Task "jshint:src" failed. Used --force, continuing.

Done, but with warnings.

@jeherve jeherve added [Feature] Protect Also known as Brute Force Attack Protection [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it labels Jan 15, 2015
@jeherve jeherve added this to the 3.4 milestone Jan 15, 2015
adding a way to pre-popluate your site with a placeholder whitelist.
This will allow jeff golenski to have some stuff to style!
@roccotripaldi
Copy link
Member Author

+1 George. Thanks for catching that.

Copied blocking mechanisms from the BruteProtect plugin, and refactored
them into the Protect module.
samhotchkiss and others added 26 commits January 30, 2015 13:32
We need to de-increment available attempts if user proved humanity through math
get_ip() will be needed by both the module and the endpoint
…nto add/jetpack-protect

Conflicts:
	modules/protect.php
now that we've moved the get_ip function out of a class, we need
to re-structure it.
I'd like to include the current user's ip in the endpoint response.
Also fixing a translation string.
Styled whitelist config textarea
another text area adjustment
Loading widget styles only on initial dashboard, rather than all admin
pages.
Link to wordpress.com to enable file scanning
Conflicts:
	css/jetpack-admin-rtl.css
	css/jetpack-admin-rtl.min.css
	css/jetpack-admin.css.map
	css/jetpack-admin.min.css
	css/jetpack-admin.min.css.map
	css/jetpack-rtl.css
	css/jetpack.css
Let's use a site_option for 'jetpack_file_scanning_enabled' and
'jetpack_protect_blocked_attempts' because they will apply to
the entire network on multisite installs
removing inline styles from config_ui.php, added to protect css. (grunt
added new styles, not sure exactly what they are)
Adding a conditional notification that tells user if the protect
module is configured properly.
samhotchkiss added a commit that referenced this pull request Feb 2, 2015
@samhotchkiss samhotchkiss merged commit 4773a7f into master Feb 2, 2015
@samhotchkiss samhotchkiss deleted the add/jetpack-protect branch April 15, 2015 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Protect Also known as Brute Force Attack Protection [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants