You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jean-Christophe Kermagoret <jc...@babelobjects.com> on 2003/12/06 21:26:48 UTC

Access session user data from flow

Hi List,
it it possible to access from flow user data stored in the session after 
an authentication ?

I authenticate with success and I put the following data in the session :

/authentication
  /ID
  /data
        /firstname
        /surname
...

How to access it with Flowscript ?

Thanks
-- 

Jean-Christophe Kermagoret
jck@BabelObjects.Com



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


Re: Access session user data from flow

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Jeremy Quinn dijo:
> fine by me ..... so maybe we had better move this thread over to the
> dev list ..... ??

Yep. Let's go there. :-DDD

Best Regards,

Antonio Gallardo


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


Re: Access session user data from flow

Posted by Upayavira <uv...@upaya.co.uk>.
Jeremy Quinn wrote:

>
> On 10 Dec 2003, at 13:33, Upayavira wrote:
>
>> Jeremy Quinn wrote:
>>
>>>
>>> Some possible options for where to work:
>>>
>>> 1) Start a new flowscript auth-fw in the scratchpad, intended as a 
>>> replacement for the one in blocks
>>> 2) Work on the flowscript auth-fw directly in it's block
>>> 3) Put together a new flowscript auth-fw in a Wiki page, to replace 
>>> the block when ready.
>>> etc.
>>
>>
>> 2).
>>
>> It is not stable, nor documented. So go ahead and make it good. Fix & 
>> work on what's there.
>> Upayavira
>
>
> fine by me ..... so maybe we had better move this thread over to the 
> dev list ..... ??

Yup.



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


Re: Access session user data from flow

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On 10 Dec 2003, at 13:33, Upayavira wrote:

> Jeremy Quinn wrote:
>
>>
>> Some possible options for where to work:
>>
>> 1) Start a new flowscript auth-fw in the scratchpad, intended as a 
>> replacement for the one in blocks
>> 2) Work on the flowscript auth-fw directly in it's block
>> 3) Put together a new flowscript auth-fw in a Wiki page, to replace 
>> the block when ready.
>> etc.
>
> 2).
>
> It is not stable, nor documented. So go ahead and make it good. Fix & 
> work on what's there.
> Upayavira

fine by me ..... so maybe we had better move this thread over to the 
dev list ..... ??

regards Jeremy

Re: Access session user data from flow

Posted by Upayavira <uv...@upaya.co.uk>.
Jeremy Quinn wrote:

>
> Some possible options for where to work:
>
> 1) Start a new flowscript auth-fw in the scratchpad, intended as a 
> replacement for the one in blocks
> 2) Work on the flowscript auth-fw directly in it's block
> 3) Put together a new flowscript auth-fw in a Wiki page, to replace 
> the block when ready.
> etc.

2).

It is not stable, nor documented. So go ahead and make it good. Fix & 
work on what's there.
 
Upayavira


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


Re: Access session user data from flow

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On 9 Dec 2003, at 03:13, Antonio Gallardo wrote:

