+

Getting Started (3)

+

Ai Configuration (6)

+

Woocommerce Integration (5)

+

Chatbot Implementation (3)

+

Customization (2)

+

Conversation Management (2)

+

Chatbot Menu Settings (4)

API Key Security

Reading Time: 3 minutes

Overview

The WPiko Chatbot plugin relies on an API key to communicate with OpenAI’s services. Properly securing this API key is crucial to prevent unauthorized access, protect your OpenAI account, and ensure the integrity of your chatbot service.

API Key Storage

Encrypted Storage:

  • The plugin encrypts the API key before storing it in the WordPress database.
  • Encryption is performed using WordPress’s built-in wp_salt('auth') function and the AES-256-CBC encryption method.
  • Database Location:

  • The encrypted API key is stored in the WordPress options table.
  • The option name used is wpiko_chatbot_api_key.
  • Key Management

    Setting the API Key:

  • The API key is set through the plugin’s admin interface.
  • Navigate to WPiko Chatbot > API Key in the WordPress admin panel.
  • Updating the Key:

  • You can update the API key at any time through the same interface.
  • The old key is immediately overwritten with the new encrypted key.
  • Viewing the Key:

  • For security reasons, the full API key is never displayed in the admin interface.
  • Only the last 5 characters of the key are shown for verification purposes.
  • Deleting the Key:

  • An option to delete the API key is provided in the admin interface.
  • This completely removes the key from the database.
  • Security Measures

    Encryption:

  • The API key is encrypted using a strong, industry-standard encryption method.
  • The encryption key is unique to each WordPress installation.
  • Access Control:

  • Only users with the manage_options capability (typically administrators) can view or modify the API key settings.
  • Nonce Protection:

  • All API key operations (save, update, delete) are protected with WordPress nonces to prevent CSRF attacks.
  • No Client-Side Exposure:

  • The API key is never sent to the client-side JavaScript, preventing exposure in the browser.
  • Secure Communication:

  • All API calls to OpenAI are made server-side over HTTPS, ensuring the key is not exposed during transmission.
  • Best Practices for API Key Management

    Regular Rotation:

  • Periodically change your OpenAI API key, especially if you suspect it might have been compromised.
  • Least Privilege:

  • Use an API key with the minimum necessary permissions for the chatbot functionality.
  • Monitoring:

  • Regularly monitor your OpenAI account for any unusual activity or unexpected charges.
  • Secure WordPress Installation:

  • Keep WordPress, all plugins, and themes up-to-date to prevent security vulnerabilities.
  • Use strong, unique passwords for all admin accounts.
  • Limited Access:

  • Restrict the number of users who have access to the API key settings in WordPress.
  • Secure Hosting Environment:

  • Ensure your web hosting environment is secure and up-to-date.
  • Use SSL/TLS for your WordPress site to encrypt all data in transit.
  • What to Do If Your Key Is Compromised

    If you suspect your API key has been compromised:

  • Immediately regenerate a new API key in your OpenAI account.
  • Update the key in the WPiko Chatbot settings.
  • Review your OpenAI account for any unauthorized usage.
  • Investigate the cause of the compromise and take steps to prevent future occurrences.
  • Developer Notes

    For developers customizing or extending the plugin:

  • Always use the wpiko_chatbot_decrypt_api_key() function to retrieve the decrypted API key.
  • Never store the decrypted API key in logs, session data, or any other unsecured location.
  • If implementing custom API calls, ensure they are always made server-side.
  • Audit and Compliance

    • Regularly audit your API key usage and security measures.
    • Ensure your API key handling complies with relevant security standards and regulations in your industry or region.

    By following these security measures and best practices, you can significantly reduce the risk of API key compromise and ensure the secure operation of your WPiko Chatbot. Remember that API key security is an ongoing process that requires regular attention and updates to maintain its effectiveness.