Created
March 14, 2012 19:56
-
-
Save timmyomahony/2039062 to your computer and use it in GitHub Desktop.
Extra middleware for a canvas app with fandjango to make sure ALL requests are authorized
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponseRedirect | |
from django.conf import settings | |
from fandjango.decorators import facebook_authorization_required | |
class ExtraFacebookMiddleware: | |
"""An extra layer of middleware on top of Fandjango to | |
enforce facebook authentication on every request. | |
This avoids having to decorate every view""" | |
def process_view(self, request, view_func, view_args, view_kwargs): | |
@facebook_authorization_required(permissions=settings.FACEBOOK_APPLICATION_INITIAL_PERMISSIONS) | |
def f(request, view_args, view_kwargs): | |
return view_func(request, view_args, view_kwargs) | |
return f(request, request, view_func, view_args, view_kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment