You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Hadmut Danisch <ha...@danisch.de> on 2007/03/08 11:17:57 UTC

Generating login forms from authen handler?

Hi,

how would I generate a web page (i.e. a login form) from a authen
handler in the case that the user is not authenticated yet ?

Can the authen handler generate HTML code and pass it back to the
client as an immediate reply?

regards
Hadmut

Re: Generating login forms from authen handler?

Posted by Sean Quinlan <se...@quinlan.org>.
On Thu, 2007-03-08 at 12:05 +0000, John ORourke wrote:
> >
> > I am currently doing something similiar, I just modify the URL to that
> > of the script to be called. 
> >
> > But I need to generate the HTML code from *within* the authen handler
> > (needs dynamic generation etc.). 
> >   
> 
> Ah I see - probably best not to output stuff at that stage as it could 
> confuse the response handler depending on your setup, but you could 
> generate the necessary HTML and put it in a pnote, then in whatever 
> handles the response just grab that and write it out.

Or set the response handler to a special 'page' as John already
mentioned, and only put whatever specific bits of information you want
to use in pnote. That page then (I'd suggest a handler for simplicity in
this case, unless your CGI's already run under the registry with access
to the request object) can access the pnote(s) during the appropriate
phase and generate the response as you need.

-- 
Sean Quinlan
sean@quinlan.org
www.getfirefox.com

Re: Generating login forms from authen handler?

Posted by John ORourke <jo...@o-rourke.org>.
>
> I am currently doing something similiar, I just modify the URL to that
> of the script to be called. 
>
> But I need to generate the HTML code from *within* the authen handler
> (needs dynamic generation etc.). 
>   

Ah I see - probably best not to output stuff at that stage as it could 
confuse the response handler depending on your setup, but you could 
generate the necessary HTML and put it in a pnote, then in whatever 
handles the response just grab that and write it out.

hth,
John


Re: Generating login forms from authen handler?

Posted by Hadmut Danisch <ha...@danisch.de>.
On Thu, Mar 08, 2007 at 10:37:37AM +0000, John ORourke wrote:
> The authen handler can simply return the right status code - eg. login 
> failed, OK, declined etc
> 
> The response phase can then do something special with it - I have sites 
> on which the front page ( / ) has the login form, and in httpd.conf I do:
> 
> <VirtualHost>
>    ErrorDocument 401 /
> </VirtualHost>



I am currently doing something similiar, I just modify the URL to that
of the script to be called. 

But I need to generate the HTML code from *within* the authen handler
(needs dynamic generation etc.). 

regards
Hadmut


Re: Generating login forms from authen handler?

Posted by John ORourke <jo...@o-rourke.org>.
Hadmut Danisch wrote:
> how would I generate a web page (i.e. a login form) from a authen
> handler in the case that the user is not authenticated yet ?
>
> Can the authen handler generate HTML code and pass it back to the
> client as an immediate reply?
>   

The authen handler can simply return the right status code - eg. login 
failed, OK, declined etc

The response phase can then do something special with it - I have sites 
on which the front page ( / ) has the login form, and in httpd.conf I do:

<VirtualHost>
    ErrorDocument 401 /
</VirtualHost>

this means if my authen handler returns failed, the ErrorDocument 
directive will do an internal redirect to the page / which contains the 
login form.  The status code returned to the browser is still 401, which 
is great because it tells the browser that the user/pass was invalid and 
therefore not to remember it.  For added karma, the login page detects 
wether it's a 401 and if so, displays the 'login failed' message.

cheers
John