Add secrets management project and group limits validations
What does this MR do and why?
Implements application limits for the maximum number of secrets that can be stored in a project/group within GitLab Secrets Manager. This is part of the GA readiness work for GitLab Secrets Manager.
Key Changes
- SecretCountService: New service that retrieves secret counts from OpenBao via the LIST API with caching for performance optimization (15-minutes TTL)
- SecretsLimitEnforcement concern: Reusable logic for limit validation across services, supporting both project and group secrets managers
-
Limit enforcement: Integrated into
Secrets::CreateServiceHelpersto prevent exceeding limits before secret creation
For groups, we currently have only the foundational work in place. Test will be extended: #585573
Default Limits
- Project: 100 secrets
- Group: 500 secrets
Limits can be set to 0 for unlimited secrets.
References
Closes #585572 Partially #585573
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
-
Enable GitLab Secrets Manager for a project
-
Set the lower limit
ApplicationSetting.current.update!(project_secrets_limit: 3) -
Invalidate settings cache
Gitlab::ApplicationSettingFetcher.expire_current_application_settings -
Check
Gitlab::CurrentSettings.project_secrets_limit -
Create secrets up to the limit (default: 100)
-
Attempt to create another secret - should receive an error message about the limit being reached
-
Delete a secret and verify you can create a new one
-
Enable GitLab Secrets Manager for a group
-
Set the lower limit
ApplicationSetting.current.update!(group_secrets_limit: 3) -
Invalidate settings cache
Gitlab::ApplicationSettingFetcher.expire_current_application_settings -
Check
Gitlab::CurrentSettings.group_secrets_limit -
Create secrets up to the limit (default: 500)
-
Attempt to create another secret - should receive an error message about the limit being reached
-
Delete a secret and verify you can create a new one
