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

feat: add key management API integration to SDK #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

subhayu99
Copy link

Motivation

I needed to use the KMS key management capabilities in the SDK, but since they were not available, I implemented the feature myself based on the existing REST API. If this can be reviewed and merged ASAP, it would be greatly helpful for my ongoing work.


Key Changes:

  • New Data Models Added (api_types.py):

    • BaseKey, ListKey, ListKeysResponse, SingleKeyResponse, EncryptDataResponse, DecryptDataResponse.
    • These models represent responses from the REST API for KMS key management operations.
  • Key Management Client (client.py):

    • Added the V1Keys class to handle KMS key management operations via the REST API.
    • Methods implemented:
      • list_keys: List keys with pagination, search, and sorting support.
      • create_key: Create a new KMS key with optional description and encryption algorithm specification.
      • update_key: Update key attributes such as name, description, and active status.
      • delete_key: Delete a KMS key. (Note: The DELETE endpoint returned a 500 Internal Server Error during testing.)
      • encrypt_data: Encrypt plaintext using a specified KMS key.
      • decrypt_data: Decrypt ciphertext using a specified KMS key.
    • The V1Keys class has been integrated into the InfisicalSDKClient as self.keys.

Impact:

  • Expands the SDK's capabilities by integrating key lifecycle management and encryption operations using the REST API.
  • Enables direct interaction with KMS endpoints for secure key handling and data encryption.

Testing:

  • Verified REST API interactions for key creation, update, encryption, and decryption.
  • Known Issue: The DELETE endpoint returned a 500 Internal Server Error during testing, preventing successful validation of the delete_key method.

Next Steps:

  • Confirm the DELETE endpoint issue with the API team.
  • Verify compatibility with existing SDK features.
  • Update the documentation with usage examples for key management.
  • Add additional test coverage for edge cases once the DELETE endpoint issue is resolved.

- Added support for KMS key lifecycle (list, create, update, delete) via `V1Keys`.
- Implemented encryption and decryption using KMS keys.
- Updated `api_types.py` and `client.py` for key management functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant