[Catalyst] Authentication Using Catalyst::Authentication::Store::LDAP

2010-02-15 Thread Amit Jha
Hi All,

In my authentication module I am trying to add  DBIC and LDAP authentication 
via Catalyst::Authentication::Store::LDAP. DBIC is working fine but LDAP is 
not. Following is app configuration file:

__PACKAGE__-config( 
    'Plugin::ConfigLoader' = {
    driver = {
    'General' = {
         -LowerCaseNames = 1,
 },
    },
    file = __PACKAGE__-path_to('conf'),
    },
    'Plugin::Session' = {
    expires = 3600,
    storage = '/home/amit/GISTFIND/tmp/session',
 },
 'Plugin::Authentication' = {
     default_realm = 'general',     
    general = {
        credential = {
        class = 'Password',
    password_field = 'login_password',
    password_type = 'clear'
    },
    store = {
        class = 'DBIx::Class',
    user_model = 'DB::Login',
    role_column = 'roles',
    }
    },
    ldap = {
     credential = {
        class = 'Password',
    password_field = 'password',
    password_type = 'clear'
    },
    store = {
                binddn  = cn=Manager, dc=example, dc=com,
    bindpw  = secret,
    class   = LDAP,
    ldap_server = 192.168.100.50,
    ldap_server_options = { timeout = 30, port = '389', },
    user_basedn = dc=example,dc=com,
    user_field  = uid,
    user_results_filter = sub { return shift-pop_entry },    
    },
 },
 },
);

When I search LDAP using Net::LDAP It authenticate the user and return the DN 
for that. 

dn:uid=shanu,dc=example,dc=com
 uid: shanu
userPassword: shanu
 objectClass: account
  simpleSecurityObject
  top
uid=shanu,dc=example,dc=com checks out!

But when I try the same from catalyst I won't show any thing. Can anyone point 
me what to do and how to debug it.

if ($c-authenticate({ id = $username, password = $password  }, 'ldap')) {
 $c-stash-{auth}- asa;
} 


Thanks

   


  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/___
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] FastCGI deployment - slow to complete request

2010-02-15 Thread Toby Corkindale

On 15/02/10 15:59, Steve Rippl wrote:

Hi,

I have a small Catalyst app, the production version of which has been
running pretty well using the built in server as there haven't been too
many user at once. I'm trying to anticipate higher concurrent usage and
switch to FastCGI (as that seems to be recommended in the book) and I
have the following running in Apache

FastCgiServer /srv/WsdSis/script/wsdsis_fastcgi.pl -processes 5
Alias / /srv/WsdSis/script/wsdsis_fastcgi.pl/

VirtualHost *:80
ServerName sis.woodlandschools.org
ServerAdmin webmas...@woodlandschool.org
DocumentRoot /srv/WsdSis/root
Alias /static /srv/WsdSis/root/static
/VirtualHost

Now this works, it's serving up the application, but each request is
really slow to complete! The obvious effect of this is that a page with
JavaScript waiting for a complete page before it does it's thing looks
dreadful for a while, the html has arrived but the browser is still
spinning, then eventually the page completes and the JS runs. (I know
about graceful failure for JS, but I have an app that is going to depend
on it!). If I switch this back to the built in server then the page is
completed faster than I can notice and the page renders correctly
immediately. Back on FastCGI and even a simple page request is taking
~10 seconds to complete (again, that html arrives straight away, but
then the browser keeps spinning as if it's still waiting on something).
This is running on a Debian 5 machine using libapache2-mod-fastcgi.


You can get good performance out of catalyst by just running the PREFORK 
standalone server*, with a reverse-proxy cache sitting in front of it. 
(eg. Varnish http://varnish-cache.org/)


[* http://search.cpan.org/dist/Catalyst-Engine-HTTP-Prefork/ ]

I've never been satisfied by either of the FastCGI implementations 
available to Apache. I do like the one for Lighttpd, but some other 
aspects of lighty can be annoying.


___
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] FastCGI deployment - slow to complete request

2010-02-15 Thread Gervase Markham
On 15/02/10 04:59, Steve Rippl wrote:
 Now this works, it's serving up the application, but each request is
 really slow to complete!  The obvious effect of this is that a page with
 JavaScript waiting for a complete page before it does it's thing looks
 dreadful for a while, the html has arrived but the browser is still
 spinning, then eventually the page completes and the JS runs.  

I think there's a strong chance you have the same problem that I have
with my production app, and have not yet had a chance to investigate. I
am using the built-in server for development, and FastCGI in production.

A good Mozilla hacker who is using my software tracked it down to the
following: Catalyst or Apache is sending the wrong Content-Length and so
the browser is spinning waiting for the rest of the data. It is sending
the Content-Length of the uncompressed data, but then the server is
applying a Content-Encoding of gzip.

Now, calculating Content-Length correctly would require doing the
compression before sending any headers, which would use a lot of memory
if the entity body was large. However, my understanding (RFC 2616
section 4.4) is that you either have to do that or use chunked
Transfer-Encoding.

I solved the problem by disabling mod_deflate. I don't know what a
proper fix would be.

Gerv

___
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] FastCGI deployment - slow to complete request

2010-02-15 Thread Steve Rippl

Andrew Rodland wrote:
Fix: Use a current snapshot version of mod_fastcgi. Source tarballs can be 
found in http://www.fastcgi.com/dist/ or if you'd like a deb, I've built 
http://cleverdomain.org/libapache2-mod-fastcgi_2.4.6.99~snap20081109_i386.deb 
(for Debian 5.0 i386).


Andrew
  

Thanks for providing this, but when I install it and restart apache I get

wsdsis:~# /etc/init.d/apache2 start
Starting web server: apache2apache2: Syntax error on line 185 of 
/etc/apache2/apache2.conf: Syntax error on line 1 of 
/etc/apache2/mods-enabled/fastcgi.load: Cannot load 
/usr/lib/apache2/modules/mod_fastcgi.so into server: 
/usr/lib/apache2/modules/mod_fastcgi.so: wrong ELF class: ELFCLASS64

failed!

and I'm on a 32bit kernel (in case that's what ELFCLASS64 is referring to?)

wsdsis:~# uname -m
i686

Would using the source version solve this or is something else going on?

For now I've disabled mod_deflate and that helps, I presume if I wasn't 
using DEFLATE anywhere I'm not loosing anything here?


Anyway, thanks for the help!

Steve

--
Steve Rippl
Technology Director
Woodland Public Schools
360 225 9451 x326


___
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] FastCGI deployment - slow to complete request

2010-02-15 Thread Tomas Doran

Steve Rippl wrote:

Andrew Rodland wrote:
Fix: Use a current snapshot version of mod_fastcgi. Source tarballs 
can be found in http://www.fastcgi.com/dist/ or if you'd like a deb, 
I've built 
http://cleverdomain.org/libapache2-mod-fastcgi_2.4.6.99~snap20081109_i386.deb 
(for Debian 5.0 i386).


Andrew
  

Thanks for providing this, but when I install it and restart apache I get

wsdsis:~# /etc/init.d/apache2 start
Starting web server: apache2apache2: Syntax error on line 185 of 
/etc/apache2/apache2.conf: Syntax error on line 1 of 
/etc/apache2/mods-enabled/fastcgi.load: Cannot load 
/usr/lib/apache2/modules/mod_fastcgi.so into server: 
/usr/lib/apache2/modules/mod_fastcgi.so: wrong ELF class: ELFCLASS64

failed!

and I'm on a 32bit kernel (in case that's what ELFCLASS64 is referring to?)

wsdsis:~# uname -m
i686

Would using the source version solve this or is something else going on?


Your machine / packaging system etc is seriously broken in some way, or 
you're trying to use a .deb built for a system you're not running.


So yes - compiling the source version yourself would imply that you 
compile it on the right machine, ergo it's more likely to work. :)


Personally, I'd just remove mod_deflate, use the mod_fastcgi in your 
distribution (which will then work fine), and add 
Catalyst::Plugin::Compress..


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] FastCGI deployment - slow to complete request

2010-02-15 Thread Andrew Rodland
On Monday 15 February 2010 10:47:45 am Steve Rippl wrote:
 Andrew Rodland wrote:
  Fix: Use a current snapshot version of mod_fastcgi. Source tarballs can
  be found in http://www.fastcgi.com/dist/ or if you'd like a deb, I've
  built
  http://cleverdomain.org/libapache2-mod-fastcgi_2.4.6.99~snap20081109_i38
  6.deb (for Debian 5.0 i386).
  
  Andrew
 
 Thanks for providing this, but when I install it and restart apache I get
 
 wsdsis:~# /etc/init.d/apache2 start
 Starting web server: apache2apache2: Syntax error on line 185 of
 /etc/apache2/apache2.conf: Syntax error on line 1 of
 /etc/apache2/mods-enabled/fastcgi.load: Cannot load
 /usr/lib/apache2/modules/mod_fastcgi.so into server:
 /usr/lib/apache2/modules/mod_fastcgi.so: wrong ELF class: ELFCLASS64
  failed!
 
 and I'm on a 32bit kernel (in case that's what ELFCLASS64 is referring to?)

Apologies, somehow I had uploaded a bad build -- it says i386 in the filename 
but it was actually amd64. Fixed one is uploaded (at the same address, so just 
pull it again and install it again).

Andrew

___
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/


[Catalyst] Multiple chaining to same action ...

2010-02-15 Thread Kiffin Gish
In my application, users are allowed to edit only their own settings
like this:

/account/id/client/settings/edit

| /role/*/settings/edit | /auth (0)   |
|   | - /role/base (1)   |
|   | - /role/settings/crud/base (0) |
|   | = /role/settings/crud/edit |

# Controller::Role
sub base : Chained('/auth') PathPart('role') CaptureArgs(1) {
my ( $self, $c, $id ) = @_;

# Get the user if possible.
my $user = $c-model('DB::User')-find($id);

# Make sure that the user is indeed this user.
$c-detach('/error_403') unless $c-user-id == $id;

# Save the user in the stash.
$c-stash( user = $user );
}

# Controller::Role::Settings::CRUD
sub base : Chained('/role/base') PathPart('settings') CaptureArgs(0)
{...}

sub edit : Chained('base') PathPart('edit') Args(0) {
my ( $self, $c ) = @_;
my $user = $c-stash-{user};

}

Now the hard part.

I also want to allow the admin to be able to edit all user settings in
exactly the same way, like this:

/account/id/admin/user/id/settings/edit

# Controller::Role::Admin::User
sub base : Chained('/role/admin/base') PathPart('user') CaptureArgs(0)
{...}

sub id : Chained('base') PathPart('') CaptureArgs(1) {
my ( $self, $c, $id ) = @_;

# Get the user if possible.
my $user = $c-model('DB::User')-find($id);

# Does this user exist?
$c-detach('/error_404') unless ($user);

# Save the user in the stash.
$c-stash( user = $user );
}

sub edit : Chained('base') PathPart('settings') Args(0) {...}

As you can see there's alot of repetition going on and there must be a
more elegant way to handle this.

How does one go about chaining the same action from multiple points.
Does this make sense and if so is it possible?

Thanks alot in advance,
Kiffin


-- 
Kiffin Gish kiffin.g...@planet.nl
Gouda, The Netherlands



___
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] Multiple chaining to same action ...

2010-02-15 Thread J. Shirley
On Mon, Feb 15, 2010 at 12:38 PM, Kiffin Gish kiffin.g...@planet.nl wrote:
 In my application, users are allowed to edit only their own settings
 like this:

 /account/id/client/settings/edit

 | /role/*/settings/edit | /auth (0)                       |
 |                       | - /role/base (1)               |
 |                       | - /role/settings/crud/base (0) |
 |                       | = /role/settings/crud/edit     |

 # Controller::Role
 sub base : Chained('/auth') PathPart('role') CaptureArgs(1) {
    my ( $self, $c, $id ) = @_;

    # Get the user if possible.
    my $user = $c-model('DB::User')-find($id);

    # Make sure that the user is indeed this user.
    $c-detach('/error_403') unless $c-user-id == $id;

    # Save the user in the stash.
    $c-stash( user = $user );
 }

 # Controller::Role::Settings::CRUD
 sub base : Chained('/role/base') PathPart('settings') CaptureArgs(0)
 {...}

 sub edit : Chained('base') PathPart('edit') Args(0) {
    my ( $self, $c ) = @_;
    my $user = $c-stash-{user};
    
 }

 Now the hard part.

 I also want to allow the admin to be able to edit all user settings in
 exactly the same way, like this:

 /account/id/admin/user/id/settings/edit

 # Controller::Role::Admin::User
 sub base : Chained('/role/admin/base') PathPart('user') CaptureArgs(0)
 {...}

 sub id : Chained('base') PathPart('') CaptureArgs(1) {
    my ( $self, $c, $id ) = @_;

    # Get the user if possible.
    my $user = $c-model('DB::User')-find($id);

    # Does this user exist?
    $c-detach('/error_404') unless ($user);

    # Save the user in the stash.
    $c-stash( user = $user );
 }

 sub edit : Chained('base') PathPart('settings') Args(0) {...}

 As you can see there's alot of repetition going on and there must be a
 more elegant way to handle this.

 How does one go about chaining the same action from multiple points.
 Does this make sense and if so is it possible?

 Thanks alot in advance,
 Kiffin



