- Security best practice: Regular rotation reduces the risk if a key is compromised
- Compliance requirements: Many security frameworks require periodic credential rotation
- Access control: Remove access for departed team members or deprecated services
-
Determine rotation schedule:
- Set a regular schedule (e.g., quarterly)
- Document the process in your security procedures
-
Identify dependencies:
- Map all services and applications using the current API key
- Ensure you have access to update configurations in all locations
-
Generate a new API key:
python nylas_api_key_generator.py create --name "production-key-YYYY-MM-DD" --expires 7776000
- Use a descriptive name with date for tracking
- Set an appropriate expiration (e.g., 90 days = 7776000 seconds)
-
Implement parallel operation:
- Deploy the new key to your applications but keep the old one active
- Configure your application to try the new key first, falling back to the old key if needed
- Monitor for any issues with the new key
-
Gradual transition:
- Update services one by one to use the new key exclusively
- Maintain a rollback plan in case of unexpected issues
-
Confirm all services are using the new key:
- Monitor API usage patterns to verify the new key is being used
- Check logs for any fallbacks to the old key
-
Decommission the old key:
python nylas_api_key_generator.py delete <old_api_key_id>
-
Verify application functionality:
- Run integration tests to ensure everything works with only the new key
- Monitor for any unexpected errors
-
Create a rotation script:
- Automate the creation of new keys
- Update configuration files or secrets management systems
- Implement automatic verification tests
-
Integrate with CI/CD:
- Trigger key rotation as part of your deployment pipeline
- Include verification steps before completing the rotation
-
Monitoring and alerts:
- Set up alerts for key expiration dates
- Monitor for authentication failures that might indicate rotation issues
In case of a suspected security breach:
-
Immediate revocation:
python nylas_api_key_generator.py delete <compromised_key_id>
-
Generate a new key:
python nylas_api_key_generator.py create --name "emergency-key-YYYY-MM-DD" --expires 7776000
-
Emergency deployment:
- Update all services with the new key as quickly as possible
- Consider temporary service disruption if necessary for security