Add service instance permissions
This commit is contained in:
parent
e441005061
commit
7da4b77267
1 changed files with 8 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import kubernetes
|
import kubernetes
|
||||||
|
import rules
|
||||||
import urlman
|
import urlman
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
@ -12,6 +13,7 @@ from encrypted_fields.fields import EncryptedJSONField
|
||||||
from kubernetes import client, config
|
from kubernetes import client, config
|
||||||
from kubernetes.client.rest import ApiException
|
from kubernetes.client.rest import ApiException
|
||||||
|
|
||||||
|
from servala.core import rules as perms
|
||||||
from servala.core.models.mixins import ServalaModelMixin
|
from servala.core.models.mixins import ServalaModelMixin
|
||||||
from servala.core.validators import kubernetes_name_validator
|
from servala.core.validators import kubernetes_name_validator
|
||||||
|
|
||||||
|
@ -486,6 +488,12 @@ class ServiceInstance(ServalaModelMixin, models.Model):
|
||||||
# Names are unique per de-facto namespace, which is defined by the
|
# Names are unique per de-facto namespace, which is defined by the
|
||||||
# Organization + ServiceDefinition (group, version) + the ControlPlane.
|
# Organization + ServiceDefinition (group, version) + the ControlPlane.
|
||||||
unique_together = [("name", "organization", "context")]
|
unique_together = [("name", "organization", "context")]
|
||||||
|
rules_permissions = {
|
||||||
|
"view": rules.is_staff | perms.is_organization_member,
|
||||||
|
"change": rules.is_staff | perms.is_organization_member,
|
||||||
|
"delete": rules.is_staff | perms.is_organization_admin,
|
||||||
|
"add": rules.is_authenticated,
|
||||||
|
}
|
||||||
|
|
||||||
class urls(urlman.Urls):
|
class urls(urlman.Urls):
|
||||||
base = "{self.organization.urls.instances}{self.name}/"
|
base = "{self.organization.urls.instances}{self.name}/"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue