PHP 클래스 Jetpack_Protect_Module, jetpack

파일 보기 프로젝트 열기: automattic/jetpack 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$api_key
$api_key_error
$last_request
$last_response
$last_response_raw
$whitelist
$whitelist_error
$whitelist_saved

공개 메소드들

메소드 설명
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

비공개 메소드들

메소드 설명
__construct ( ) Registers actions

메소드 상세

admin_banner_styles() 공개 메소드

public admin_banner_styles ( )

admin_jetpack_manage_notice() 공개 메소드

block_with_math() 공개 메소드

public block_with_math ( )

check_api_key() 공개 메소드

public check_api_key ( )

check_login_ability() 공개 메소드

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
리턴 boolean Either returns true, fires $this->kill_login, or includes a math fallback and returns false

check_preauth() 공개 메소드

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
리턴 string $user

check_use_math() 공개 메소드

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

configuration_head() 공개 메소드

public configuration_head ( )

configuration_load() 공개 메소드

Get or delete API key
public configuration_load ( )

configuration_screen() 공개 메소드

Prints the configuration screen

delete_transient() 공개 메소드

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.
리턴 boolean true if successful, false otherwise

get_api_host() 공개 메소드

public get_api_host ( )

get_headers() 공개 메소드

..
public get_headers ( ) : string
리턴 string

get_local_host() 공개 메소드

public get_local_host ( )

get_main_blog_id() 공개 메소드

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

get_main_blog_jetpack_id() 공개 메소드

Get jetpack blog id, or the jetpack blog id of the main blog in the main network

get_protect_key() 공개 메소드

Request an api key from wordpress.com
public get_protect_key ( ) : boolean | string
리턴 boolean | string | string

get_transient() 공개 메소드

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.
리턴 mixed Value of transient.

instance() 공개 정적인 메소드

Singleton implementation
public static instance ( ) : object
리턴 object

ip_is_whitelisted() 공개 메소드

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

kill_login() 공개 메소드

* Kill a login attempt
public kill_login ( )

log_failed_attempt() 공개 메소드

Fires custom, plugable action jpp_log_failed_attempt with the IP
public log_failed_attempt ( ) : void
리턴 void

log_successful_login() 공개 메소드

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() 공개 메소드

maybe_get_protect_key() 공개 메소드

maybe_update_headers() 공개 메소드

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() 공개 메소드

Set up the Protect configuration page
public modules_loaded ( )

on_activation() 공개 메소드

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

on_deactivation() 공개 메소드

On module deactivation, unset protect_active
public on_deactivation ( )

prepare_jetpack_protect_multisite_notice() 공개 메소드

protect_call() 공개 메소드

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
리턴 array

set_transient() 공개 메소드

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.
리턴 boolean False if value was not set and true if value was set.

프로퍼티 상세

$api_key 공개적으로 프로퍼티

public $api_key

$api_key_error 공개적으로 프로퍼티

public $api_key_error

$last_request 공개적으로 프로퍼티

public $last_request

$last_response 공개적으로 프로퍼티

public $last_response

$last_response_raw 공개적으로 프로퍼티

public $last_response_raw

$whitelist 공개적으로 프로퍼티

public $whitelist

$whitelist_error 공개적으로 프로퍼티

public $whitelist_error

$whitelist_saved 공개적으로 프로퍼티

public $whitelist_saved