How to use the aj.auth.PermissionProvider function in aj

To help you get started, we’ve selected a few aj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ajenti / ajenti / plugins / core / main.py View on Github external
'name': 'System',
                'children': [
                ]
            },
            {
                'attach': None,
                'id': 'category:other',
                'name': 'Other',
                'children': [
                ]
            },
        ]


@component(PermissionProvider)
class Permissions (PermissionProvider):
    def provide(self):
        sidebar_perms = [
            {
                'id': 'sidebar:view:%s' % item['url'],
                'name': item['name'],
                'default': True,
            }
            for provider in SidebarItemProvider.all(self.context)
            for item in provider.provide()
            if 'url' in item
        ]
        return [
            {
                'id': 'core:config:read',
                'name': 'Read configuration file',
                'default': True,
github ajenti / ajenti / plugins / network / main.py View on Github external
def provide(self):
        return [
            {
                'attach': 'category:system',
                'id': 'network',
                'name': _('Network'),
                'icon': 'plug',
                'url': '/view/network',
                'children': [],
            }
        ]


@component(PermissionProvider)
class Permissions(PermissionProvider):
    def provide(self):
        return [
            {
                'id': 'network:configure',
                'name': _('Configure network interfaces'),
                'default': True,
            },
            {
                'id': 'network:updown',
                'name': _('Activate/deactivate network interfaces'),
                'default': True,
            },
github ajenti / ajenti / plugins / datetime / main.py View on Github external
self.context = context

    def provide(self):
        return [
            {
                'attach': 'category:system',
                'id': 'datetime',
                'name': _('Date & time'),
                'icon': 'clock-o',
                'url': '/view/datetime',
                'children': [],
            }
        ]


@component(PermissionProvider)
class Permissions(PermissionProvider):
    def provide(self):
        return [
            {
                'id': 'datetime:write',
                'name': _('Change date and time'),
                'default': True,
            },
github ajenti / ajenti / plugins / packages / main.py View on Github external
'children': [],
        } for mgr in PackageManager.all(self.context)]
        return [
            {
                'attach': 'category:system',
                'id': 'packages',
                'name': _('Packages'),
                'icon': 'gift',
                'url': '/view/packages/%s' % PackageManager.all(self.context, ignore_exceptions=True)[0].id,
                'children': children,
            }
        ]


@component(PermissionProvider)
class Permissions (PermissionProvider):
    def provide(self):
        return [
            {
                'id': 'packages:install',
                'name': _('Install/remove packages'),
                'default': True,
            },
github ajenti / ajenti / plugins / core / main.py View on Github external
'id': 'category:system',
                'name': 'System',
                'children': [
                ]
            },
            {
                'attach': None,
                'id': 'category:other',
                'name': 'Other',
                'children': [
                ]
            },
        ]


@component(PermissionProvider)
class Permissions (PermissionProvider):
    def provide(self):
        sidebar_perms = [
            {
                'id': 'sidebar:view:%s' % item['url'],
                'name': item['name'],
                'default': True,
            }
            for provider in SidebarItemProvider.all(self.context)
            for item in provider.provide()
            if 'url' in item
        ]
        return [
            {
                'id': 'core:config:read',
                'name': 'Read configuration file',
github ajenti / ajenti / plugins / filesystem / main.py View on Github external
from jadi import component

from aj.auth import PermissionProvider


@component(PermissionProvider)
class Permissions (PermissionProvider):
    def provide(self):
        return [
            {
                'id': 'filesystem:read',
                'name': _('Read from the filesystem'),
                'default': True,
            },
            {
                'id': 'filesystem:write',
                'name': _('Write to the filesystem'),
                'default': True,
            },
github ajenti / ajenti / plugins / network / main.py View on Github external
self.context = context

    def provide(self):
        return [
            {
                'attach': 'category:system',
                'id': 'network',
                'name': _('Network'),
                'icon': 'plug',
                'url': '/view/network',
                'children': [],
            }
        ]


@component(PermissionProvider)
class Permissions(PermissionProvider):
    def provide(self):
        return [
            {
                'id': 'network:configure',
                'name': _('Configure network interfaces'),
                'default': True,
            },
            {
                'id': 'network:updown',
                'name': _('Activate/deactivate network interfaces'),
                'default': True,
            },
github ajenti / ajenti / plugins / services / main.py View on Github external
'url': '/view/services/%s' % mgr.id,
            'children': [],
        } for mgr in ServiceManager.all(self.context)]

        return [
            {
                'attach': 'category:software',
                'name': 'Services',
                'icon': 'cogs',
                'url': '/view/services',
                'children': children
            }
        ]

@component(PermissionProvider)
class Permissions (PermissionProvider):
    def provide(self):
        return [
            {
                'id': 'services:manage',
                'name': 'Manage system services',
                'default': True,
            },
github ajenti / ajenti / plugins / datetime / main.py View on Github external
def provide(self):
        return [
            {
                'attach': 'category:system',
                'id': 'datetime',
                'name': _('Date & time'),
                'icon': 'clock-o',
                'url': '/view/datetime',
                'children': [],
            }
        ]


@component(PermissionProvider)
class Permissions(PermissionProvider):
    def provide(self):
        return [
            {
                'id': 'datetime:write',
                'name': _('Change date and time'),
                'default': True,
            },
github ajenti / ajenti / plugins / core / views / config.py View on Github external
def handle_api_permissions(self, http_context):
        r = []
        for p in PermissionProvider.all(self.context):
            r += p.provide()
        return r