Skip to content

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.
@subhayu99
Copy link
Author

@maidul98, @DanielHougaard

If you guys have time, please review this PR.

@varonix0
Copy link
Member

varonix0 commented Apr 1, 2025

Hi @subhayu99, this was added in #28, so I will close this PR. Thank you for the contribution!

@varonix0 varonix0 closed this Apr 1, 2025
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.

2 participants