fix: dynamic secret env scoping - #1024
Open
rohan-chaturvedi wants to merge 7 commits into
Open
rohan-chaturvedi wants to merge 7 commits into
rohan-chaturvedi wants to merge 7 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔍 Overview
Misc fixes to permission enforcement and lifeccycle checks for dynamic secrets
💡 Proposed Changes
Environment scoping
dynamicSecrets(app and org level) only returns secrets in environments the caller has access to. The nestedleasesfield applies the same check.deleteDynamicSecretanddeleteEnvironmentrequire access to the environment.accessible_environment_ids()andrequest_accessible_env_ids()inapi/utils/access/permissions.py.Lease permissions
DynamicSecretLeases:createfor the member or service account that will hold it. This applies to the REST secrets endpoints (only when a lease would actually be created) and to the GraphQLleaseDynamicSecretmutation.leaseDynamicSecretnow checksSecrets:read+DynamicSecretLeases:create, instead ofSecrets:create.Lease lifecycle
pre_deletereceiver onDynamicSecretLease. Revocation is best-effort and bounded:Frontend
🖼️ Screenshots or Demo
N/A. Backend permission and lifecycle changes, plus a small frontend guard.
📝 Release Notes
DynamicSecretLeases:create. All default roles already include it. Update custom roles and team role overrides that use dynamic secrets. This affects:phase run,phase shell,phase secrets get/export) in environments with dynamic secrets at the requested pathlease=true--generate-leases=false.Secrets:create.Secrets:read+DynamicSecretLeases:createis enough.🧪 Testing
backend/tests/ee/integrations/secrets/dynamic/:test_lease_view_scoping.py,test_dynamic_secret_env_scoping.py,test_lease_cascade_revocation.py,test_lease_ownership.py,test_lease_renewal.py,test_lease_create_permission.pybackend/tests/api/utils/test_env_access_helpers.pybackend/tests/graphene/mutations/test_environment_delete_access.pybackend/tests/api/mutations/test_delete_account.py.🎯 Reviewer Focus
backend/api/signals.py,_dynamic_secret_lease_pre_delete:backend/ee/integrations/secrets/dynamic/utils.py:revoke_lease_immediatelycancel_scheduled_lease_job(deferred to commit)renew_dynamic_secret_leasecan_create_dynamic_secret_leasebackend/api/views/secrets.py: the lease permission check only runs when a lease would be created.backend/ee/integrations/secrets/dynamic/rest/views.pyandgraphene/mutations.py: ownership checks.➕ Additional Context
✨ How to Test the Changes Locally
Setup:
devandprodenvironments, and a dynamic secret in each.devonly.Secrets:readbut withoutDynamicSecretLeases:create, assigned to a member and a service account.proddynamic secrets and leases are not listed. Deleting theproddynamic secret through the API is refused.phase runin an environment with dynamic secrets creates leases.--generate-leases=falsestill works, as do environments without dynamic secrets.DynamicSecretLeases:createrestores access.docker compose -f dev-docker-compose.yml exec backend pytest tests/ee/integrations/secrets/dynamic tests/graphene/mutations/test_environment_delete_access.py tests/api/mutations/test_delete_account.py tests/api/utils/test_env_access_helpers.py💚 Did You...