> Jeremy Quinn dijo:
>>
>> On 8 Dec 2003, at 14:31, Antonio Gallardo wrote:
>>
>>> Upayavira dijo:
>>>> Is it more useful to return a UserHandler than a boolean? The 
>>>> auth.js
>>>> code is experimental, and can thus be changed. If you can supply a
>>>> usecase as to why it should be changed, personally, I'd say go ahead
>>>> and
>>>> commit a change. It is good to have real users using the code, as
>>>> what I
>>>> came up with was just a first iteration.
>>
>> My use-case was that I wanted to read values from the authentication
>> XML in my 'login' script, because we needed to see certain values (eg.
>> the user's full name) outside of the security zone. I read the values 
>> I
>> need and set them as Session Attributes.
>
> I did the same :-D But I think you did it more general. I just added 
> some
> functions to allow this:

Handy

> /* Returns the userID in the session */
> function auth_getUserID() {
>   var handler = "authhandler";
>   var authMgr = null;
>   try {
>     authMgr = 
> cocoon.getComponent(Packages.o.a.c...Authentication....ROLE);
>     // autentication
>     if (authMgr.checkAuthentication(null, handler, null)) {
>       // User already autenticated, get the UserID
>       var userId = authMgr.getState().getHandler().getUserId();
>       return parseInt(userId);
>     }
>   } finally {
>     cocoon.releaseComponent(authMgr);
>   }
>   return null;
> }
>
>> A much better way of handling that IMHO would be to use a FlowScript
>> based authentication pipeline, and set up the Session there. This
>> unfortunately is still alluding us, we still get bizarre errors (null
>> FOM_Request etc.) when attempting this, after much research ..... we
>> now only get it the 2nd time someone logs in  =:'(  (deeply weird).
>
> In our case, we have the code already stable. No problems.

I'd love to see how ....

>
>> Another thing I have done to the flow-auth-fw is to Woodify it .....
>> maybe you'd be more interested in that?
>
> We have "woodified" code too. :-D

Ha!

>>> Hmm... I think this kind of changes will break the authentication for
>>> people that already use it (I am one of them). I prefer to first talk
>>> about this change and if it is OK. Make the change.
>>>
>>> Is this OK?
>>
>> No offence Antonio , but is it a Sample or an API ? :)
>
> Part of them is sample, but there is an auth.js inside the
> authentication-fw block that is not a sample to me. I mean:
>
> org/apache/cocoon/webapps/authentication/flow/javascript/auth.js
>
>> But I am perfectly happy to discuss any changes that might be made 
>> ....
>
> I agree. Lets discuss about it. I think it is a good idea. I don't have
> problem to show the code we did. Is this OK? Then I am sure we can got 
> a
> better support for woody and flow in the auth-fw.

OK, so how to move forward?

Some possible options for the modifications to make:

1) Woodification
2) Flow-base authorisation pipeline
3) i18n
4) utility functions to read authorisation data
5) reject User after a certain number of failed logins
etc.

Some possible options for where to work:

1) Start a new flowscript auth-fw in the scratchpad, intended as a 
replacement for the one in blocks
2) Work on the flowscript auth-fw directly in it's block
3) Put together a new flowscript auth-fw in a Wiki page, to replace the 
block when ready.
etc.

WDYT?

regards Jeremy



Re: Access session user data from flow

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Jeremy Quinn dijo:
>
> On 8 Dec 2003, at 14:31, Antonio Gallardo wrote:
>
>> Upayavira dijo:
>>> Is it more useful to return a UserHandler than a boolean? The auth.js
>>> code is experimental, and can thus be changed. If you can supply a
>>> usecase as to why it should be changed, personally, I'd say go ahead
>>> and
>>> commit a change. It is good to have real users using the code, as
>>> what I
>>> came up with was just a first iteration.
>
> My use-case was that I wanted to read values from the authentication
> XML in my 'login' script, because we needed to see certain values (eg.
> the user's full name) outside of the security zone. I read the values I
> need and set them as Session Attributes.

I did the same :-D But I think you did it more general. I just added some
functions to allow this:

/* Returns the userID in the session */
function auth_getUserID() {
  var handler = "authhandler";
  var authMgr = null;
  try {
    authMgr = cocoon.getComponent(Packages.o.a.c...Authentication....ROLE);
    // autentication
    if (authMgr.checkAuthentication(null, handler, null)) {
      // User already autenticated, get the UserID
      var userId = authMgr.getState().getHandler().getUserId();
      return parseInt(userId);
    }
  } finally {
    cocoon.releaseComponent(authMgr);
  }
  return null;
}

> A much better way of handling that IMHO would be to use a FlowScript
> based authentication pipeline, and set up the Session there. This
> unfortunately is still alluding us, we still get bizarre errors (null
> FOM_Request etc.) when attempting this, after much research ..... we
> now only get it the 2nd time someone logs in  =:'(  (deeply weird).

In our case, we have the code already stable. No problems.

> Another thing I have done to the flow-auth-fw is to Woodify it .....
> maybe you'd be more interested in that?

We have "woodified" code too. :-D

>> Hmm... I think this kind of changes will break the authentication for
>> people that already use it (I am one of them). I prefer to first talk
>> about this change and if it is OK. Make the change.
>>
>> Is this OK?
>
> No offence Antonio , but is it a Sample or an API ? :)

Part of them is sample, but there is an auth.js inside the
authentication-fw block that is not a sample to me. I mean:

org/apache/cocoon/webapps/authentication/flow/javascript/auth.js

