From 6d934b96be17ce7ee84668cb3b76f2375b6c05aa Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Tue, 25 Sep 2012 19:42:41 -0400 Subject: added ASKBOT_INTERNAL_IPS setting - to allow dedicated IPs open read access to the site --- askbot/doc/source/intranet-setup.rst | 7 +++++++ askbot/middleware/forum_mode.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/askbot/doc/source/intranet-setup.rst b/askbot/doc/source/intranet-setup.rst index 224ffb89..2711b376 100644 --- a/askbot/doc/source/intranet-setup.rst +++ b/askbot/doc/source/intranet-setup.rst @@ -12,3 +12,10 @@ Please change the following settings in your ``settings.py`` file:: In addition, in the "live settings": * disable gravatar in "settings->User settings" + +If you would like to password/protect your site +(achievable via "access control settings" -> "allow only registered users..."), +and at the same time be able to have some dedicated service +to read your site without authentication, add +IP addresses of that service to a tuple ``ASKBOT_INTERNAL_IPS`` +in your ``settings.py`` file. diff --git a/askbot/middleware/forum_mode.py b/askbot/middleware/forum_mode.py index 7f1e29b1..d593a6f2 100644 --- a/askbot/middleware/forum_mode.py +++ b/askbot/middleware/forum_mode.py @@ -45,6 +45,10 @@ class ForumModeMiddleware(object): and request.user.is_anonymous()): resolver_match = ResolverMatch(resolve(request.path)) + internal_ips = getattr(settings, 'ASKBOT_INTERNAL_IPS', None) + if internal_ips and request.META['REMOTE_ADDR'] in internal_ips: + return None + if is_view_allowed(resolver_match.func): return -- cgit v1.2.3-1-g7c22