perrin, I am forced to bow to your mastery here... with appreciation.

I haven't finished all the bits that I need, but it's definitely turning out to be significantly easier to do this as you suggested than I had originally feared. And, yes, this is mod_perl2, so I can do an output filter.

For anyone else who cares, relevant code (and otherwise) fragments: (Names have been changed to protect the guilty...)

httpd.conf

PerlModule Foo::FooAuth PerlModule Foo::FooFilter <Location /foo/cgi-bin/foo.cgi> PerlOutputFilterHandler Foo::FooFilter PerlAuthenHandler Foo::FooAuth require valid-user </Location>
Foo::FooAuth
package Foo::FooAuth; use strict; use Apache2::Const qw(:common); use Foo::AuthAux; # Provides whoami - uses a cookie set elsewhere sub handler { my $r = shift; my $user = whoami($r); unless ($user) { $r->note_basic_auth_failure; return AUTH_REQUIRED; } $r->user($user); $r->subprocess_env(FOO => "bar+$user"); return OK; } 1;
Foo::FooFilter
package Foo::FooFilter; use strict; use Apache2::Filter; use Apache2::Const qw(:common); use Apache2::Request; use HTML::Template; use Foo::Config; # Provides $TMPL_PATH below use Foo::Auth; use Foo::AuthAux; # Provides whoami below my $BUFF_LEN = 8192; sub handler { my $f = shift; my $r = $f->r; my $fullbuf; while ($f->read(my $buf, $BUFF_LEN)) { $fullbuf .= $buf; } my $tmpl = HTML::Template->new(scalarref => \$fullbuf, path => $TMPL_PATH, die_on_bad_params => 0, ); my $user = whoami($r); my $userinfo = ISPNET::Auth::userinfo($user); $tmpl->param(_user => $user, _logo => $userinfo->{logo}, _logo_alt => $userinfo->{logo_alt}, # Set _home (would be $ENV{SCRIPT_NAME})... ); $f->print($tmpl->output); return OK; } 1;

I'm still debating where to put the .cgi scripts (in the filesystem) and have to figure out how to reference them from elsewhere (which will be used to adjust the $tmpl->param(_home => ...) bits, but otherwise, it seems to be working nicely.


In reply to Re^2: Embedding "user" CGI output into a mod_perl response by bmcatt
in thread Embedding "user" CGI output into a mod_perl response by bmcatt

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.