Last active
December 23, 2015 07:28
-
-
Save phaer/6600688 to your computer and use it in GitHub Desktop.
Mediagoblin m*e*ddleware to keep your instance private.
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 mediagoblin.meddleware import BaseMeddleware | |
from mediagoblin.tools.response import redirect | |
class PrivateMeddleware(BaseMeddleware): | |
"""Private Meddleware | |
Redirects requests by unauthenticated clients to the login form. | |
""" | |
public_views = [ | |
'mediagoblin.auth.login', | |
'mediagoblin.plugins.basic_auth.forgot_password', | |
'mediagoblin.plugins.basic_auth.verify_forgot_password', | |
'mediagoblin.plugins.api.test', | |
'mediagoblin.plugins.api.entries', | |
'mediagoblin.plugins.api.post_entry', | |
] | |
def process_request(self, request, controller): | |
public_urls = map(request.urlgen, self.public_views) | |
# TODO: check atom feeds with authentication. | |
if not request.path in public_urls and not request.user: | |
return redirect(request, 'mediagoblin.auth.login') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment