[Catalyst] $c->user and session questions

2012-05-31 Thread Kenneth S Mclane
I have an LDAP server authenticating my users. The look up returns a ton 
of fields in a hash. My questions are as follows:

1. What happens to this data/information? Is it stored in the $c->user 
object?

2. If it is, how do I access it? 

3. Is there a simple way to look at what is stored in the user object?

4. I would like to store the users role in the session object so it can be 
accessed for authorization purposes. The docs only have an example of 
storing stuff in a shopping cart, which is a bit more than I need, but 
there isn't enough there for me to figure out how to store just one thing, 
and retrieve it, of course. Can someone show me how to do this?

Here is a sample of what comes back from the ldap lookup:

SEQUENCE {
051D   11: STRING = 'hrFirstName'
052A9: SET {
05307:   STRING = 'KENNETH'
0539 : }
0539 :   }

I would like to use this as a greeting string in my site wrapper, but I'm 
not sure how to reference it, or if it is even in the object.

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] $c->user and session questions

2012-05-31 Thread Tomas Doran

On 31 May 2012, at 14:00, Kenneth S Mclane wrote:

> I have an LDAP server authenticating my users. The look up returns a ton of 
> fields in a hash. My questions are as follows: 
> 
> 1. What happens to this data/information? Is it stored in the $c->user 
> object? 

Yes

> 2. If it is, how do I access it? 

https://metacpan.org/module/Catalyst::Authentication::Store::LDAP::User

Like that. Specifically the ->ldap_entry method is probably what you're after.

> 3. Is there a simple way to look at what is stored in the user object? 

Data::Dumper::Dumper($c->user) ?

> 4. I would like to store the users role in the session object so it can be 
> accessed for authorization purposes. The docs only have an example of storing 
> stuff in a shopping cart, which is a bit more than I need, but there isn't 
> enough there for me to figure out how to store just one thing, and retrieve 
> it, of course. Can someone show me how to do this? 
> 

You need to override the user class, and implement the for_session and 
from_session methods to get additionally stuff serialized.

Cheers
t0m


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] $c->user and session questions

2012-05-31 Thread Kenneth S Mclane
I found that I can simply reference $c->user->hrfirstname. 

As to the role info, that comes from a different source (an sqlite db just 
for this info). I found that $c->session(role => $role); works to insert 
the value in the session, so I just need to pull the data from the table 
into the variable and then I'm good. Thanks for the suggestions.

Tomas Doran  wrote on 05/31/2012 08:31:31 AM:

> From:
> 
> Tomas Doran 
> 
> To:
> 
> The elegant MVC web framework 
> 
> Date:
> 
> 05/31/2012 08:32 AM
> 
> Subject:
> 
> Re: [Catalyst] $c->user and session questions
> 
> 
> On 31 May 2012, at 14:00, Kenneth S Mclane wrote:
> 
> > I have an LDAP server authenticating my users. The look up returns
> a ton of fields in a hash. My questions are as follows: 
> > 
> > 1. What happens to this data/information? Is it stored in the 
> $c->user object? 
> 
> Yes
> 
> > 2. If it is, how do I access it? 
> 
> https://metacpan.org/module/Catalyst::Authentication::Store::LDAP::User
> 
> Like that. Specifically the ->ldap_entry method is probably what you're 
after.
> 
> > 3. Is there a simple way to look at what is stored in the user object? 

> 
> Data::Dumper::Dumper($c->user) ?
> 
> > 4. I would like to store the users role in the session object so 
> it can be accessed for authorization purposes. The docs only have an
> example of storing stuff in a shopping cart, which is a bit more 
> than I need, but there isn't enough there for me to figure out how 
> to store just one thing, and retrieve it, of course. Can someone 
> show me how to do this? 
> > 
> 
> You need to override the user class, and implement the for_session 
> and from_session methods to get additionally stuff serialized.
> 
> Cheers
> t0m
> 
> 
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: 
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
> 
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/