Commit 46d06df9 by Szabolcs Gelencser

Add policy middleware, use it in requests tab

parent 6676d3c2
class PolicyMiddleware(object):
def process_request(self, request):
user = request.user
if hasattr(user, 'project_id'):
setattr(user, 'permissions', {})
from django.utils.module_loading import import_string
check = import_string("openstack_auth.policy.check")
has_perm_request_decide = check((("circle", "request:decide"),), request,
{'project_id': user.project_id})
user.permissions["request_decide"] = has_perm_request_decide
\ No newline at end of file
{ {
"admin_or_owner": "is_admin:True or (role:admin and is_admin_project:True) or project_id:%(project_id)s", "admin": "is_admin:True or (role:admin and is_admin_project:True)",
"owner": "project_id:%(project_id)s",
"circle_admin": "role:circle_admin and project_id:%(project_id)s",
"template:create": "rule:admin_or_owner" "template:create": "rule:admin or rule:owner or rule:circle_admin",
"request:decide": "rule:admin or rule:circle_admin"
} }
\ No newline at end of file
...@@ -336,6 +336,7 @@ MIDDLEWARE_CLASSES = ( ...@@ -336,6 +336,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'circle.middleware.PolicyMiddleware'
) )
########## END MIDDLEWARE CONFIGURATION ########## END MIDDLEWARE CONFIGURATION
...@@ -580,4 +581,4 @@ DEFAULT_SUBNETPOOL_PREFIXES = ( ...@@ -580,4 +581,4 @@ DEFAULT_SUBNETPOOL_PREFIXES = (
) )
DEFAULT_SUBNETPOOL_PREFIX_LEN = 20 DEFAULT_SUBNETPOOL_PREFIX_LEN = 20
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN="bme" OPENSTACK_KEYSTONE_DEFAULT_DOMAIN="Default"
\ No newline at end of file \ No newline at end of file
...@@ -49,13 +49,15 @@ ...@@ -49,13 +49,15 @@
{# <span class="hidden-sm">{% trans "Network" %}</span>#} {# <span class="hidden-sm">{% trans "Network" %}</span>#}
{# </a>#} {# </a>#}
{# </li>#} {# </li>#}
{# <li>#} {% if view.request.user.permissions.request_decide %}
{# <a href="{% url "request.views.request-list" %}">#} <li>
{# <i class="fa fa-phone"></i>#} <a href="{% url "request.views.request-list" %}">
{# <span class="hidden-sm">{% trans "Requests" %}</span>#} <i class="fa fa-phone"></i>
{# </a>#} <span class="hidden-sm">{% trans "Requests" %}</span>
{# </li>#} </a>
{# {% endif %}#} </li>
{% endif %}
{# {% endif %}#}
{# <li>#} {# <li>#}
{# <a href="{% url "dashboard.views.profile-preferences" %}">#} {# <a href="{% url "dashboard.views.profile-preferences" %}">#}
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-04-03 11:42
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('request', '0004_auto_20150629_1605'),
]
operations = [
migrations.AlterModelOptions(
name='request',
options={'permissions': (('can_decide_request', 'Can decide to accept/decline request'),)},
),
]
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 sign in to comment