cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graaf, Edgar de (fin)" <Edgar.de.Gr...@ordina.nl>
Subject RE: how do I redirect in an Action?
Date Thu, 23 May 2002 15:25:03 GMT
Harry,

I have to look in to you example later. 
But the last redirect is to a page that ask you to try again... when the
action doesn't fail(the password is right) that redirect is not executed
(that between the <map:act> is).

-----Oorspronkelijk bericht-----
Van: Lai, Harry [mailto:HLai@coremetrics.com]
Verzonden: donderdag 23 mei 2002 17:19
Aan: 'cocoon-users@xml.apache.org'
Onderwerp: RE: how do I redirect in an Action?


Hi Christopher and Edgar,

Couple things.  I could be wrong, but I believe in Edgar's example, the
redirect would always execute (since it sits outside the action).

Also, depending on how many protected url matchers you have, you can also
delegate all work to a resource where you could put all your authentication
and redirect logic (so you don't have to have it in each matcher).  So you
could do something like this:

	<map:match pattern="some protected url">
		<map:call resource="authenticatedAccess">
			<map:parameter name="someIDForThisPipe"
value="foo"/>
			... any other params you might need to process this
pipe ...
		</map:call>
	</map:match>

	<map:match pattern="some other protected url">
		<map:call resource="authenticatedAccess">
			<map:parameter name="someIDForThisPipe"
value="bar"/>
			... any other params you might need to process this
pipe ...
		</map:call>
	</map:match>

And the resource might look like:

	<map:resource name="authenticatedAccess">
		<map:act type="my-authenticator">
			<map:select type="parameter">
				<map:parameter
name="parameter-selector-test" value="{authStatus}"/>
				<map:when test="success">
					... stuff to process pipeline based
on params
				</map:when>
				<map:otherwise>
					<map:redirect-to
uri="loginpage.html"/>
				</map:otherwise>
			</map:select>
		</map:act>
	</map:resource>


Anyway, hope that helps!

Harry

-----Original Message-----
From: Graaf, Edgar de (fin) [mailto:Edgar.de.Graaf@ordina.nl]
Sent: Thursday, May 23, 2002 10:01 AM
To: 'cocoon-users@xml.apache.org'
Subject: RE: how do I redirect in an Action?


Christopher,

<map:act...> can't contain matchers, how else would cocoon know that the
action should be run?

try:

      <map:match pattern="some protected url">
	<map:act type="my-authenticator">
            ...
	</map:act>
	<map:redirect-to uri="loginpage.html"/>
      </map:match>

      <map:match pattern="some other protected url">
	<map:act type="my-authenticator">
            ...
	</map:act>
	<map:redirect-to uri="loginpage.html"/>
      </map:match>

regards

Edgar

-----Oorspronkelijk bericht-----
Van: Christopher Painter-Wakefield [mailto:paint007@mc.duke.edu]
Verzonden: donderdag 23 mei 2002 15:52
Aan: cocoon-users@xml.apache.org
Onderwerp: Re: how do I redirect in an Action?



I'm trying to implement a homegrown authentication scheme.  One of our
types of users will be "authenticated" by coming into the system with
appropriate credentials as request parameters in the URL (we will e-mail
them their unique URL).  This is to avoid generating a large number of user
ids and requiring all these users to remember credentials for a system they
will likely use once or twice a year.  None of the existing server-level
authentication schemes would seem to support this.

Once the user has "logged in" by providing the correct credentials, I
planned to store their identity and the fact that they have been
authenticated in their session.

So, each time a request is made to a protected page, I need to first check
the session to see if the user is already authenticated.  If not, I need to
check the request parameters, if available, against the database.  If both
of these fail, I need to redirect the user to a polite login failure page
(at some point we will have users that use a traditional login mechanism,
at which point we'll probably redirect to a login form).

I read the Action docs and searched through the mail archives, and I
thought I could do something like this:

<map:act type="my-authenticator">
      <map:match pattern="some protected url">
            ...
      </map:match>

      <map:match pattern="some other protected url">
            ...
      </map:match>
</map:act>

As I understood it, if the authentication fails, I would redirect to my
failure page in the Action and return null to prevent anything inside the
<map:act> element from running.  If the authentication succeeds, I return
an empty Map and the stuff inside the <map:act> element will run as usual.
Now that I'm saying all that it doesn't sound very likely, but I swear I
got it all from the docs.

Any suggestions?

-Christopher



From: "Christopher Painter-Wakefield" <paint007@mc.duke.edu>

> What is the proper way to redirect in an Action?

Why do you have to redirect in an action?
I would not suggest it.

Redirect instead in the sitemap based on the results of the Action.

--
Nicola Ken Barozzi                   nicolaken@apache.org
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)
---------------------------------------------------------------------




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message