Or try this application which implements authentication example with perl catalyst from scratch. <br>You can test it, its just a couple steps.. hope it helps. <br>i wrote it sometime ago but i have not tested yet.<br><br>1. create a database<br>

        2. create tables:<br>
        <br>
        CREATE TABLE users<br>
        (<br>
          id serial NOT NULL,<br>
          nome text,<br>
          sobrenome text,<br>
          is_deleted integer DEFAULT 0,<br>
          endereco text,<br>
          created date DEFAULT now(),<br>
          username text,<br>
          &quot;password&quot; text,<br>
          telefone text,<br>
          email character varying(255),<br>
          CONSTRAINT users_pkey PRIMARY KEY (id)<br>
        );<br>
        <br>
        CREATE TABLE roles<br>
        (<br>
          id integer NOT NULL,<br>
          &quot;role&quot; text,<br>
          CONSTRAINT role_pkey PRIMARY KEY (id)<br>
        );<br>
        <br>
        <br>
        CREATE TABLE users_to_roles<br>
        (<br>
          user_id integer NOT NULL,<br>
          role_id integer NOT NULL,<br>
          CONSTRAINT users_to_roles_pkey PRIMARY KEY (user_id, role_id),<br>
          CONSTRAINT users_to_roles_role_id_fkey FOREIGN KEY (role_id)<br>
              REFERENCES roles (id) MATCH SIMPLE<br>
              ON UPDATE NO ACTION ON DELETE NO ACTION,<br>
          CONSTRAINT users_to_roles_user_id_fkey FOREIGN KEY (user_id)<br>
              REFERENCES users (id) MATCH SIMPLE<br>
              ON UPDATE NO ACTION ON DELETE NO ACTION<br>
        );<br>
        <br>
        2.1 add some data onto db:<br>
        <br>
        insert into roles (id, role) values (1, &#39;admin&#39;);<br>
        insert into roles (id, role) values (2, &#39;gerente&#39;);<br>
        insert into roles (id, role) values (3, &#39;banidos&#39;);<br>
        insert into roles (id, role) values (4, &#39;funcionario&#39;);<br>
        insert into roles (id, role) values (5, &#39;secretaria&#39;);<br>
        <br>
        insert into users (nome, sobrenome, is_deleted, endereco, username, 
password, email) values (&#39;joe&#39;, &#39;silva&#39;, &#39;0&#39;, &#39;-&#39;, &#39;joe&#39;, &#39;silva&#39;, 
&#39;<a href="mailto:joe@silva.net" target="_blank">joe@silva.net</a>&#39;);<br>
        insert into users (nome, sobrenome, is_deleted, endereco, username, 
password, email) values (&#39;maria&#39;, &#39;gomes&#39;, &#39;0&#39;, &#39;-&#39;, &#39;maria&#39;, &#39;gomes&#39;, 
&#39;<a href="mailto:mariagomes@hotmail.com" target="_blank">mariagomes@hotmail.com</a>&#39;);<br>
        insert into users (nome, sobrenome, is_deleted, endereco, username, 
password, email) values (&#39;admin&#39;, &#39;admin&#39;, &#39;0&#39;, &#39;-&#39;, &#39;admin&#39;, &#39;admin&#39;, 
&#39;<a href="mailto:admin@admins.com" target="_blank">admin@admins.com</a>&#39;);<br>
        <br>
        <br>
        insert into users_to_roles ( role_id, user_id ) values (1, 3);<br>
        insert into users_to_roles ( role_id, user_id ) values (2, 1);<br>
        insert into users_to_roles ( role_id, user_id ) values (2, 2);<br>
        <br>
        3. create a  default catalyst app<br>
        <br>
        <a href="http://catalyst.pl/" target="_blank">catalyst.pl</a> Example::Catalyst::Auth<br>
        cd Example-Catalyst-Auth/<br>
        <br>
        4. create TT view<br>
        <br>
        script/<a href="http://example_catalyst_auth_create.pl/" target="_blank">example_catalyst_auth_create.pl</a> view TT<br>
        <br>
        5. open TT.pm file to edit<br>
        <br>
        vim lib/Example/Catalyst/Auth/View/TT.pm<br>
        <br>
        6. insert the following into your TT.pm<br>
        <br>
        package Example::Catalyst::Auth::View::TT;<br>
        use warnings;<br>
        use strict;<br>
        use base &#39;Catalyst::View::TT&#39;;<br>
        <br>
        __PACKAGE__-&gt;config(<br>
            # Set to 1 for detailed timer stats in your HTML as comments<br>
            TIMER   =&gt; 0,<br>
            # This is your wrapper template located in the &#39;root/src&#39;<br>
            WRAPPER =&gt; &#39;wrapper.tt2&#39;,<br>
            # Change default TT extension<br>
            TEMPLATE_EXTENSION =&gt; &#39;.tt2&#39;,<br>
            # Set the location for TT files<br>
            INCLUDE_PATH =&gt; [<br>
                    Example::Catalyst::Auth-&gt;path_to( &#39;root&#39;,  ),<br>
                ],<br>
        );<br>
        <br>
        __PACKAGE__-&gt;meta-&gt;make_immutable;<br>
        <br>
        1;<br>
        <br>
        <br>
        7. now open the main ap config<br>
        <br>
        vim lib/Example/Catalyst/Auth.pm<br>
        <br>
        8. and insert inside your __PACKAGE__-&gt;config() :<br>
        <br>
        default_view =&gt; &#39;TT&#39;,<br>
        ENCODING =&gt; &#39;utf-8&#39;,<br>
        <br>
        8.1 and also declare these inside your use Catalyst qw//:<br>
        <br>
            Unicode<br>
        <br>
            StackTrace<br>
            <span class="il">Authentication</span><br>
            Authorization::Roles<br>
        <br>
        8.2 and insert the Auth configuration also.. on that same file:<br>
        <br>
        __PACKAGE__-&gt;config-&gt;{&#39;Plugin::<span class="il">Authentication</span>&#39;} = {<br>
                default =&gt; {<br>
                    class           =&gt; &#39;SimpleDB&#39;,<br>
        #           user_model      =&gt; &#39;DBICSchemamodel::Users&#39;,<br>
                    user_model      =&gt; &#39;DBICSchemamodel::User&#39;,<br>
                    password_type   =&gt; &#39;clear&#39;,<br>
                    user_role_user_field =&gt; &#39;user_id&#39;,<br>
                    user_role_role_field =&gt; &#39;role_id&#39;,<br>
                },<br>
            };<br>
        <br>
        8.3 and also insert the Store config<br>
        <br>
        __PACKAGE__-&gt;config-&gt;{&#39;Plugin::Cache&#39;}{backend} = { #DEFAULT backend<br>
          store =&gt; &quot;FastMmap&quot;,<br>
            class =&gt; &quot;Cache::FastMmap&quot;,<br>
              storage =&gt; &quot;/tmp/cache&quot;,<br>
                expires =&gt; 3600,<br>
                  };<br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        8. create the wrapper:<br>
        <br>
        vim root/wrapper.tt2<br>
        <br>
        9. and insert this content:<br>
        <br>
        &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot;<br>
            &quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd</a>&quot;&gt;<br>
        &lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>&quot;&gt;<br>
        &lt;head&gt;<br>
        &lt;/head&gt;<br>
        &lt;body&gt;<br>
        [%content%]<br>
        &lt;/body&gt;<br>
        &lt;/html&gt;<br>
        <br>
        10. now lets modify our Root controller.<br>
        We should create one index page (And test the view we setup is working)<br>
        We should create one hidden page, which will show only when logged in.<br>
        <br>
        vim lib/Example/Catalyst/Auth/Controller/Root.pm<br>
        <br>
        10.1 declare use HTML::FormHandler<br>
        <br>
        use HTML::FormHandler;<br>
        <br>
        11. delete index action and add the following:<br>
        <br>
        sub auto :Private {<br>
            my ($self, $c) =@_;<br>
        <br>
            if ( $c-&gt;action eq $c-&gt;controller(&#39;root&#39;)-&gt;action_for(&#39;login&#39;)<br>
                || $c-&gt;action eq $c-&gt;controller(&#39;root&#39;)-&gt;action_for(&#39;index&#39;)<br>
                ) {<br>
                return 1;<br>
            }<br>
        <br>
            # If a user doesn&#39;t exist, force login<br>
            if (<br>
                !$c-&gt;user_exists<br>
                or (<br>
                    (<br>
                            !$c-&gt;check_user_roles(&#39;admin&#39;)<br>
                        and !$c-&gt;check_user_roles(&#39;gerente&#39;)<br>
                        and !$c-&gt;check_user_roles(&#39;funcionario&#39;)<br>
                    )<br>
                )<br>
              )<br>
            {<br>
                # Redirect the user to the login page<br>
                $c-&gt;forward(&#39;login&#39;);<br>
                  # Return 0 to cancel &#39;post-auto&#39; processing and prevent use of application<br>
                    return 0;<br>
                  }<br>
        <br>
            # User found, so return 1 to continue with processing after this &#39;auto&#39;<br>
            return 1;<br>
            }<br>
        <br>
        sub index :Path :Args(0) {<br>
            my ( $self, $c ) = @_;<br>
            $c-&gt;stash(template =&gt; \&#39;Welcome please &lt;a 
href=&quot;/login&quot;&gt;login&lt;/a&gt;&#39;); #or i could use: template =&gt; 
&#39;index.tt2&#39;, and create that file inside myapp/root<br>
        }<br>
        <br>
        sub hidden_page :Path(&#39;/hidden_page&#39;) :Args(0) {<br>
            my ( $self, $c ) = @_;<br>
            $c-&gt;stash( template =&gt; \&#39;CONTEÚDO ESCONDIDO&#39; );<br>
            }<br>
        <br>
        sub login : Path(&#39;/login&#39;) : Args(0) {<br>
            my ( $self, $c ) = @_;<br>
        <br>
                my $form = HTML::FormHandler-&gt;new({<br>
                    field_list =&gt; [<br>
                      username =&gt; {<br>
                          type =&gt; &#39;Text&#39;,<br>
                          label =&gt; &#39;Login&#39;,<br>
                          required =&gt; 1,<br>
                          required_message =&gt; &#39;Campo Requerido&#39;,<br>
                          },<br>
                      password =&gt; {<br>
                          type =&gt; &#39;Password&#39;,<br>
                          label =&gt; &#39;Password&#39;,<br>
                          required =&gt; 1,<br>
                          required_message =&gt; &#39;Campo Requerido&#39;,<br>
                          },<br>
                      submit =&gt; {<br>
                          type =&gt; &#39;Submit&#39;,<br>
                          value =&gt; &#39;Login&#39;,<br>
                          },<br>
                      ],<br>
                    });<br>
                $c-&gt;stash( template =&gt; \$form-&gt;render);<br>
        <br>
            # Get the username and password from form<br>
            my $username = $c-&gt;request-&gt;params-&gt;{username} || undef;<br>
            my $password = $c-&gt;request-&gt;params-&gt;{password} || undef;<br>
        <br>
            # If the username and password values were found in form<br>
            if ( defined($username) &amp;&amp; defined($password) ) {<br>
        <br>
                # Attempt to log the user in<br>
                if (<br>
                    $c-&gt;authenticate(<br>
                        {<br>
                            username =&gt; $username,<br>
                            password =&gt; $password<br>
                        }<br>
                    )<br>
                  )<br>
                {<br>
        <br>
                    $c-&gt;forward(&#39;hidden_page&#39;);<br>
        <br>
                    return;<br>
                }<br>
                else {<br>
        <br>
                    # Set an error message<br>
                    $c-&gt;stash-&gt;{error_msg} =<br>
         &quot;Login desconhecido. Verifique seu login e senha e tente novamente. &quot;;<br>
                }<br>
            }<br>
        <br>
            # If either of above don&#39;t work out, send to the login page<br>
            $c-&gt;detach(&#39;index&#39;) if ($c-&gt;user_exists);<br>
        }<br>
        <br>
        <br>
        <br>
        <br>
        sub logout : Path(&#39;/logout&#39;) : Args(0) {<br>
            my ( $self, $c ) = @_;<br>
        <br>
            # Clear the user&#39;s state<br>
            $c-&gt;logout;<br>
        <br>
            # Send the user to the starting point<br>
            $c-&gt;response-&gt;redirect( $c-&gt;uri_for(&#39;/&#39;) );<br>
        }<br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        12. now create your schema:<br>
        <br>
        script/<a href="http://example_catalyst_auth_create.pl/" target="_blank">example_catalyst_auth_create.pl</a> model DBICSchemamodel 
DBIC::Schema Example::Catalyst::Auth::DBSchema create=static 
dbi:Pg:dbname=test_auth dblogin password<br>
        <br>
        13. add many_to_many relationships to model User<br>
        <br>
        vim lib/Example/Catalyst/Auth/DBSchema/Result/User.pm<br>
        <br>
        14. insert before make_immutable or 1<br>
        <br>
        __PACKAGE__-&gt;many_to_many(&#39;roles&#39;, &#39;users_to_roles&#39; =&gt; &#39;role&#39;);<br>
        <br>
        15. add many_to_many relationships to model Role<br>
        <br>
        vim lib/Example/Catalyst/Auth/DBSchema/Result/Role.pm<br>
        <br>
        14. insert before make_immutable or 1<br>
        <br>
        __PACKAGE__-&gt;many_to_many(&#39;users&#39;, &#39;users_to_roles&#39; =&gt; &#39;user&#39;);<br><br><br><br><br><br><br><br>att,<br>Hernan<br><br><br><div class="gmail_quote">On Tue, Jan 11, 2011 at 3:18 PM, Mike Raynham <span dir="ltr">&lt;<a href="mailto:catalyst@mikeraynham.co.uk">catalyst@mikeraynham.co.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On 11/01/11 16:09, Ben Lavery wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Dear all,<br>
<br>
After installing Catalyst on an OpenIndiana virtual machine, I&#39;ve been working through the Definitive Guide to Catalyst for the last few weeks and have been impressed with how smoothly most of it has gone.<br>
<br>
I have, however, become unstuck at Chapter 6.  The book explains how to create an application that uses some simple CRUD with user and role data, and uses authentication to prevent users updating other user&#39;s data.<br>

I have a working application that allows one to create and read user data, but I can&#39;t figure out how to apply the authentication.  The book says:<br>
&quot;When using the Authentication plug-in, as we showed in Chapter 3...&quot;<br>
<br>
I&#39;ve gone back to Chapter 3 and followed the steps, but I&#39;m not sure where I am supposed to put the &quot;$c-&gt;authenticate&quot;.<br>
If I place it in DBAuthTest::Controller::Root in a subroutine called &quot;auto&quot;, every page on the site needs me to log in, but no matter what I put in the username and password fields it says that the data is invalid.<br>

As such I have no idea where I have gone wrong, after Googling I can&#39;t find similar problems, or people who have had similar problems or implemented a similar system in a similar way.<br>
I have looked at the source code provided on the publisher&#39;s site, but it doesn&#39;t include code for the whole chapter, and indeed seems to stop given code a page or two previous to where I am now...<br>
<br>
I have uploaded a copy of my application to <a href="http://hashbang0.com/personal/DBAuthTest.tar.bz2" target="_blank">http://hashbang0.com/personal/DBAuthTest.tar.bz2</a> (~46K) which I hope help demonstrate where I am currently.<br>

<br>
Many thanks for your time, I appreciate any help you can give,<br>
<br>
Ben Lavery<br>
</blockquote>
<br></div>
The authentication section of the online tutorial, as suggested by Hernan Lopes, is definitely worth reading.  However, what follows may get you started.  The following approach doesn&#39;t deal with roles or permission levels - it just tests if a user is logged in or not.<br>

<br>
The following code is just to give you an idea of how it would work. I&#39;ve just grabbed bits of code from various places and stuck them together, so please don&#39;t expect to be able to just copy and paste it into your code :-)<br>

<br>
In your secure controller actions, you need to check if a user is logged in:<br>
<br>
In DBAuthTest::Controller::AuthUsers...<br>
<br>
###<br>
<br>
sub add : Chained(&#39;base&#39;): PathPart(&#39;add&#39;): Args(0) {<br>
    my ($self, $c) = @_;<br>
<br>
    # Detach to the no_user action if a user is not logged in.<br>
    $c-&gt;detach( &#39;/no_user&#39; ) unless $c-&gt;user_exists;<br>
<br>
    # Do secure stuff here...<br>
}<br>
<br>
###<br>
<br>
Then in DBAuthTest::Controller::Root...<br>
<br>
###<br>
<br>
sub no_user :Chained(&#39;/&#39;) :PathPart :Args(0) {<br>
    my ($self, $c) = @_;<br>
        <br>
    # The user is not logged in.<br>
<br>
    # Remember the failed action so that we can redirect to it<br>
    # after login.<br>
    $c-&gt;session-&gt;{action_private_path} = $c-&gt;action-&gt;private_path;<br>
<br>
    # Put a message in the flash so that we can display it on the<br>
    # login page.<br>
    $c-&gt;flash(<br>
        error_msg =&gt;<br>
            &#39;To perform the requested action, you must be logged in.&#39;<br>
    );<br>
<br>
    # Redirect to a login page.<br>
    $c-&gt;response-&gt;redirect(<br>
        $c-&gt;uri_for_action( &#39;/login&#39; )<br>
    );<br>
}<br>
<br>
###<br>
<br>
You then need a suitable controller to handle authentication:<br>
<br>
###<br>
<br>
package DBAuthTest::Controller::Login;<br>
<br>
sub login :Chained(&#39;base&#39;) :PathPart(&#39;login&#39;) :Args(0) {<br>
    my ( $self, $c ) = @_;<br>
<br>
    # Get username and password from somewhere...<br>
    my $username = $c-&gt;request-&gt;params-&gt;{username};<br>
    my $password = $c-&gt;request-&gt;params-&gt;{password};<br>
<br>
    # Do something here if username and password have<br>
    # not been supplied.<br>
        <br>
    unless ( $c-&gt;authenticate( {<br>
        username =&gt; $username,<br>
        password =&gt; $password<br>
    } ) ) {<br>
<br>
        # Stash an error message.<br>
        $c-&gt;stash(<br>
            error_msg =&gt; &#39;Incorrect username, password, or both&#39;,<br>
        );<br>
<br>
        # Handle invalid credentials.<br>
<br>
        return;<br>
    }<br>
<br>
    if( $c-&gt;session-&gt;{action_private_path} ) {<br>
<br>
        # Redirect to the previously unauthorised action.<br>
        $c-&gt;response-&gt;redirect(<br>
            $c-&gt;uri_for_action( $c-&gt;session-&gt;{action_private_path} )<br>
        );<br>
<br>
        delete $c-&gt;session-&gt;{action_private_path};<br>
<br>
    } else {<br>
<br>
        # Redirect to a default page.<br>
        $c-&gt;response-&gt;redirect( $c-&gt;uri_for_action(&#39;/index&#39;) );<br>
<br>
    }<br>
}<br>
<br>
###<div><div></div><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</div></div></blockquote></div><br>