PHP Class Jetpack_Protect_Module, jetpack

Afficher le fichier Open project: automattic/jetpack Class Usage Examples

Méthodes publiques

Свойство Type Description
$api_key
$api_key_error
$last_request
$last_response
$last_response_raw
$whitelist
$whitelist_error
$whitelist_saved

Méthodes publiques

Méthode Description
admin_banner_styles ( )
admin_jetpack_manage_notice ( )
block_with_math ( )
check_api_key ( )
check_login_ability ( boolean $preauth = false ) : boolean Checks the status for a given IP. API results are cached as transients
check_preauth ( string $user = 'Not Used By Protect', string $username = 'Not Used By Protect', string $password = 'Not Used By Protect' ) : string Checks for loginability BEFORE authentication so that bots don't get to go around the log in form.
check_use_math ( ) * Checks if the protect API call has failed, and if so initiates the math captcha fallback.
configuration_head ( )
configuration_load ( ) Get or delete API key
configuration_screen ( ) Prints the configuration screen
delete_transient ( string $transient ) : boolean Wrapper for WordPress delete_transient function, our version deletes the transient on the main site in the network if this is a multisite network
get_api_host ( )
get_headers ( ) : string Get all IP headers so that we can process on our server.
get_local_host ( )
get_main_blog_id ( ) : integer If we're in a multisite network, return the blog ID of the primary blog
get_main_blog_jetpack_id ( ) : integer Get jetpack blog id, or the jetpack blog id of the main blog in the main network
get_protect_key ( ) : boolean | string Request an api key from wordpress.com
get_transient ( string $transient ) : mixed Wrapper for WordPress get_transient function, our version gets the transient on the main site in the network if this is a multisite network
instance ( ) : object Singleton implementation
ip_is_whitelisted ( $ip ) * Checks if the IP address has been whitelisted
kill_login ( ) * Kill a login attempt
log_failed_attempt ( ) : void Called via WP action wp_login_failed to log failed attempt with the api
log_successful_login ( $user_login, $user ) Logs a successful login back to our servers, this allows us to make sure we're not blocking a busy IP that has a lot of good logins along with some forgotten passwords. Also saves current user's ip to the ip address whitelist
maybe_display_security_warning ( )
maybe_get_protect_key ( )
maybe_update_headers ( $force = false ) Sends a "check_key" API call once a day. This call allows us to track IP-related headers for this server via the Protect API, in order to better identify the source IP for login attempts
modules_loaded ( ) Set up the Protect configuration page
on_activation ( ) On module activation, try to get an api key
on_deactivation ( ) On module deactivation, unset protect_active
prepare_jetpack_protect_multisite_notice ( )
protect_call ( string $action = 'check_ip', array $request = [] ) : array Calls over to the api using wp_remote_post
set_transient ( string $transient, mixed $value, integer $expiration ) : boolean Wrapper for WordPress set_transient function, our version sets the transient on the main site in the network if this is a multisite network

Private Methods

Méthode Description
__construct ( ) Registers actions

Method Details

admin_banner_styles() public méthode

public admin_banner_styles ( )

admin_jetpack_manage_notice() public méthode

block_with_math() public méthode

public block_with_math ( )

check_api_key() public méthode

public check_api_key ( )

check_login_ability() public méthode

Checks the status for a given IP. API results are cached as transients
public check_login_ability ( boolean $preauth = false ) : boolean
$preauth boolean Whether or not we are checking prior to authorization
Résultat boolean Either returns true, fires $this->kill_login, or includes a math fallback and returns false

check_preauth() public méthode

If we are using our math fallback, authenticate via math-fallback.php
public check_preauth ( string $user = 'Not Used By Protect', string $username = 'Not Used By Protect', string $password = 'Not Used By Protect' ) : string
$user string
$username string
$password string
Résultat string $user

check_use_math() public méthode

* Checks if the protect API call has failed, and if so initiates the math captcha fallback.
public check_use_math ( )