> But I am perfectly happy to discuss any changes that might be made ....

I agree. Lets discuss about it. I think it is a good idea. I don't have
problem to show the code we did. Is this OK? Then I am sure we can got a
better support for woody and flow in the auth-fw.

Best Regards,

Antonio Gallardo


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


Re: Access session user data from flow

Posted by Upayavira <uv...@upaya.co.uk>.
Jeremy Quinn wrote:

>
> On 8 Dec 2003, at 14:31, Antonio Gallardo wrote:
>
>> Upayavira dijo:
>>
>>> Is it more useful to return a UserHandler than a boolean? The auth.js
>>> code is experimental, and can thus be changed. If you can supply a
>>> usecase as to why it should be changed, personally, I'd say go ahead 
>>> and
>>> commit a change. It is good to have real users using the code, as 
>>> what I
>>> came up with was just a first iteration.
>>
>
> My use-case was that I wanted to read values from the authentication 
> XML in my 'login' script, because we needed to see certain values (eg. 
> the user's full name) outside of the security zone. I read the values 
> I need and set them as Session Attributes.
>
> A much better way of handling that IMHO would be to use a FlowScript 
> based authentication pipeline, and set up the Session there. This 
> unfortunately is still alluding us, we still get bizarre errors (null 
> FOM_Request etc.) when attempting this, after much research ..... we 
> now only get it the 2nd time someone logs in  =:'(  (deeply weird).
>
> Another thing I have done to the flow-auth-fw is to Woodify it ..... 
> maybe you'd be more interested in that?
>
>> Hmm... I think this kind of changes will break the authentication for
>> people that already use it (I am one of them). I prefer to first talk
>> about this change and if it is OK. Make the change.
>>
>> Is this OK?
>
>
> No offence Antonio , but is it a Sample or an API ? :)

It is an unstable API. Look at the comment at the top of the auth.js 
file: USE AT YOUR OWN RISK, or something like that.

Therefore we can change it. Fair enough discuss the changes, but it IS 
NOT FINISHED, and needs polishing by people who are actually using it. 
Right now, thats you guys. (I implemented the auth.js and a sample, but 
have ended up doing auth my own way).

Regards, Upayavira

>
> But I am perfectly happy to discuss any changes that might be made ....
>
> regards Jeremy
>
>
>



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


Re: Access session user data from flow

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On 8 Dec 2003, at 14:31, Antonio Gallardo wrote:

> Upayavira dijo:
>> Is it more useful to return a UserHandler than a boolean? The auth.js
>> code is experimental, and can thus be changed. If you can supply a
>> usecase as to why it should be changed, personally, I'd say go ahead 
>> and
>> commit a change. It is good to have real users using the code, as 
>> what I
>> came up with was just a first iteration.

My use-case was that I wanted to read values from the authentication 
XML in my 'login' script, because we needed to see certain values (eg. 
the user's full name) outside of the security zone. I read the values I 
need and set them as Session Attributes.

A much better way of handling that IMHO would be to use a FlowScript 
based authentication pipeline, and set up the Session there. This 
unfortunately is still alluding us, we still get bizarre errors (null 
FOM_Request etc.) when attempting this, after much research ..... we 
now only get it the 2nd time someone logs in  =:'(  (deeply weird).

Another thing I have done to the flow-auth-fw is to Woodify it ..... 
maybe you'd be more interested in that?

> Hmm... I think this kind of changes will break the authentication for
> people that already use it (I am one of them). I prefer to first talk
> about this change and if it is OK. Make the change.
>
> Is this OK?

No offence Antonio , but is it a Sample or an API ? :)

But I am perfectly happy to discuss any changes that might be made ....

regards Jeremy




Re: Access session user data from flow

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Upayavira dijo:
> Is it more useful to return a UserHandler than a boolean? The auth.js
> code is experimental, and can thus be changed. If you can supply a
> usecase as to why it should be changed, personally, I'd say go ahead and
> commit a change. It is good to have real users using the code, as what I
> came up with was just a first iteration.

Hmm... I think this kind of changes will break the authentication for
people that already use it (I am one of them). I prefer to first talk
about this change and if it is OK. Make the change.

Is this OK?

Best Regards,

Antonio Gallardo


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


Re: Access session user data from flow

