I just recently started using CGI:App and so far, really like what I see. It is well documented, and handles most of the low-level CGI stuff that has made web programming so tedious for me (without having to learn Moose!). Most of my web app is working (I use Template Toolkit for the forms), and today I decided to add User Authentication to protect some of the runmodes. That's when the trouble began ...

I don't have any fancy needs regarding Authent. Just a simple user=>password hash will work fine. So I loaded the Generic driver. I wrote my own HTML form for the login, and call it from a "login_user()" runmode. But I can't figure out HOW to actually DO the Authentication. I try calling "verify_credentials()", but it can't find it.

I know this must be very simple and basic, but I have combed through the docs and can't find a simple explanation.

Here is my config:

package ePlan::AppBase; use strict; use warnings; use base qw(CGI::Application); use CGI::Application::Plugin::ConfigAuto (qw/cfg cfg_file/); use CGI::Application::Plugin::DBIC::Schema (qw/dbic_config schema resu +ltset rs/); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Authentication; use CGI::Application::Plugin::Authentication::Driver::Generic; my %users = ( ray => '123', jeff => '456', ); __PACKAGE__->authen->config( DRIVER => [ 'Generic', \%users ], STORE => 'Session', POST_LOGIN_URL => 'http://cgiapp.site/dash.pl', LOGIN_RUNMODE => 'login_user', LOGOUT_RUNMODE => 'logout_user', CREDENTIALS => ['authen_username','authen_password'], ); sub setup { my $self = shift; $self->start_mode('owner'); $self->run_modes('owner' => 'lookup_owner', 'user' => 'login_user', ); } sub login_user { ...... my $q = $self->query(); my $user = $q->param('authen_username'); my $pswd = $q->param('authen_password'); (now, what??) my @crednames=@{$self->authen->credentials}; # this fails --> my $go_nogo = $authen->verify_credentials();

Anyway, now whenever I get to an "authen->protected_runmode", it doesn't know I've been Authenticated, and pops up the form.

Thanks!


In reply to cgi::application authentication by neptuneray

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.