def LoginRedirect(login_url, hostname, port, relative_url, outfile):
 hostname = os.environ['NGINX_HOST']
 port = os.environ['NGINX_PORT']
 dest_url = ('http://%s:%s%s' % (hostname, port, relative_url))
 redirect_url = ('http://%s:%s%s?%s=%s' % (hostname, port, login_url, CONTINUE_PARAM, urllib.quote(dest_url)))
 outfile.write('Status: 302 Requires login\r\n')
 output_headers = []
 output_headers.append(ClearUserInfoCookie())
 for header in output_headers:
  outfile.write(header)
 outfile.write(('Location: %s\r\n\r\n' % redirect_url))

def LoginRedirect ( login_url , hostname , port , relative_url , outfile ) : hostname = os . environ [ 'NGINX_HOST' ] port = os . environ [ 'NGINX_PORT' ] dest_url = ( 'http://%s:%s%s' % ( hostname , port , relative_url ) ) redirect_url = ( 'http://%s:%s%s?%s=%s' % ( hostname , port , login_url , CONTINUE_PARAM , urllib . quote ( dest_url ) ) ) outfile . write ( 'Status: 302 Requires login\r\n' ) output_headers = [ ] output_headers . append ( ClearUserInfoCookie ( ) ) for header in output_headers : outfile . write ( header ) outfile . write ( ( 'Location: %s\r\n\r\n' % redirect_url ) )
writes a login redirection url to a user .