Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial RBAC support #1062

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/860.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added initial RBAC support.
33 changes: 33 additions & 0 deletions pulp_deb/app/migrations/0030_rbac_permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 4.2.9 on 2024-03-22 11:33

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('deb', '0029_distributedpublication'),
]

operations = [
migrations.AlterModelOptions(
name='aptdistribution',
options={'default_related_name': '%(app_label)s_%(model_name)s', 'permissions': [('manage_roles_aptdistribution', 'Can manage roles on an APT distribution')]},
),
migrations.AlterModelOptions(
name='aptpublication',
options={'default_related_name': '%(app_label)s_%(model_name)s', 'permissions': [('manage_roles_aptpublication', 'Can manage roles on an APT publication')]},
),
migrations.AlterModelOptions(
name='aptremote',
options={'default_related_name': '%(app_label)s_%(model_name)s', 'permissions': [('manage_roles_aptremote', 'Can manage roles on an APT remote')]},
),
migrations.AlterModelOptions(
name='aptrepository',
options={'default_related_name': '%(app_label)s_%(model_name)s', 'permissions': [('manage_roles_aptrepository', 'Can manage roles on APT repositories'), ('modify_content_aptrepository', 'Add content to, or remove content from a repository'), ('repair_aptrepository', 'Copy an APT repository'), ('sync_aptrepository', 'Sync an APT repository'), ('delete_aptrepository_version', 'Delete a repository version')]},
),
migrations.AlterModelOptions(
name='verbatimpublication',
options={'default_related_name': '%(app_label)s_%(model_name)s', 'permissions': [('manage_roles_verbatimpublication', 'Can manage roles on a verbatim publication')]},
),
]
16 changes: 13 additions & 3 deletions pulp_deb/app/models/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django_lifecycle import hook, AFTER_CREATE, AFTER_UPDATE

from pulpcore.plugin.models import (
AutoAddObjPermsMixin,
BaseModel,
Distribution,
Publication,
Expand Down Expand Up @@ -37,7 +38,7 @@ def latest_publication(repo_pk):
)


class VerbatimPublication(Publication):
class VerbatimPublication(Publication, AutoAddObjPermsMixin):
"""
A verbatim Publication for Content.

Expand All @@ -54,9 +55,12 @@ def set_distributed_publication(self):

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
permissions = [
("manage_roles_verbatimpublication", "Can manage roles on a verbatim publication"),
]


class AptPublication(Publication):
class AptPublication(Publication, AutoAddObjPermsMixin):
"""
A Publication for DebContent.

Expand All @@ -79,9 +83,12 @@ def set_distributed_publication(self):

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
permissions = [
("manage_roles_aptpublication", "Can manage roles on an APT publication"),
]


class AptDistribution(Distribution):
class AptDistribution(Distribution, AutoAddObjPermsMixin):
"""
A Distribution for DebContent.
"""
Expand Down Expand Up @@ -120,6 +127,9 @@ def content_handler(self, path):

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
permissions = [
("manage_roles_aptdistribution", "Can manage roles on an APT distribution"),
]


class DistributedPublication(BaseModel):
Expand Down
7 changes: 5 additions & 2 deletions pulp_deb/app/models/remote.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.db import models

from pulpcore.plugin.models import Remote
from pulpcore.plugin.models import Remote, AutoAddObjPermsMixin


class AptRemote(Remote):
class AptRemote(Remote, AutoAddObjPermsMixin):
"""
A Remote for DebContent.
"""
Expand All @@ -21,3 +21,6 @@ class AptRemote(Remote):

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
permissions = [
("manage_roles_aptremote", "Can manage roles on an APT remote"),
]
16 changes: 14 additions & 2 deletions pulp_deb/app/models/repository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from django.db import models

from pulpcore.plugin.models import BaseModel, Content, Repository
from pulpcore.plugin.models import (
AutoAddObjPermsMixin,
BaseModel,
Content,
Repository,
)
from pulpcore.plugin.repo_version_utils import (
remove_duplicates,
validate_version_paths,
Expand Down Expand Up @@ -32,7 +37,7 @@
log = logging.getLogger(__name__)


class AptRepository(Repository):
class AptRepository(Repository, AutoAddObjPermsMixin):
"""
A Repository for DebContent.
"""
Expand Down Expand Up @@ -66,6 +71,13 @@ class AptRepository(Repository):

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
permissions = [
("manage_roles_aptrepository", "Can manage roles on APT repositories"),
("modify_content_aptrepository", "Add content to, or remove content from a repository"),
("repair_aptrepository", "Copy an APT repository"),
("sync_aptrepository", "Sync an APT repository"),
("delete_aptrepository_version", "Delete a repository version"),
]

def release_signing_service(self, release):
"""
Expand Down
Loading
Loading