Posted by Upayavira <uv...@upaya.co.uk>.
Jeremy Quinn wrote:

>
> On 8 Dec 2003, at 13:33, Jean-Christophe Kermagoret wrote:
>
>>
>> Hello Jeremy,
>> thanks for your feedback.
>>
>> 1st method is ok.
>> I'd like to use the second method too, but :
>> * I get null handler with cocoon.parameters["handler"]
>
>
> this is a param passed from my sitemap to my flowscript, it is the 
> name  of the authorisation handler
>
> <map:component-configurations>
>     <authentication-manager>
>         <handlers>
>             <handler name="myAuthorisation">
>                 <redirect-to uri="cocoon:/login"/>
>                 <authentication uri="cocoon:raw:/authenticate"/>
>             </handler>
>         </handlers>
>     </authentication-manager>
> </map:component-configurations>
>
> . . .
>
> <map:match pattern="do-login">
>     <!-- try to login -->
>     <map:call function="woody">
>         <map:parameter name="function" value="login"/>
>         . . .
>         <map:parameter name="handler" value="myAuthorisation"/>
>         . . .
>     </map:call>
> </map:match>
>
> function login(form) {
>   . . .
>   var handler = cocoon.parameters["handler"];
>   . . .
> }
>
>> * and what is authParams ?
>
>
> These are the parameters that get passed to the 'authenticate' pipeline.
>
> See  
> cocoon/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/ 
> authentication/flow/javascript/auth.js
>
> See the function called 'auth_login'.
>
> I took this and adapted it to return the UserHandler rather than a  
> boolean.

Jeremy,

Is it more useful to return a UserHandler than a boolean? The auth.js 
code is experimental, and can thus be changed. If you can supply a 
usecase as to why it should be changed, personally, I'd say go ahead and 
commit a change. It is good to have real users using the code, as what I 
came up with was just a first iteration.

Regards, Upayavira



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


Re: Access session user data from flow

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On 8 Dec 2003, at 13:33, Jean-Christophe Kermagoret wrote:

>
> Hello Jeremy,
> thanks for your feedback.
>
> 1st method is ok.
> I'd like to use the second method too, but :
> * I get null handler with cocoon.parameters["handler"]

this is a param passed from my sitemap to my flowscript, it is the name  
of the authorisation handler

<map:component-configurations>
	<authentication-manager>
		<handlers>
			<handler name="myAuthorisation">
				<redirect-to uri="cocoon:/login"/>
				<authentication uri="cocoon:raw:/authenticate"/>
			</handler>
		</handlers>
	</authentication-manager>
</map:component-configurations>

. . .

<map:match pattern="do-login">
	<!-- try to login -->
	<map:call function="woody">
		<map:parameter name="function" value="login"/>
		. . .
		<map:parameter name="handler" value="myAuthorisation"/>
		. . .
	</map:call>
</map:match>

function login(form) {
   . . .
   var handler = cocoon.parameters["handler"];
   . . .
}

> * and what is authParams ?

These are the parameters that get passed to the 'authenticate' pipeline.

See  
cocoon/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/ 
authentication/flow/javascript/auth.js

See the function called 'auth_login'.

I took this and adapted it to return the UserHandler rather than a  
boolean.

>
> Regards,
>
> Jeremy Quinn wrote:
>
>>
>> On 6 Dec 2003, at 20:26, Jean-Christophe Kermagoret wrote:
>>
>>> Hi List,
>>> it it possible to access from flow user data stored in the session   
>>> after an authentication ?
>>>
>>> I authenticate with success and I put the following data in the   
>>> session :
>>>
>>> /authentication
>>>  /ID
>>>  /data
>>>        /firstname
>>>        /surname
>>> ...
>>>
>>> How to access it with Flowscript ?
>>
>>
>> There are two possibilities that I know of ...... there are probably   
>> more ....
>>
>> 1. Via input modules :
>>
>> <map:parameter name="userid"   
>> value="{session-context:authentication/authentication/ID}"/>
>>
>> which might be used to get the Sitemap to pass a parameter from the   
>> Session Context to your FlowScript.
>>
>> 2. Via the AuthenticationManager at login time :
>>
>> The auth flowscripts call the 'login' method of   
>> 'AuthenticationManager'. 'login' returns a 'UserHandler', the   
>> 'UserHandler' can give you access to your data:
>>
>> var authMgr = cocoon.getComponent          
>> (Packages.org.apache.cocoon.webapps.authentication.AuthenticationManag 
>> er .ROLE);
>> var userhandler =  authMgr.login (handler, null, authParams);
>> if (userhandler != null) {
>>     cocoon.log.info ("firstname: " + userhandler.getContext   
>> ().getContextInfo ().get ("firstname"));
>>     cocoon.log.info ("surname: " + userhandler.getContext   
>> ().getContextInfo ().get ("surname"));
>> }
>>
>>
>> Keep in mind that the authentication context is only available while   
>> you are in a protected URL.
>>
>> HTH
>>
>> regards Jeremy
>
>
>
> -- 
>
> Jean-Christophe Kermagoret
> jck@BabelObjects.Com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>

