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

Whitelist Auth0 IPs by default and show in wp-admin #596

Merged
merged 1 commit into from
Dec 6, 2018

Conversation

joshcanhelp
Copy link
Contributor

Changes

  • Migration endpoints will always whitelist Auth0 IPs if whitelist filter is turned on.
  • IP whitelist setting in wp-admin shows the Auth0 IPs being whitelisted (see screenshot below).
  • DB migration to remove default IPs from the migration IP setting.

References

Setting shows default IPs

screenshot 2018-12-01 08 08 32

Testing

  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language

Checklist

  • All existing and new tests complete without errors
  • All code quality tools/guidelines in the Contribution guide have been run/followed
  • All active GitHub CI checks have passed

@joshcanhelp joshcanhelp added this to the 3.9.0 milestone Dec 1, 2018
@joshcanhelp joshcanhelp changed the title Whitelist Auth0 IPs by default; DB migration; show Auth0 IPs on admin Whitelist Auth0 IPs by default and show in wp-admin Dec 1, 2018
@@ -81,17 +81,6 @@ public function install_db( $version_to_install = null, $app_token = '' ) {
}
}

if ( $this->current_db_version < 13 ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration is handled in v20 added below.

public function get_ips_by_domain( $domain ) {
return $this->get_ip_by_region( WP_Auth0::get_tenant_region( $domain ) );
public function get_ips_by_domain( $domain = null, $glue = self::IP_STRING_GLUE ) {
if ( empty( $domain ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default to current domain if none passed in.

*
* @return string
*/
public function get_ip_by_region( $region ) {
return implode( ',', $this->valid_webtask_ips[ $region ] );
public function get_ip_by_region( $region, $glue = self::IP_STRING_GLUE ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow the glue to be customized.

}

return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable return line.

protected function process_ip_list( $ip_list ) {
$raw = explode( ',', $ip_list );
$raw = is_array( $ip_list ) ? $ip_list : explode( self::IP_STRING_GLUE, $ip_list );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow array and string

return true;
}
}

return false;
}

/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only moved and docblocks added, no functionality change.

@@ -182,14 +252,11 @@ private function validate_ip() {
return false;
}

private function in_range( $ip, $range ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved ☝️

@@ -105,7 +105,7 @@ public function init() {
'function' => 'render_migration_ws_ips_filter',
),
array(
'name' => __( 'IP Addresses', 'wp-auth0' ),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary label for this field (see screenshot)

@@ -231,7 +231,8 @@ protected function render_radio_buttons( array $buttons, $id, $input_name, $curr
* @param string $text - description text to display
*/
protected function render_field_description( $text ) {
printf( '<div class="subelement"><span class="description">%s.</span></div>', $text );
$period = ! in_array( $text[ strlen( $text ) - 1 ], array( '.', ':', '>' ) ) ? '.' : '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not add a period if the final char is a period, colon, or open angle bracket

cocojoe
cocojoe previously approved these changes Dec 6, 2018
}
}

/**
* Test a DB upgrade from v19 to v20.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful 🌅

@codecov-io
Copy link

Codecov Report

Merging #596 into master will increase coverage by 1.3%.
The diff coverage is 87.8%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #596     +/-   ##
===========================================
+ Coverage     28.56%   29.87%   +1.3%     
+ Complexity     1309     1305      -4     
===========================================
  Files            52       52             
  Lines          4201     4178     -23     
===========================================
+ Hits           1200     1248     +48     
+ Misses         3001     2930     -71
Impacted Files Coverage Δ Complexity Δ
WP_Auth0.php 22.36% <ø> (ø) 62 <0> (ø) ⬇️
lib/admin/WP_Auth0_Admin_Advanced.php 19.54% <0%> (+0.05%) 64 <0> (ø) ⬇️
lib/WP_Auth0_DBManager.php 21.33% <100%> (+2.94%) 86 <0> (+4) ⬆️
lib/WP_Auth0_Ip_Check.php 100% <100%> (+91.54%) 16 <8> (-10) ⬇️
lib/admin/WP_Auth0_Admin_Generic.php 44.35% <100%> (+0.45%) 46 <0> (+1) ⬆️
lib/WP_Auth0_Options_Generic.php 96.55% <100%> (+0.25%) 27 <1> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60df121...cd29681. Read the comment docs.

Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@joshcanhelp joshcanhelp merged commit bc69645 into master Dec 6, 2018
@joshcanhelp joshcanhelp deleted the fix-migration-ip-filter branch December 6, 2018 15:56
@stale stale bot added the closed:stale label Oct 26, 2019
@auth0 auth0 deleted a comment from stale bot Oct 28, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants