[cgiapp] Re: CAP::Auth: more details

fREW Schmidt frioux at gmail.com
Wed Mar 18 02:04:37 EDT 2009


On Wed, Mar 18, 2009 at 12:32 AM, fREW Schmidt <frioux at gmail.com> wrote:

> Ok, so I had thought that CA::Dispatch was breaking CAP::Auth but
> apparently I was wrong.  Here is most of my controller:
>
> package ACD::Controller;
> use strict;
> use warnings;
> use base qw/CGI::Application/;
> use feature ':5.10';
> use ACD::Model;
> use CGI::Application::Plugin::AutoRunmode;
> use CGI::Application::Plugin::Authentication;
> use CGI::Application::Plugin::JSON ':all';
>
> sub foo : Runmode {
>     my $self = shift;
>     return 'foo';
> }
>
> __PACKAGE__->authen->config(
>     DRIVER => [ 'Generic', { user1 => '123' } ],
>     LOGIN_RUNMODE => 'login',
> );
>
> __PACKAGE__->authen->protected_runmodes(qr/^(?!main)/);
>
> sub login : Runmode {
>     my $self = shift;
>     $self->header_add( -status => '500 unauthenticated' );
>     return $self->json_body({ success => 'false', reason =>
> 'unauthenticated'});
> }
>
> and then the app script:
>
> #!/usr/bin/perl
> use strict;
> use ACD::Controller;
> my $app = ACD::Controller->new();
>
> $app->run();
>
> And if I go to the url: http://localhost:8080/devcgi/test.plx?rm=foo
>
> I get a 500 and the following is printed to the log:
>
> [Wed Mar 18 00:30:01 2009] [error] No such run mode 'login' at (eval 9)
> line 9\n
>
> Does anyone see what I am doing wrong?  It all looks really basic to me...
>

Solved!!!

You can't use AutoRunMode in tandem with CAP::Auth.  Well, you can, but the
LOGIN_RUNMODE must be defined the idiomatic way in setup vs tagging the
function with Runmode.

Hurray!


-- 
fREW Schmidt
http://blog.afoolishmanifesto.com


More information about the cgiapp mailing list