diff options
author | John Jarvis <jarv@gitlab.com> | 2019-04-12 14:49:06 +0000 |
---|---|---|
committer | John Jarvis <jarv@gitlab.com> | 2019-04-12 14:49:06 +0000 |
commit | f4d3820a1d56c78719d6ff96082411bef2193b13 (patch) | |
tree | 24d463eaad0ee1c9992778be1e2efa66650e4983 /app/policies/project_policy.rb | |
parent | 8728176f7427521654448b90e9590a063a12a2c5 (diff) | |
parent | a59b4223818620dc5944114de5deec27c30df2ef (diff) | |
download | gitlab-ce-f4d3820a1d56c78719d6ff96082411bef2193b13.tar.gz |
Merge branch 'if-external_auth-11-10' into '11-10-stable-prepare-rc7'
Backport "Move Authorize project access with external service to Core" to 11.10
See merge request gitlab-org/gitlab-ce!27317
Diffstat (limited to 'app/policies/project_policy.rb')
-rw-r--r-- | app/policies/project_policy.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index 26d7d6e84c4..ba38af9c529 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -89,6 +89,15 @@ class ProjectPolicy < BasePolicy ::Gitlab::CurrentSettings.current_application_settings.mirror_available end + with_scope :subject + condition(:classification_label_authorized, score: 32) do + ::Gitlab::ExternalAuthorization.access_allowed?( + @user, + @subject.external_authorization_classification_label, + @subject.full_path + ) + end + # We aren't checking `:read_issue` or `:read_merge_request` in this case # because it could be possible for a user to see an issuable-iid # (`:read_issue_iid` or `:read_merge_request_iid`) but then wouldn't be @@ -417,6 +426,25 @@ class ProjectPolicy < BasePolicy rule { ~can_have_multiple_clusters & has_clusters }.prevent :add_cluster + rule { ~can?(:read_cross_project) & ~classification_label_authorized }.policy do + # Preventing access here still allows the projects to be listed. Listing + # projects doesn't check the `:read_project` ability. But instead counts + # on the `project_authorizations` table. + # + # All other actions should explicitly check read project, which would + # trigger the `classification_label_authorized` condition. + # + # `:read_project_for_iids` is not prevented by this condition, as it is + # used for cross-project reference checks. + prevent :guest_access + prevent :public_access + prevent :public_user_access + prevent :reporter_access + prevent :developer_access + prevent :maintainer_access + prevent :owner_access + end + private def team_member? |