Wordpress WooCommerce REST API客户身份验证

Wordpress WooCommerce REST API客户身份验证,wordpress,woocommerce,hook-woocommerce,wordpress-rest-api,woocommerce-rest-api,Wordpress,Woocommerce,Hook Woocommerce,Wordpress Rest Api,Woocommerce Rest Api,关于这一点,到处都有很多问题,但没有一个得到回答。WooCommerce不支持通过用户名和密码进行基于客户的身份验证 我们可以创建API密钥来访问woo commerce上的数据,但不限于每个用户。一旦访问API,所有客户的信息都可以访问。(不相关,但我使用的是nativescript,所以如果代码是反编译的,那么所有消费者机密等都可以访问,因为它是一个javascript文件。所以我不能使用它。) 有人试图让WooCommerce接受他的请求,但显然被拒绝了。他创建了一个端点,用用户名和密码对

关于这一点,到处都有很多问题,但没有一个得到回答。WooCommerce不支持通过用户名和密码进行基于客户的身份验证

我们可以创建API密钥来访问woo commerce上的数据,但不限于每个用户。一旦访问API,所有客户的信息都可以访问。(不相关,但我使用的是nativescript,所以如果代码是反编译的,那么所有消费者机密等都可以访问,因为它是一个javascript文件。所以我不能使用它。)

有人试图让WooCommerce接受他的请求,但显然被拒绝了。他创建了一个端点,用用户名和密码对客户进行身份验证

链接如下:

我的问题是,如果在访问API时使用HTTPS,这有多安全

是否可以利用DDOS攻击来查找密码等。? 我应该添加一个额外的代码,比如sleep(1000)(可能不是最聪明的方式)来降低身份验证的速度,这样密码就不能通过迭代破解了

什么是最好的、安全的、简单的方法来仅对客户的数据进行身份验证

代码如下所示:

/**
 * Login a customer
 *
 * @since 2.2
 * @param array $data
 * @return array
 */
public function login_customer( $data ) {

    // Checks the username.
    if ( ! isset( $data['username'] ) ) {
        return new WP_Error( 'woocommerce_api_missing_customer_username', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'username' ), array( 'status' => 400 ) );
    }

    // Checks the password.
    if ( ! isset( $data['password'] ) ) {
        return new WP_Error( 'woocommerce_api_missing_customer_password', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'password' ), array( 'status' => 400 ) );
    }

    // Attempts to login customer
    $credentials = array();
    $credentials['user_login'] = $data['username'];
    $credentials['user_password'] = $data['password'];
    $credentials['remember'] = true;
    $user = wp_signon( $credentials, false );

    // Checks for an error in the customer login.
    if ( is_wp_error( $user) ) {
        return new WP_Error( 'woocommerce_api_cannot_login_customer', $user->get_error_message(), array( 'status' => 400 ) );
    }

    do_action( 'woocommerce_api_login_customer', $user );

    $this->server->send_status( 201 );

    return $this->get_customer( $user->ID );
}
可能重复的