Simply use roles or a base class.  Just go with a standard base class
if that's what you are more familiar with.

With Chained, this becomes very simple because you only have to define
the individual setup methods (sub base : Chained(...)) and go from
there.

You can look at Catalyst::Controller::DBIC::API for a CPAN'd example.

-J

___
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] Multiple chaining to same action ...

2010-02-15 Thread Kiffin Gish
I just happened to find the answer here:

http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg07604.html

t0m++ for (1..10)

On Mon, 2010-02-15 at 21:38 +0100, Kiffin Gish wrote:
 In my application, users are allowed to edit only their own settings
 like this:
 
 /account/id/client/settings/edit
 
 | /role/*/settings/edit | /auth (0)   |
 |   | - /role/base (1)   |
 |   | - /role/settings/crud/base (0) |
 |   | = /role/settings/crud/edit |
 
 # Controller::Role
 sub base : Chained('/auth') PathPart('role') CaptureArgs(1) {
 my ( $self, $c, $id ) = @_;
 
 # Get the user if possible.
 my $user = $c-model('DB::User')-find($id);
 
 # Make sure that the user is indeed this user.
 $c-detach('/error_403') unless $c-user-id == $id;
 
 # Save the user in the stash.
 $c-stash( user = $user );
 }
 
 # Controller::Role::Settings::CRUD
 sub base : Chained('/role/base') PathPart('settings') CaptureArgs(0)
 {...}
 
 sub edit : Chained('base') PathPart('edit') Args(0) {
 my ( $self, $c ) = @_;
 my $user = $c-stash-{user};
 
 }
 
 Now the hard part.
 
 I also want to allow the admin to be able to edit all user settings in
 exactly the same way, like this:
 
 /account/id/admin/user/id/settings/edit
 
 # Controller::Role::Admin::User
 sub base : Chained('/role/admin/base') PathPart('user') CaptureArgs(0)
 {...}
 
 sub id : Chained('base') PathPart('') CaptureArgs(1) {
 my ( $self, $c, $id ) = @_;
 
 # Get the user if possible.
 my $user = $c-model('DB::User')-find($id);
 
 # Does this user exist?
 $c-detach('/error_404') unless ($user);
 
 # Save the user in the stash.
 $c-stash( user = $user );
 }
 
 sub edit : Chained('base') PathPart('settings') Args(0) {...}
 
 As you can see there's alot of repetition going on and there must be a
 more elegant way to handle this.
 
 How does one go about chaining the same action from multiple points.
 Does this make sense and if so is it possible?
 
 Thanks alot in advance,
 Kiffin
 
 


-- 
Kiffin Gish kiffin.g...@planet.nl
Gouda, The Netherlands



___
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] Multiple chaining to same action ...

2010-02-15 Thread Octavian Rasnita

From: Kiffin Gish kiffin.g...@planet.nl

In my application, users are allowed to edit only their own settings
like this:

/account/id/client/settings/edit

| /role/*/settings/edit | /auth (0)   |
|   | - /role/base (1)   |
|   | - /role/settings/crud/base (0) |
|   | = /role/settings/crud/edit |

# Controller::Role
sub base : Chained('/auth') PathPart('role') CaptureArgs(1) {
   my ( $self, $c, $id ) = @_;

   # Get the user if possible.
   my $user = $c-model('DB::User')-find($id);

   # Make sure that the user is indeed this user.
   $c-detach('/error_403') unless $c-user-id == $id;

   # Save the user in the stash.
   $c-stash( user = $user );
}


Why do you need this subroutine?
It should be reached only by the authenticated users, and if somebody 
reached here, you can just get his/her user id from $c-user-get('id') and 
you can get this information in the other subroutines also.


Octavian


___
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] FastCGI deployment - slow to complete request

2010-02-15 Thread Steve Rippl

Andrew Rodland wrote:
Apologies, somehow I had uploaded a bad build -- it says i386 in the filename 
but it was actually amd64. Fixed one is uploaded (at the same address, so just 
pull it again and install it again).


Andrew
  

That worked - thanks!

--
Steve Rippl
Technology Director
Woodland Public Schools
360 225 9451 x326


___
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/