Draft: Validate deploy key owner membership when creating access levels
What does this MR do and why?
Validate deploy key owner membership when creating access levels
This change adds a new validator to check that the deploy key owner is a project member. This aligns with our documentation:
https://docs.gitlab.com/ee/user/project/protected_branches.html
This states:
the owner of the deploy key must have at least read access to the project.
This change also moves the deploy_key.user_id == current_user.id
check
before current_user.can?(:read_project, project)
as the later will
fire a db query which we can avoid if the deploy_key
owner is not the
current_user
.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.