Re: Access session user data from flow

Posted by Jean-Christophe Kermagoret <jc...@babelobjects.com>.
Hello Jeremy,
thanks for your feedback.

1st method is ok.
I'd like to use the second method too, but :
* I get null handler with cocoon.parameters["handler"]
* and what is authParams ?

Regards,

Jeremy Quinn wrote:

>
> On 6 Dec 2003, at 20:26, Jean-Christophe Kermagoret wrote:
>
>> Hi List,
>> it it possible to access from flow user data stored in the session  
>> after an authentication ?
>>
>> I authenticate with success and I put the following data in the  
>> session :
>>
>> /authentication
>>  /ID
>>  /data
>>        /firstname
>>        /surname
>> ...
>>
>> How to access it with Flowscript ?
>
>
> There are two possibilities that I know of ...... there are probably  
> more ....
>
> 1. Via input modules :
>
> <map:parameter name="userid"  
> value="{session-context:authentication/authentication/ID}"/>
>
> which might be used to get the Sitemap to pass a parameter from the  
> Session Context to your FlowScript.
>
> 2. Via the AuthenticationManager at login time :
>
> The auth flowscripts call the 'login' method of  
> 'AuthenticationManager'. 'login' returns a 'UserHandler', the  
> 'UserHandler' can give you access to your data:
>
> var authMgr = cocoon.getComponent    
>      
> (Packages.org.apache.cocoon.webapps.authentication.AuthenticationManager 
> .ROLE);
> var userhandler =  authMgr.login (handler, null, authParams);
> if (userhandler != null) {
>     cocoon.log.info ("firstname: " + userhandler.getContext  
> ().getContextInfo ().get ("firstname"));
>     cocoon.log.info ("surname: " + userhandler.getContext  
> ().getContextInfo ().get ("surname"));
> }
>
>
> Keep in mind that the authentication context is only available while  
> you are in a protected URL.
>
> HTH
>
> regards Jeremy



-- 

Jean-Christophe Kermagoret
jck@BabelObjects.Com



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


Re: Access session user data from flow

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On 6 Dec 2003, at 20:26, Jean-Christophe Kermagoret wrote:

> Hi List,
> it it possible to access from flow user data stored in the session  
> after an authentication ?
>
> I authenticate with success and I put the following data in the  
> session :
>
> /authentication
>  /ID
>  /data
>        /firstname
>        /surname
> ...
>
> How to access it with Flowscript ?

There are two possibilities that I know of ...... there are probably  
more ....

1. Via input modules :

<map:parameter name="userid"  
value="{session-context:authentication/authentication/ID}"/>

which might be used to get the Sitemap to pass a parameter from the  
Session Context to your FlowScript.

2. Via the AuthenticationManager at login time :

The auth flowscripts call the 'login' method of  
'AuthenticationManager'. 'login' returns a 'UserHandler', the  
'UserHandler' can give you access to your data:

var authMgr = cocoon.getComponent 	
	 
(Packages.org.apache.cocoon.webapps.authentication.AuthenticationManager 
.ROLE);
var userhandler =  authMgr.login (handler, null, authParams);
if (userhandler != null) {
	cocoon.log.info ("firstname: " + userhandler.getContext  
().getContextInfo ().get ("firstname"));
	cocoon.log.info ("surname: " + userhandler.getContext  
().getContextInfo ().get ("surname"));
}


Keep in mind that the authentication context is only available while  
you are in a protected URL.

HTH

regards Jeremy