[Repoze-dev] tg.repoze.who and ProxyPass
percious
percious17 at gmail.com
Mon May 12 12:46:28 EDT 2008
Ok, so I started digging, because I have to get this working for work
now....
Looking at the Tosca source: http://svn.turbogears.org/projects/ToscaWidgets/trunk/tw/mods/base.py
The "url" function:
def url(self, url):
"""
Returns the absolute path for the given url.
"""
prefix = self.request_local.environ['toscawidgets.prefix']
script_name = self.request_local.environ['SCRIPT_NAME']
return ''.join([script_name, prefix, url])
makes a call to a StackedObjectProxy object and pulls out the
'mytg2app' from 'SCRIPT_NAME'. Is it possible to create the same
StackedObjectProxy in the repoze software so that the redirect does a
similar thing?
cheers.
-chris
On May 11, 6:41 pm, Chris McDonough <chr... at plope.com> wrote:
> I suspect taking a look at the Paste urlmap composite implementation would give
> you a clue as to what needs to change in the plugin (e.g. figure out how/if it
> signals that a particular prefix is in use). Even if it doesn't immediately go
> into the repoze.who mainline, you should be able to make a new plugin through
> judicious cut and paste and hack on it.
>
> In particular, its' "challenge" method looks like this:
>
> # IChallenger
> def challenge(self, environ, status, app_headers, forget_headers):
> url_parts = list(urlparse.urlparse(self.login_form_url))
> query = url_parts[4]
> query_elements = cgi.parse_qs(query)
> came_from = environ.get('came_from', construct_url(environ))
> query_elements['came_from'] = came_from
> url_parts[4] = urllib.urlencode(query_elements, doseq=True)
> login_form_url = urlparse.urlunparse(url_parts)
> headers = [ ('Location', login_form_url) ]
> headers = headers + forget_headers
> return HTTPFound(headers=headers)
>
> The login_form_url should be composed dynamically based on stuff in the
> environment set by the urlmap composite plus whatever is set in the
> configuration of the plugin.
>
> - C
>
>
>
> percious wrote:
> > Since the tg.repoze.who creates a paster app, I don't really see why
> > the page could not know where in the url path it should direct
> > people. I am ccing Alberto in the hopes that he can help us clear
> > this stuff up.
>
> > cheers.
> > -chris
>
> > On May 9, 5:32 pm, Chris McDonough <chr... at plope.com> wrote:
> >> It's statically configured now. The plugin itself would need to change to
> >> support redirecting to a dynamic URL.
>
> >> If you weren't up for changing the plugin, you could *try* using the
> >> "non-redirecting" form plugin (replace the call to "form = RedirectingFormPlugin
> >> ..." with what's below). This plugin renders a login form directly without
> >> needing to redirect:
>
> >> FORMBODY = """
> >> <html>
> >> <head>
> >> <title>Log In</title>
> >> </head>
> >> <body>
> >> <div>
> >> <b>Log In</b>
> >> </div>
> >> <br/>
> >> <form method="POST" action="?__do_login=true">
> >> <table border="0">
> >> <tr>
> >> <td>User Name</td>
> >> <td><input type="text" name="login"></input></td>
> >> </tr>
> >> <tr>
> >> <td>Password</td>
> >> <td><input type="password" name="password"></input></td>
> >> </tr>
> >> <tr>
> >> <td></td>
> >> <td><input type="submit" name="submit" value="Log In"/></td>
> >> </tr>
> >> </table>
> >> </form>
> >> <pre>
> >> </pre>
> >> </body>
> >> </html>
> >> """
> >> form = FormPlugin(login_qs='__do_login', rememberer_name='cookie', FORMBODY)
>
> >> - C
>
> >> percious wrote:
> >>> Yeah, I realized that. I was just wondering, how can I get it to
> >>> automatically figure out the paste prefix? This is something that
> >>> goes off without a hitch in toscawidgets.
> >>> cheers.
> >>> -chris
> >>> On May 9, 5:15 pm, Chris McDonough <chr... at plope.com> wrote:
> >>>> I think what you might be seeing if you're using the configuration of repoze.who
> >>>> implied byhttp://svn.turbogears.org/projects/tgrepozewho/trunk/tgrepozewho/midd...
> >>>> is that the thing that shows the challenge (the form plugin) is configured
> >>>> statically, e.g. (from that file):
> >>>> form = RedirectingFormPlugin('/login', '/login_handler', '/logout_handler',
> >>>> rememberer_name='cookie')
> >>>> The first argument there is the "login_form_url". That's the URL that
> >>>> repoze.who will redirect to when a login is required. You probably need to
> >>>> change this to support your environment.
> >>>> - C
> >>>> percious wrote:
> >>>>> So, I almost have my project up and running on the production server.
> >>>>> The thing is, I have a large server with many applications, and they
> >>>>> are all mounted at the highest level of the global tree: ie
> >>>>>http://my.ip.address.com/plone
> >>>>>http://my.ip.address.com/tg2app
> >>>>> All the applications are routed with apache using:
> >>>>> <VirtualHost *>
> >>>>> DocumentRoot /my/tg2app/public
> >>>>> ProxyPass /tg2app/http://127.0.0.1:8080/
> >>>>> ProxyPassReverse /tg2app/http://127.0.0.1:8080/
> >>>>> ...
> >>>>> </VirtualHost>
> >>>>> ok, so this all works fine with wsgi, all I have to do is add
> >>>>> something like:
> >>>>> [filter:proxy-prefix]
> >>>>> use = egg:PasteDeploy#prefix
> >>>>> prefix = /tg2app
> >>>>> [app:main]
> >>>>> filter-with = proxy-prefix
> >>>>> to my ini file and it works.
> >>>>> Until I go to login.
> >>>>> For whatever reason, the login script keeps sending me back to the
> >>>>> root... Is there a fix for this?
> >>>>> Also, once I have that working, it appears that I will have a
> >>>>> requirement to authenticate using Apache's authentication (ick) is
> >>>>> there a way to send the Apache Authentication over to repoze.who?
> >>>>> cheers.
> >>>>> -chris
> >>>>> _______________________________________________
> >>>>> Repoze-dev mailing list
> >>>>> Repoze-... at lists.repoze.org
> >>>>>http://lists.repoze.org/listinfo/repoze-dev
> >>>> _______________________________________________
> >>>> Repoze-dev mailing list
> >>>> Repoze-... at lists.repoze.orghttp://lists.repoze.org/listinfo/repoze-dev
> >>> _______________________________________________
> >>> Repoze-dev mailing list
> >>> Repoze-... at lists.repoze.org
> >>>http://lists.repoze.org/listinfo/repoze-dev
> >> _______________________________________________
> >> Repoze-dev mailing list
> >> Repoze-... at lists.repoze.orghttp://lists.repoze.org/listinfo/repoze-dev
> > _______________________________________________
> > Repoze-dev mailing list
> > Repoze-... at lists.repoze.org
> >http://lists.repoze.org/listinfo/repoze-dev
>
> _______________________________________________
> Repoze-dev mailing list
> Repoze-... at lists.repoze.orghttp://lists.repoze.org/listinfo/repoze-dev
More information about the Repoze-dev
mailing list