Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.web.serving.ProxyTrust Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 app
 proxies

Detailed Description

Middleware that rewrites the remote address according to trusted
proxies in the forward chain.

Definition at line 43 of file serving.py.


Constructor & Destructor Documentation

def MoinMoin.web.serving.ProxyTrust.__init__ (   self,
  app,
  proxies 
)

Definition at line 49 of file serving.py.

00049 
00050     def __init__(self, app, proxies):
00051         self.app = app
00052         self.proxies = proxies


Member Function Documentation

def MoinMoin.web.serving.ProxyTrust.__call__ (   self,
  environ,
  start_response 
)

Definition at line 53 of file serving.py.

00053 
00054     def __call__(self, environ, start_response):
00055         if 'HTTP_X_FORWARDED_FOR' in environ:
00056             addrs = environ.pop('HTTP_X_FORWARDED_FOR').split(',')
00057             addrs = [addr.strip() for addr in addrs]
00058         elif 'REMOTE_ADDR' in environ:
00059             addrs = [environ['REMOTE_ADDR']]
00060         else:
00061             addrs = [None]
00062         result = [addr for addr in addrs if addr not in self.proxies]
00063         if result:
00064             environ['REMOTE_ADDR'] = result[-1]
00065         elif addrs[-1] is not None:
00066             environ['REMOTE_ADDR'] = addrs[-1]
00067         else:
00068             del environ['REMOTE_ADDR']
00069         return self.app(environ, start_response)


Member Data Documentation

Definition at line 50 of file serving.py.

Definition at line 51 of file serving.py.


The documentation for this class was generated from the following file: