Thanks Gustavo! I really appreciate the help and middleware did the trick. I
was still having a couple of issues with redirects so I tried instead
modifying the environ this way:
class SSLOnlyLoginMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
if environ['wsgi.url_scheme'] != 'https':
environ['HTTP_HTTPS'] = 'on'
environ['wsgi.url_scheme'] = 'https'
body = self.app(environ, start_response)
return body
It's a small internal app and 99% of it will use https correctly already, so
I think I can get away without needing redirects for search engines or any
of the normal reasons. However, if you see any potential problems with
modifying the environ this way please let me know.
Thanks again!
Eric
On Sun, Dec 12, 2010 at 2:04 PM, Gustavo Narea <[email protected]> wrote:
> Hello,
>
> I'm afraid the only solution would be to write a WSGI middleware like:
>
> class SSLOnlyLoginMiddleware(object):
>
> def __init__(self, app):
> self.app = app
>
> def __call__(self, environ, start_response):
> if environ['PATH_INFO'].startswith("/login/") and
> environ['wsgi.url_scheme'] != "https":
> headers = [("Location", "https://example.org/login")]
> start_response("301 Moved Permanently", headers)
> body = [""]
> else:
> body = self.app(environ, start_response)
>
> return body
>
> And put it before repoze.what/who.
>
> HTH,
>
> - Gustavo
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<pylons-discuss%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.