Skip to content

Add security endpoint for public key retrieval and RSA key management#92

Merged
Santiago1010 merged 9 commits into
developfrom
feature/keys
Jan 25, 2026
Merged

Add security endpoint for public key retrieval and RSA key management#92
Santiago1010 merged 9 commits into
developfrom
feature/keys

Conversation

@Santiago1010
Copy link
Copy Markdown
Owner

📋 Summary

This PR introduces a new security endpoint for retrieving the public encryption key and integrates RSA key management with Vault storage. It enables secure encryption/decryption workflows and provides infrastructure for handling sensitive data transmission.

🎯 Type of Change

  • New feature (adds functionality)

🔍 What Changed

Added

  • GET /security/public-key endpoint with controller, service, and routing
  • Security documentation structure with OpenAPI paths
  • Vault-based RSA key management functions in encrypt utility
  • Decrypt middleware for handling encrypted request data
  • Translation keys for showPublicKey endpoint success messages
  • PlantUML diagrams for security endpoints and expanded auth functionality
  • VAULT_PATHS constant for centralized key storage configuration

Changed

  • Updated system structure documentation to reflect new security modules
  • Modified encryption utility to remove verbose comments and integrate dayjs
  • Updated main web router to include security routes
  • Updated documentation paths index to include security endpoints
  • Reformatted i18n JSON files with consistent tab indentation

🧪 Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • All tests passing

Test Instructions:

  1. Start the application and verify RSA keys are initialized in Vault
  2. Access GET /security/public-key endpoint to retrieve public key
  3. Use the public key to encrypt sensitive data on client side
  4. Test the decrypt middleware by sending encrypted data in requests
  5. Verify API documentation includes the new security endpoint

🔗 Related Issues

  • None specified

📝 Additional Notes

  • The RSA key management uses Vault for secure storage and retrieval
  • The public key endpoint enables clients to encrypt sensitive data before transmission
  • The decrypt middleware supports decryption of properties in body, query, and params
  • Key rotation functionality is included for periodic security updates

✅ Checklist

  • Follows project style guidelines
  • Self-reviewed my code
  • Commented complex logic
  • Updated documentation
  • No new warnings
  • Existing and new tests pass locally

- Add vault-based initialization and retrieval for RSA key pairs
- Implement key rotation functionality with timestamps
- Remove verbose header comments from encryption utility
- Add VAULT_PATHS constant for consistent key storage location
- Update dependencies to include vault helper and dayjs
- Create security API documentation structure with OpenAPI paths
- Implement SecurityService with showPublicKey method
- Add public key retrieval using vault integration from encrypt utilities
- Re-enable debug flag for development environment
…endpoint

- Rename SecurityService to KeyService for better semantics
- Create KeyController with showPublicKey endpoint handler
- Move service logic to dedicated keys.service.js file
- Maintain existing functionality with proper error handling
- Create security router module with express router
- Register GET /security/public-key route using KeyController
- Integrate security routes into main web router
- Add security directory with public-key endpoint diagrams
- Expand auth directory with new 2FA and device management diagrams
- Rename verify-code related files for consistency
- Update total file and directory counts in structure.txt
- Add success message key for showPublicKey endpoint in both en and es locales
- Wrap public key response in data object structure in controller
- Reformat JSON files with tabs for consistent indentation
- Create decrypt.middleware.js with decryptSensitiveData function
- Support decryption of properties across body, query, and params
- Use RSA private key from vault for decryption operations
- Handle error cases with descriptive error messages
- Add decrypt.middleware.js to middlewares/security directory listing
- Adjust total file count in structure.txt
@Santiago1010 Santiago1010 self-assigned this Jan 24, 2026
@Santiago1010 Santiago1010 added enhancement New feature or request developer experience Tasks that are responsible for making development easier. labels Jan 24, 2026
  Auto-generated by GitHub Actions workflow
  PR: #92
  Workflow: Auto Version & Changelog
  Run ID: 21323896941
@github-actions
Copy link
Copy Markdown

🚀 Auto-versioning complete!

📦 New version: 1.20.0
📋 CHANGELOG.md and package.json updated
👤 Author: Santiago1010
✅ Approved by: DiegoAlejandroNino

This PR is ready for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

developer experience Tasks that are responsible for making development easier. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provision a global RSA key pair for client-side password encryption (front-end uses public key)

3 participants