Skip to content

Commit 4fa0ce2

Browse files
committed
Fix broken api for non-GET requests
Summary: - Removes DjangoModelPermissions from the settings template. DjangoModelPermissions is not needed since the user actions are validated based on their organization allowed peers. There is no other permission model/group. DjangoModelPermissions rendered the non-GET actions unusable until now in the api (only admins could make such actions) whereas in the views, such actions were allowed (because the view used django forms instead of api callbacks) - Downgrades djangorestframework version to solve #1850 drf bug with pickling and caching. Bug was solved after version 3.0.4 which until now is not tested, so it's safer to downgrade. More info about the bug: encode/django-rest-framework#1850 - Fix documentation example for `then` rule - Adds PENDING in allowed Route statuses since the rules are applied asynchronously and this means that until applied, the Route will have to be in PENDING status. This was stated in commit 11171aa message but was not implemented Reviewers: #developers, zmousm Reviewed By: #developers, zmousm Subscribers: zmousm, #developers Differential Revision: https://phab.noc.grnet.gr/D5182
1 parent ff15e05 commit 4fa0ce2

File tree

4 files changed

+3
-7
lines changed

4 files changed

+3
-7
lines changed

doc/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ existing) since we need it's `id`. Let's assume a `ThenAction` with an `id` of
268268
`4` exists. To create a new `Route` with this `ThenAction`:
269269

270270
```
271-
curl -X POST https://fod.example.com/api/routes/ -F "source=62.217.45.75/32" -F "destination=62.217.45.91/32" -F "name=testroute" -F "comments=Route for testing" -F "then=https://fod.example.com/api/thenactions/4" -H "Authorization: Token <your-token>"
271+
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token <your-token>" https://fod.staging.grnet.gr/api/routes/ -d '{"source":"62.217.45.75/32", "destination":"62.217.45.91/32", "name":"testroute", "then":["https://fod.staging.grnet.gr/api/thenactions/4/"]}'
272272
273273
{
274274
"name":"testroute_9Q5Y90",

flowspec/validators.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from django.utils.translation import ugettext as _
66
from peers.models import PeerRange, Peer
77
from flowspec.models import Route
8-
from django.core.urlresolvers import reverse
98

109

1110
def get_network(ip):
@@ -31,8 +30,6 @@ def clean_ip(address):
3130
def clean_status(status):
3231
"""
3332
Verifies the `status` of a `Route` is valid.
34-
Only allows `ACTIVE` / `INACTIVE` states since the rest should be
35-
assigned from the application
3633
3734
:param status: the status of a `Route`
3835
:type status: str
@@ -41,7 +38,7 @@ def clean_status(status):
4138
:rtype: str
4239
"""
4340

44-
allowed_states = ['ACTIVE', 'INACTIVE']
41+
allowed_states = ['ACTIVE', 'INACTIVE', 'PENDING']
4542

4643
if status not in allowed_states:
4744
return _('Invalid status value. You are allowed to use "{}".'.format(

flowspy/settings.py.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ REST_FRAMEWORK = {
309309
'rest_framework.renderers.JSONRenderer',
310310
),
311311
'DEFAULT_PERMISSION_CLASSES': [
312-
'rest_framework.permissions.DjangoModelPermissions',
313312
'rest_framework.permissions.IsAuthenticated'
314313
]
315314
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pyyaml==3.11
33
celery==3.1.23
44
django-registration==2.0.4
55
django-tinymce==1.5.3
6-
djangorestframework==2.4.3
6+
djangorestframework==2.3.14
77
gevent==0.13.6
88
greenlet==0.4.11
99
ncclient==0.5.3

0 commit comments

Comments
 (0)