diff --git a/mellon/middleware.py b/mellon/middleware.py index 2c1d3fd..a0b814a 100644 --- a/mellon/middleware.py +++ b/mellon/middleware.py @@ -35,8 +35,12 @@ class PassiveAuthenticationMiddleware(object): # get the common domain or guess common_domain = app_settings.OPENED_SESSION_COOKIE_DOMAIN if not common_domain: + host = request.get_host() + # accept automatic common domain selection if domain has at least three components + # and is not an IP address + if not host.count('.') > 1 or host.replace('.', '').isdigit(): + return common_domain = request.get_host().split('.', 1)[1] - assert '.' in common_domain # if domain is xxx.com explode ! params = { 'next': request.build_absolute_uri(), 'passive': '',