Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a8420489
Commit
a8420489
authored
Sep 21, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shift NamespacePolicy to UserNamespacePolicy
as we convert to using Namespaces::UserNamespace
parent
be4538b5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
46 deletions
+59
-46
app/policies/namespace_policy.rb
app/policies/namespace_policy.rb
+6
-23
app/policies/namespaces/user_namespace_policy.rb
app/policies/namespaces/user_namespace_policy.rb
+28
-0
ee/app/policies/ee/namespace_policy.rb
ee/app/policies/ee/namespace_policy.rb
+0
-21
ee/app/policies/ee/namespaces/user_namespace_policy.rb
ee/app/policies/ee/namespaces/user_namespace_policy.rb
+23
-0
ee/spec/policies/ee/namespaces/user_namespace_policy_spec.rb
ee/spec/policies/ee/namespaces/user_namespace_policy_spec.rb
+1
-1
spec/policies/namespaces/user_namespace_policy_spec.rb
spec/policies/namespaces/user_namespace_policy_spec.rb
+1
-1
No files found.
app/policies/namespace_policy.rb
View file @
a8420489
# frozen_string_literal: true
class
NamespacePolicy
<
BasePolicy
rule
{
anonymous
}.
prevent_all
condition
(
:personal_project
,
scope: :subject
)
{
@subject
.
kind
==
'user'
}
condition
(
:can_create_personal_project
,
scope: :user
)
{
@user
.
can_create_project?
}
condition
(
:owner
)
{
@subject
.
owner
==
@user
}
rule
{
owner
|
admin
}.
policy
do
enable
:owner_access
enable
:create_projects
enable
:admin_namespace
enable
:read_namespace
enable
:read_statistics
enable
:create_jira_connect_subscription
enable
:create_package_settings
enable
:read_package_settings
end
rule
{
personal_project
&
~
can_create_personal_project
}.
prevent
:create_projects
rule
{
(
owner
|
admin
)
&
can?
(
:create_projects
)
}.
enable
:transfer_projects
class
NamespacePolicy
<
::
Namespaces
::
UserNamespacePolicy
# NamespacePolicy has been traditionally for user namespaces.
# So these policies have been moved into Namespaces::UserNamespacePolicy.
# Once the user namespace conversion is complete, we can look at
# either removing this file or locating common namespace policy items
# here.
end
NamespacePolicy
.
prepend_mod_with
(
'NamespacePolicy'
)
app/policies/namespaces/user_namespace_policy.rb
0 → 100644
View file @
a8420489
# frozen_string_literal: true
module
Namespaces
class
UserNamespacePolicy
<
BasePolicy
rule
{
anonymous
}.
prevent_all
condition
(
:personal_project
,
scope: :subject
)
{
@subject
.
kind
==
'user'
}
condition
(
:can_create_personal_project
,
scope: :user
)
{
@user
.
can_create_project?
}
condition
(
:owner
)
{
@subject
.
owner
==
@user
}
rule
{
owner
|
admin
}.
policy
do
enable
:owner_access
enable
:create_projects
enable
:admin_namespace
enable
:read_namespace
enable
:read_statistics
enable
:create_jira_connect_subscription
enable
:create_package_settings
enable
:read_package_settings
end
rule
{
personal_project
&
~
can_create_personal_project
}.
prevent
:create_projects
rule
{
(
owner
|
admin
)
&
can?
(
:create_projects
)
}.
enable
:transfer_projects
end
end
Namespaces
::
UserNamespacePolicy
.
prepend_mod_with
(
'Namespaces::UserNamespacePolicy'
)
ee/app/policies/ee/namespace_policy.rb
deleted
100644 → 0
View file @
be4538b5
# frozen_string_literal: true
module
EE
module
NamespacePolicy
extend
ActiveSupport
::
Concern
prepended
do
condition
(
:over_storage_limit
,
scope: :subject
)
{
@subject
.
over_storage_limit?
}
condition
(
:compliance_framework_available
)
do
@subject
.
feature_available?
(
:custom_compliance_frameworks
)
end
rule
{
admin
&
is_gitlab_com
}.
enable
:update_subscription_limit
rule
{
over_storage_limit
}.
policy
do
prevent
:create_projects
end
rule
{
can?
(
:owner_access
)
&
compliance_framework_available
}.
enable
:admin_compliance_framework
end
end
end
ee/app/policies/ee/namespaces/user_namespace_policy.rb
0 → 100644
View file @
a8420489
# frozen_string_literal: true
module
EE
module
Namespaces
module
UserNamespacePolicy
extend
ActiveSupport
::
Concern
prepended
do
condition
(
:over_storage_limit
,
scope: :subject
)
{
@subject
.
over_storage_limit?
}
condition
(
:compliance_framework_available
)
do
@subject
.
licensed_feature_available?
(
:custom_compliance_frameworks
)
end
rule
{
admin
&
is_gitlab_com
}.
enable
:update_subscription_limit
rule
{
over_storage_limit
}.
policy
do
prevent
:create_projects
end
rule
{
can?
(
:owner_access
)
&
compliance_framework_available
}.
enable
:admin_compliance_framework
end
end
end
end
ee/spec/policies/namespace_policy_spec.rb
→
ee/spec/policies/
ee/namespaces/user_
namespace_policy_spec.rb
View file @
a8420489
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
NamespacePolicy
do
RSpec
.
describe
Namespace
s
::
UserNamespace
Policy
do
let
(
:owner
)
{
build_stubbed
(
:user
)
}
let
(
:namespace
)
{
build_stubbed
(
:namespace
,
owner:
owner
)
}
let
(
:admin
)
{
build_stubbed
(
:admin
)
}
...
...
spec/policies/namespace_policy_spec.rb
→
spec/policies/namespace
s/user_namespace
_policy_spec.rb
View file @
a8420489
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
NamespacePolicy
do
RSpec
.
describe
Namespace
s
::
UserNamespace
Policy
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:owner
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment