Skip to content

Instantly share code, notes, and snippets.

@timmyomahony
Created March 14, 2012 19:56
Show Gist options
  • Save timmyomahony/2039062 to your computer and use it in GitHub Desktop.
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
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