Commit e495d6a5 authored by Lee Tickett's avatar Lee Tickett Committed by Jarka Košanová

Restric access to crm to reporter+

Changelog: fixed
parent b8e38e38
...@@ -123,8 +123,6 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy ...@@ -123,8 +123,6 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy
enable :read_group_member enable :read_group_member
enable :read_custom_emoji enable :read_custom_emoji
enable :read_counts enable :read_counts
enable :read_crm_organization
enable :read_crm_contact
end end
rule { ~public_group & ~has_access }.prevent :read_counts rule { ~public_group & ~has_access }.prevent :read_counts
...@@ -159,6 +157,8 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy ...@@ -159,6 +157,8 @@ class GroupPolicy < Namespaces::GroupProjectNamespaceSharedPolicy
enable :read_prometheus enable :read_prometheus
enable :read_package enable :read_package
enable :read_package_settings enable :read_package_settings
enable :read_crm_organization
enable :read_crm_contact
end end
rule { maintainer }.policy do rule { maintainer }.policy do
......
...@@ -14,6 +14,15 @@ With customer relations management (CRM) you can create a record of contacts ...@@ -14,6 +14,15 @@ With customer relations management (CRM) you can create a record of contacts
You can use contacts and organizations to tie work to customers for billing and reporting purposes. You can use contacts and organizations to tie work to customers for billing and reporting purposes.
To read more about what is planned for the future, see [issue 2256](https://gitlab.com/gitlab-org/gitlab/-/issues/2256). To read more about what is planned for the future, see [issue 2256](https://gitlab.com/gitlab-org/gitlab/-/issues/2256).
## Permissions
| Permission | Guest | Reporter | Developer, Maintainer, and Owner |
| ---------- | ---------------- | -------- | -------------------------------- |
| View contacts/organizations | | ✓ | ✓ |
| View issue contacts | | ✓ | ✓ |
| Add/remove issue contacts | | ✓ | ✓ |
| Create/edit contacts/organizations | | | ✓ |
## Enable customer relations management (CRM) ## Enable customer relations management (CRM)
To enable customer relations management in a group: To enable customer relations management in a group:
...@@ -122,10 +131,6 @@ API. ...@@ -122,10 +131,6 @@ API.
### Add or remove issue contacts ### Add or remove issue contacts
Prerequisites:
- You must have at least the [Developer role](../permissions.md#project-members-permissions) for a group.
### Add contacts to an issue ### Add contacts to an issue
To add contacts to an issue use the `/add_contacts` To add contacts to an issue use the `/add_contacts`
......
...@@ -11,8 +11,6 @@ RSpec.describe GroupPolicy do ...@@ -11,8 +11,6 @@ RSpec.describe GroupPolicy do
it do it do
expect_allowed(:read_group) expect_allowed(:read_group)
expect_allowed(:read_crm_organization)
expect_allowed(:read_crm_contact)
expect_allowed(:read_counts) expect_allowed(:read_counts)
expect_allowed(*read_group_permissions) expect_allowed(*read_group_permissions)
expect_disallowed(:upload_file) expect_disallowed(:upload_file)
...@@ -21,11 +19,13 @@ RSpec.describe GroupPolicy do ...@@ -21,11 +19,13 @@ RSpec.describe GroupPolicy do
expect_disallowed(*maintainer_permissions) expect_disallowed(*maintainer_permissions)
expect_disallowed(*owner_permissions) expect_disallowed(*owner_permissions)
expect_disallowed(:read_namespace) expect_disallowed(:read_namespace)
expect_disallowed(:read_crm_organization)
expect_disallowed(:read_crm_contact)
end end
end end
context 'with no user and public project' do context 'with no user and public project' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, group: create(:group, :crm_enabled)) }
let(:current_user) { nil } let(:current_user) { nil }
before do before do
...@@ -40,7 +40,7 @@ RSpec.describe GroupPolicy do ...@@ -40,7 +40,7 @@ RSpec.describe GroupPolicy do
end end
context 'with foreign user and public project' do context 'with foreign user and public project' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public, group: create(:group, :crm_enabled)) }
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
before do before do
...@@ -65,7 +65,7 @@ RSpec.describe GroupPolicy do ...@@ -65,7 +65,7 @@ RSpec.describe GroupPolicy do
it { expect_allowed(*read_group_permissions) } it { expect_allowed(*read_group_permissions) }
context 'in subgroups' do context 'in subgroups' do
let(:subgroup) { create(:group, :private, parent: group) } let(:subgroup) { create(:group, :private, :crm_enabled, parent: group) }
let(:project) { create(:project, namespace: subgroup) } let(:project) { create(:project, namespace: subgroup) }
it { expect_allowed(*read_group_permissions) } it { expect_allowed(*read_group_permissions) }
...@@ -233,7 +233,7 @@ RSpec.describe GroupPolicy do ...@@ -233,7 +233,7 @@ RSpec.describe GroupPolicy do
describe 'private nested group use the highest access level from the group and inherited permissions' do describe 'private nested group use the highest access level from the group and inherited permissions' do
let_it_be(:nested_group) do let_it_be(:nested_group) do
create(:group, :private, :owner_subgroup_creation_only, parent: group) create(:group, :private, :owner_subgroup_creation_only, :crm_enabled, parent: group)
end end
before_all do before_all do
...@@ -340,7 +340,7 @@ RSpec.describe GroupPolicy do ...@@ -340,7 +340,7 @@ RSpec.describe GroupPolicy do
let(:current_user) { owner } let(:current_user) { owner }
context 'when the group share_with_group_lock is enabled' do context 'when the group share_with_group_lock is enabled' do
let(:group) { create(:group, share_with_group_lock: true, parent: parent) } let(:group) { create(:group, :crm_enabled, share_with_group_lock: true, parent: parent) }
before do before do
group.add_owner(owner) group.add_owner(owner)
...@@ -348,10 +348,10 @@ RSpec.describe GroupPolicy do ...@@ -348,10 +348,10 @@ RSpec.describe GroupPolicy do
context 'when the parent group share_with_group_lock is enabled' do context 'when the parent group share_with_group_lock is enabled' do
context 'when the group has a grandparent' do context 'when the group has a grandparent' do
let(:parent) { create(:group, share_with_group_lock: true, parent: grandparent) } let(:parent) { create(:group, :crm_enabled, share_with_group_lock: true, parent: grandparent) }
context 'when the grandparent share_with_group_lock is enabled' do context 'when the grandparent share_with_group_lock is enabled' do
let(:grandparent) { create(:group, share_with_group_lock: true) } let(:grandparent) { create(:group, :crm_enabled, share_with_group_lock: true) }
context 'when the current_user owns the parent' do context 'when the current_user owns the parent' do
before do before do
...@@ -377,7 +377,7 @@ RSpec.describe GroupPolicy do ...@@ -377,7 +377,7 @@ RSpec.describe GroupPolicy do
end end
context 'when the grandparent share_with_group_lock is disabled' do context 'when the grandparent share_with_group_lock is disabled' do
let(:grandparent) { create(:group) } let(:grandparent) { create(:group, :crm_enabled) }
context 'when the current_user owns the parent' do context 'when the current_user owns the parent' do
before do before do
...@@ -394,7 +394,7 @@ RSpec.describe GroupPolicy do ...@@ -394,7 +394,7 @@ RSpec.describe GroupPolicy do
end end
context 'when the group does not have a grandparent' do context 'when the group does not have a grandparent' do
let(:parent) { create(:group, share_with_group_lock: true) } let(:parent) { create(:group, :crm_enabled, share_with_group_lock: true) }
context 'when the current_user owns the parent' do context 'when the current_user owns the parent' do
before do before do
...@@ -411,7 +411,7 @@ RSpec.describe GroupPolicy do ...@@ -411,7 +411,7 @@ RSpec.describe GroupPolicy do
end end
context 'when the parent group share_with_group_lock is disabled' do context 'when the parent group share_with_group_lock is disabled' do
let(:parent) { create(:group) } let(:parent) { create(:group, :crm_enabled) }
it { expect_allowed(:change_share_with_group_lock) } it { expect_allowed(:change_share_with_group_lock) }
end end
...@@ -696,7 +696,7 @@ RSpec.describe GroupPolicy do ...@@ -696,7 +696,7 @@ RSpec.describe GroupPolicy do
end end
it_behaves_like 'clusterable policies' do it_behaves_like 'clusterable policies' do
let(:clusterable) { create(:group) } let(:clusterable) { create(:group, :crm_enabled) }
let(:cluster) do let(:cluster) do
create(:cluster, create(:cluster,
:provided_by_gcp, :provided_by_gcp,
...@@ -706,7 +706,7 @@ RSpec.describe GroupPolicy do ...@@ -706,7 +706,7 @@ RSpec.describe GroupPolicy do
end end
describe 'update_max_artifacts_size' do describe 'update_max_artifacts_size' do
let(:group) { create(:group, :public) } let(:group) { create(:group, :public, :crm_enabled) }
context 'when no user' do context 'when no user' do
let(:current_user) { nil } let(:current_user) { nil }
...@@ -736,7 +736,7 @@ RSpec.describe GroupPolicy do ...@@ -736,7 +736,7 @@ RSpec.describe GroupPolicy do
end end
describe 'design activity' do describe 'design activity' do
let_it_be(:group) { create(:group, :public) } let_it_be(:group) { create(:group, :public, :crm_enabled) }
let(:current_user) { nil } let(:current_user) { nil }
...@@ -933,8 +933,6 @@ RSpec.describe GroupPolicy do ...@@ -933,8 +933,6 @@ RSpec.describe GroupPolicy do
it { is_expected.to be_allowed(:read_package) } it { is_expected.to be_allowed(:read_package) }
it { is_expected.to be_allowed(:read_group) } it { is_expected.to be_allowed(:read_group) }
it { is_expected.to be_allowed(:read_crm_organization) }
it { is_expected.to be_allowed(:read_crm_contact) }
it { is_expected.to be_disallowed(:create_package) } it { is_expected.to be_disallowed(:create_package) }
end end
...@@ -944,8 +942,6 @@ RSpec.describe GroupPolicy do ...@@ -944,8 +942,6 @@ RSpec.describe GroupPolicy do
it { is_expected.to be_allowed(:create_package) } it { is_expected.to be_allowed(:create_package) }
it { is_expected.to be_allowed(:read_package) } it { is_expected.to be_allowed(:read_package) }
it { is_expected.to be_allowed(:read_group) } it { is_expected.to be_allowed(:read_group) }
it { is_expected.to be_allowed(:read_crm_organization) }
it { is_expected.to be_allowed(:read_crm_contact) }
it { is_expected.to be_disallowed(:destroy_package) } it { is_expected.to be_disallowed(:destroy_package) }
end end
...@@ -965,7 +961,7 @@ RSpec.describe GroupPolicy do ...@@ -965,7 +961,7 @@ RSpec.describe GroupPolicy do
it_behaves_like 'Self-managed Core resource access tokens' it_behaves_like 'Self-managed Core resource access tokens'
context 'support bot' do context 'support bot' do
let_it_be(:group) { create(:group, :private) } let_it_be(:group) { create(:group, :private, :crm_enabled) }
let_it_be(:current_user) { User.support_bot } let_it_be(:current_user) { User.support_bot }
before do before do
...@@ -975,7 +971,7 @@ RSpec.describe GroupPolicy do ...@@ -975,7 +971,7 @@ RSpec.describe GroupPolicy do
it { expect_disallowed(:read_label) } it { expect_disallowed(:read_label) }
context 'when group hierarchy has a project with service desk enabled' do context 'when group hierarchy has a project with service desk enabled' do
let_it_be(:subgroup) { create(:group, :private, parent: group) } let_it_be(:subgroup) { create(:group, :private, :crm_enabled, parent: group) }
let_it_be(:project) { create(:project, group: subgroup, service_desk_enabled: true) } let_it_be(:project) { create(:project, group: subgroup, service_desk_enabled: true) }
it { expect_allowed(:read_label) } it { expect_allowed(:read_label) }
...@@ -1170,7 +1166,7 @@ RSpec.describe GroupPolicy do ...@@ -1170,7 +1166,7 @@ RSpec.describe GroupPolicy do
end end
context 'when crm_enabled is false' do context 'when crm_enabled is false' do
let(:group) { create(:group) } let(:group) { create(:group, :crm_enabled) }
let(:current_user) { owner } let(:current_user) { owner }
it { is_expected.to be_disallowed(:read_crm_contact) } it { is_expected.to be_disallowed(:read_crm_contact) }
......
...@@ -73,7 +73,7 @@ RSpec.describe Groups::Crm::ContactsController do ...@@ -73,7 +73,7 @@ RSpec.describe Groups::Crm::ContactsController do
let(:group) { create(:group, :public, :crm_enabled) } let(:group) { create(:group, :public, :crm_enabled) }
context 'with anonymous user' do context 'with anonymous user' do
it_behaves_like 'ok response with index template' it_behaves_like 'response with 404 status'
end end
end end
end end
......
...@@ -73,7 +73,7 @@ RSpec.describe Groups::Crm::OrganizationsController do ...@@ -73,7 +73,7 @@ RSpec.describe Groups::Crm::OrganizationsController do
let(:group) { create(:group, :public, :crm_enabled) } let(:group) { create(:group, :public, :crm_enabled) }
context 'with anonymous user' do context 'with anonymous user' do
it_behaves_like 'ok response with index template' it_behaves_like 'response with 404 status'
end end
end end
end end
......
...@@ -22,10 +22,10 @@ RSpec.describe Issues::UpdateService, :mailer do ...@@ -22,10 +22,10 @@ RSpec.describe Issues::UpdateService, :mailer do
end end
before_all do before_all do
project.add_maintainer(user) group.add_maintainer(user)
project.add_developer(user2) group.add_developer(user2)
project.add_developer(user3) group.add_developer(user3)
project.add_guest(guest) group.add_guest(guest)
end end
describe 'execute' do describe 'execute' do
......
...@@ -28,6 +28,8 @@ RSpec.shared_context 'GroupPolicy context' do ...@@ -28,6 +28,8 @@ RSpec.shared_context 'GroupPolicy context' do
read_metrics_dashboard_annotation read_metrics_dashboard_annotation
read_prometheus read_prometheus
read_package_settings read_package_settings
read_crm_contact
read_crm_organization
] ]
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment