Permalink
Browse files

allow sub-folders of protected areas to be accessible without authent…

…ication
  • Loading branch information...
1 parent e2b4d13 commit 2aecd1c2bff2ac36f2213927e055f64813f777da @willcritchlow willcritchlow committed Mar 16, 2011
Showing with 13 additions and 0 deletions.
  1. +5 −0 README.rst
  2. +8 −0 googleappsauth/middleware.py
View
@@ -54,6 +54,11 @@ In addition you can set `AUTH_PROTECTED_AREAS` to authenticate only access to ce
::
AUTH_PROTECTED_AREAS = ['/admin']
+
+If you wish, you can add `AUTH_EXCLUDED_AREAS` to remove authentication from sub-folders of your protected areas, e.g.
+::
+
+ AUTH_EXCLUDED_AREAS = ['/admin/public']
Download
========
@@ -34,6 +34,14 @@ def process_request(self, request):
if len(matches) == 0:
return
+ # Don't force authentication for excluded areas - allow sub-folders without auth
+ excludes = getattr(settings, 'AUTH_EXCLUDED_AREAS', [])
+ if hasattr(excludes, 'split'):
+ excludes = excludes.split('+')
+ exclude_matches = [exclude for exclude in excludes if path.startswith(exclude)]
+ if len(exclude_matches) != 0:
+ return
+
# Dont force authentication for the callback URL since it would
# result in a loop
callback_url = request.build_absolute_uri(reverse(googleappsauth.views.callback))

0 comments on commit 2aecd1c

Please sign in to comment.