Skip to content

Commit a003e2e

Browse files
committed
Change the authentication of all resources to ApiKeyAuthentication
1 parent de37fff commit a003e2e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

api.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from handball.models import *
44
from django.contrib.auth.models import User
55
from tastypie.authorization import DjangoAuthorization, Authorization
6-
from tastypie.authentication import BasicAuthentication, Authentication
6+
from tastypie.authentication import BasicAuthentication, Authentication, ApiKeyAuthentication
7+
from handball.authorization import ManagerAuthorization
78

89

910
class UnionResource(ModelResource):
@@ -14,7 +15,7 @@ class Meta:
1415
queryset = Union.objects.all()
1516
allowed_methods = ['get', 'post', 'put', 'patch']
1617
authorization = Authorization()
17-
authentication = BasicAuthentication()
18+
authentication = ApiKeyAuthentication()
1819
filtering = {
1920
'name': ('exact')
2021
}
@@ -29,7 +30,7 @@ class LeagueResource(ModelResource):
2930
class Meta:
3031
queryset = Team.objects.all()
3132
allowed_methods = ['get', 'post', 'put']
32-
authentication = Authentication()
33+
authentication = ApiKeyAuthentication()
3334
authorization = Authorization()
3435

3536

@@ -41,7 +42,7 @@ class Meta:
4142
queryset = Club.objects.all()
4243
allowed_methods = ['get', 'post', 'put']
4344
authorization = Authorization()
44-
authentication = Authentication()
45+
authentication = ApiKeyAuthentication()
4546
filtering = {
4647
'union': ALL_WITH_RELATIONS
4748
}
@@ -60,7 +61,7 @@ class Meta:
6061
queryset = Team.objects.all()
6162
allowed_methods = ['get', 'post', 'put']
6263
authorization = Authorization()
63-
authentication = Authentication()
64+
authentication = ApiKeyAuthentication()
6465

6566
def obj_create(self, bundle, request=None, **kwargs):
6667
# The user to create a team becomes its first manager (for lack of other people)
@@ -73,7 +74,7 @@ class UserResource(ModelResource):
7374

7475
class Meta:
7576
queryset = User.objects.all()
76-
excludes = ["email", "password"]
77+
excludes = ['email', 'password']
7778

7879

7980
class PersonResource(ModelResource):
@@ -82,22 +83,25 @@ class PersonResource(ModelResource):
8283

8384
class Meta:
8485
queryset = Person.objects.all()
85-
authorization = DjangoAuthorization()
86+
authorization = Authorization()
87+
authentication = ApiKeyAuthentication()
8688
excludes = ['activation_key', 'key_expires']
8789

8890

8991
class GameTypeResource(ModelResource):
9092
class Meta:
9193
queryset = GameType.objects.all()
9294
include_resource_uri = False
93-
authorization = DjangoAuthorization()
95+
authorization = Authorization()
96+
authentication = ApiKeyAuthentication()
9497

9598

9699
class SiteResource(ModelResource):
97100
class Meta:
98101
queryset = Site.objects.all()
99102
include_resource_uri = False
100-
authorization = DjangoAuthorization()
103+
authorization = Authorization()
104+
authentication = ApiKeyAuthentication()
101105

102106

103107
class GameResource(ModelResource):
@@ -116,7 +120,8 @@ class GameResource(ModelResource):
116120

117121
class Meta:
118122
queryset = Game.objects.all()
119-
authorization = DjangoAuthorization()
123+
authorization = Authorization()
124+
authentication = ApiKeyAuthentication()
120125

121126

122127
class EventTypeResource(ModelResource):
@@ -125,7 +130,8 @@ class EventTypeResource(ModelResource):
125130
class Meta:
126131
queryset = EventType.objects.all()
127132
include_resource_uri = False
128-
authorization = DjangoAuthorization()
133+
authorization = Authorization()
134+
authentication = ApiKeyAuthentication()
129135

130136

131137
class EventResource(ModelResource):
@@ -134,5 +140,6 @@ class EventResource(ModelResource):
134140

135141
class Meta:
136142
queryset = Event.objects.all()
137-
authorization = DjangoAuthorization()
143+
authorization = Authorization()
144+
authentication = ApiKeyAuthentication()
138145
include_resource_uri = False

0 commit comments

Comments
 (0)