Skip to content

Commit c210f23

Browse files
committed
let OPTIONS requests pass inside dispatch() method
1 parent b6af819 commit c210f23

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

oauth2_provider/views/mixins.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,15 @@ def get_scopes(self, *args, **kwargs):
192192

193193
class ProtectedResourceMixin(OAuthLibMixin):
194194
"""
195-
Helper mixin that implements OAuth2 protection on request dispatch, specially useful for Django Generic Views
195+
Helper mixin that implements OAuth2 protection on request dispatch,
196+
specially useful for Django Generic Views
196197
"""
197198
def dispatch(self, request, *args, **kwargs):
199+
# let preflight OPTIONS requests pass
200+
if request.method.upper() == 'OPTIONS':
201+
return super(ProtectedResourceMixin, self).dispatch(request, *args, **kwargs)
202+
203+
# check if the request is valid and the protected resource may be accessed
198204
valid, r = self.verify_request(request)
199205
if valid:
200206
request.resource_owner = r.user

0 commit comments

Comments
 (0)