Commit 2e330597 by Bence Dányi

firewall_gui: authorization added

parent c8025a95
...@@ -10,6 +10,7 @@ def req_staff(user): ...@@ -10,6 +10,7 @@ def req_staff(user):
''' decorator function for user permission checking ''' ''' decorator function for user permission checking '''
return user.is_staff return user.is_staff
@user_passes_test(req_staff)
def index(request): def index(request):
return render(request, 'firewall/index.html') return render(request, 'firewall/index.html')
...@@ -167,7 +168,7 @@ def list_entities(request, name): ...@@ -167,7 +168,7 @@ def list_entities(request, name):
'ipv4']), 'ipv4']),
}[name](request)), content_type='application/json') }[name](request)), content_type='application/json')
@user_passes_test(req_staff)
def show_rule(request, id=None): def show_rule(request, id=None):
try: try:
rule = Rule.objects.get(id=id) rule = Rule.objects.get(id=id)
...@@ -251,7 +252,7 @@ def show_rule(request, id=None): ...@@ -251,7 +252,7 @@ def show_rule(request, id=None):
} }
return HttpResponse(json.dumps(rule), content_type='application/json') return HttpResponse(json.dumps(rule), content_type='application/json')
@user_passes_test(req_staff)
def show_host(request, id=None): def show_host(request, id=None):
try: try:
host = Host.objects.get(id=id) host = Host.objects.get(id=id)
...@@ -319,7 +320,7 @@ def show_host(request, id=None): ...@@ -319,7 +320,7 @@ def show_host(request, id=None):
} }
return HttpResponse(json.dumps(host), content_type='application/json') return HttpResponse(json.dumps(host), content_type='application/json')
@user_passes_test(req_staff)
def show_vlan(request, id=None): def show_vlan(request, id=None):
try: try:
vlan = Vlan.objects.get(id=id) vlan = Vlan.objects.get(id=id)
...@@ -389,7 +390,7 @@ def show_vlan(request, id=None): ...@@ -389,7 +390,7 @@ def show_vlan(request, id=None):
} }
return HttpResponse(json.dumps(vlan), content_type='application/json') return HttpResponse(json.dumps(vlan), content_type='application/json')
@user_passes_test(req_staff)
def show_vlangroup(request, id=None): def show_vlangroup(request, id=None):
try: try:
group = VlanGroup.objects.get(id=id) group = VlanGroup.objects.get(id=id)
...@@ -434,7 +435,7 @@ def show_vlangroup(request, id=None): ...@@ -434,7 +435,7 @@ def show_vlangroup(request, id=None):
} }
return HttpResponse(json.dumps(group), content_type='application/json') return HttpResponse(json.dumps(group), content_type='application/json')
@user_passes_test(req_staff)
def show_hostgroup(request, id=None): def show_hostgroup(request, id=None):
try: try:
group = Group.objects.get(id=id) group = Group.objects.get(id=id)
...@@ -479,6 +480,8 @@ def show_hostgroup(request, id=None): ...@@ -479,6 +480,8 @@ def show_hostgroup(request, id=None):
} }
return HttpResponse(json.dumps(group), content_type='application/json') return HttpResponse(json.dumps(group), content_type='application/json')
@user_passes_test(req_staff)
def show_record(request, id=None): def show_record(request, id=None):
try: try:
record = Record.objects.get(id=id) record = Record.objects.get(id=id)
...@@ -526,6 +529,8 @@ def show_record(request, id=None): ...@@ -526,6 +529,8 @@ def show_record(request, id=None):
} }
return HttpResponse(json.dumps(record), content_type='application/json') return HttpResponse(json.dumps(record), content_type='application/json')
@user_passes_test(req_staff)
def show_domain(request, id=None): def show_domain(request, id=None):
try: try:
domain = Domain.objects.get(id=id) domain = Domain.objects.get(id=id)
...@@ -566,6 +571,7 @@ def make_autocomplete(entity, name='name'): ...@@ -566,6 +571,7 @@ def make_autocomplete(entity, name='name'):
return autocomplete return autocomplete
@user_passes_test(req_staff)
def autocomplete(request, entity): def autocomplete(request, entity):
try: try:
return { return {
......
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