configuration_head() public méthode

public configuration_head ( )

configuration_load() public méthode

Get or delete API key
public configuration_load ( )

configuration_screen() public méthode

Prints the configuration screen

delete_transient() public méthode

Wrapper for WordPress delete_transient function, our version deletes the transient on the main site in the network if this is a multisite network
public delete_transient ( string $transient ) : boolean
$transient string Transient name. Expected to not be SQL-escaped.
Résultat boolean true if successful, false otherwise

get_api_host() public méthode

public get_api_host ( )

get_headers() public méthode

..
public get_headers ( ) : string
Résultat string

get_local_host() public méthode

public get_local_host ( )

get_main_blog_id() public méthode

If we're in a multisite network, return the blog ID of the primary blog
public get_main_blog_id ( ) : integer
Résultat integer

get_main_blog_jetpack_id() public méthode

Get jetpack blog id, or the jetpack blog id of the main blog in the main network
public get_main_blog_jetpack_id ( ) : integer
Résultat integer

get_protect_key() public méthode

Request an api key from wordpress.com
public get_protect_key ( ) : boolean | string
Résultat boolean | string | string

get_transient() public méthode

Wrapper for WordPress get_transient function, our version gets the transient on the main site in the network if this is a multisite network
public get_transient ( string $transient ) : mixed
$transient string Transient name. Expected to not be SQL-escaped.
Résultat mixed Value of transient.

instance() public static méthode

Singleton implementation
public static instance ( ) : object
Résultat object

ip_is_whitelisted() public méthode

* Checks if the IP address has been whitelisted
public ip_is_whitelisted ( $ip )
$ip

kill_login() public méthode

* Kill a login attempt
public kill_login ( )

log_failed_attempt() public méthode

Fires custom, plugable action jpp_log_failed_attempt with the IP
public log_failed_attempt ( ) : void
Résultat void

log_successful_login() public méthode

Logs a successful login back to our servers, this allows us to make sure we're not blocking a busy IP that has a lot of good logins along with some forgotten passwords. Also saves current user's ip to the ip address whitelist
public log_successful_login ( $user_login, $user )

maybe_display_security_warning() public méthode

maybe_get_protect_key() public méthode

maybe_update_headers() public méthode

Sends a "check_key" API call once a day. This call allows us to track IP-related headers for this server via the Protect API, in order to better identify the source IP for login attempts
public maybe_update_headers ( $force = false )

modules_loaded() public méthode

Set up the Protect configuration page
public modules_loaded ( )

on_activation() public méthode

On module activation, try to get an api key
public on_activation ( )

on_deactivation() public méthode

On module deactivation, unset protect_active
public on_deactivation ( )

prepare_jetpack_protect_multisite_notice() public méthode

protect_call() public méthode

Calls over to the api using wp_remote_post
public protect_call ( string $action = 'check_ip', array $request = [] ) : array
$action string 'check_ip', 'check_key', or 'failed_attempt'
$request array Any custom data to post to the api
Résultat array

set_transient() public méthode

We do it this way (instead of set_site_transient) because of an issue where sitewide transients are always autoloaded https://core.trac.wordpress.org/ticket/22846
public set_transient ( string $transient, mixed $value, integer $expiration ) : boolean
$transient string Transient name. Expected to not be SQL-escaped. Must be 45 characters or fewer in length.
$value mixed Transient value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
$expiration integer Optional. Time until expiration in seconds. Default 0.
Résultat boolean False if value was not set and true if value was set.

Property Details

$api_key public_oe property

public $api_key

$api_key_error public_oe property

public $api_key_error

$last_request public_oe property

public $last_request

$last_response public_oe property

public $last_response

$last_response_raw public_oe property

public $last_response_raw

$whitelist public_oe property

public $whitelist

$whitelist_error public_oe property

public $whitelist_error

$whitelist_saved public_oe property

public $whitelist_saved