Having nearly finished my first C::A module (it performs authentication), I'm not sure what the best way is to chain to the next C::A module. I want multiple/separate C::A modules to be able to reuse the authentication module. I haven't been able to find many examples of this type and would appreciate suggestions from other C::A users. My current thought is to create the initial script to look like the following untested code:
#!/usr/local/bin/perl use MyAuth; ## has strict, warnings, etc. my $webapp = MyAuth->new( PARAMS => { 'Next_CGI' => "some_url_without_query_string" } ); $webapp->run();
Then teardown() within MyAuth.pm would look like the following:
sub teardown() my $self = shift; my $output = ''; ## probably best to store the following in a file my %Allowed_Scripts = ( 'https://site/pathto/ca.script1.cgi' => 1, 'https://site/pathto/ca.script2.cgi' => 1, ); ## usual teardown stuff my $url = $self->param('Next_CGI'); if ( exists($Allowed_Scripts{$url}) ) { if (authorized) { my $query_string = "?whatever"; $self->header_type('redirect'); $self->header_props( -url => "$url$query_string" ); } else { ## use template for unauthorized user message } } else { ## use template for unauthorized script message } return $output; }
Is this a reasonable way to handle an application using multiple CAs? Will it cause memory problems (bloat)? Thanks.

In reply to Structuring multiple CGI::Application modules by Anonymous Monk

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.