[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Fwd: modperl Digest 16 Jun 2017 08:02:57 -0000 Issue 3266
From:       Cris Shupp <cshupp () gmail ! com>
Date:       2017-06-16 17:44:40
Message-ID: CA+gaLa0KSeXnET_VKS_=6NzGj5wXHCj0kFGv7coF_v2jArpGZA () mail ! gmail ! com
[Download RAW message or body]

André,

Thank you for your response!  I had to read your post multiple times (your
magic sentences):

---
No further "response generator" will be called for this request (such as
any "Ruby on Rails" module which might then have seen these response
headers).
(In other words : I think that your headers /are/ being set; but that there
is nothing that runs afterward to show you that they are set.)
---

I couldn't figure out why you would think I couldn't tell if my Rails code
was being hit.  I mean I am dense, but... He thinks I know what I am doing
in my perl...

OK, I did this:

             $r->headers_out->set('prisme-roles'=> $role_string );
Should of done:
             $r->headers_in->set('prisme-roles'=> $role_string );

I also put in more logging in my Rails controller, and it is a good thing I
did (I never would have seen my header on the web page)...

"prisme-roles" is transformed to "HTTP_PRISME_ROLES"


BTW, I am configured as a PerlFixupHandler, and it has always allowed a
return of FORBIDEN.

I tried (per your suggestion) using: PerlAuthenHandler

but that doesn't work.  My mod perl module seems to not even run in that
case.


Thanks,

Cris

On Fri, Jun 16, 2017 at 4:02 AM, <modperl-digest-help@perl.apache.org>
wrote:

>
> modperl Digest 16 Jun 2017 08:02:57 -0000 Issue 3266
>
> Topics (messages 64692 through 64693)
>
> Re: lost headers
>         64692 by: Cris Shupp
>         64693 by: André Warnier (tomcat)
>
> Administrivia:
>
> ---------------------------------------------------------------------
> To post to the list, e-mail: modperl@perl.apache.org
> To unsubscribe, e-mail: modperl-digest-unsubscribe@perl.apache.org
> For additional commands, e-mail: modperl-digest-help@perl.apache.org
>
> ----------------------------------------------------------------------
>
>
>
> ---------- Forwarded message ----------
> From: Cris Shupp <cshupp@gmail.com>
> To: modperl@perl.apache.org
> Cc:
> Bcc:
> Date: Tue, 13 Jun 2017 12:54:14 -0400
> Subject: Re: lost headers
> Hello all...
>
> I have a simple mod_perl program that does some custom role based
> authentication before granting access to certain resources.  That part does
> work, but for a new feature I need to be able to embed roles into my
> headers.  Try as may, try as I might, those roles never show up...
>
>
> consider a portion of my mod_perl program:
>
> #####################
> sub handler {
> ...
> if($user) {
>         my $val = rest_call($user,$context, $r->log);
>         my $roles = $cache_hash{'roles'}->{$user};
>         my $role_string = join(',', @$roles);
>         $r->headers_out->set('prisme-roles'=> $role_string );
>         #$r->headers_out->add('prisme.roles'=> $role_string );
>         $r->err_headers_out->add('prisme-roles2', $role_string);
>         #$|++;
>         $r->rflush();# $r->rflush can't be called before the response
> phase if using PerlFixupHandler Prisme::ValidateHeader
>         $r->log->info("Request end on pid $$: The user for this request is
> $user, the roles are $role_string, returning $val");
>         return $val; #OK or FORBIDDEN
>         }
> ###################################
>
> With either config in http.conf:
> ##############################
> <Location /rails_prisme/>
>   SetHandler perl-script
>   PerlResponseHandler Prisme::ValidateHeader
>   #PerlFixupHandler Prisme::ValidateHeader
> </Location>
> ####################
>
>
> My Ruby on Rails controller:
> #######################
> def warmup
>     @headers = {}
>     @warmup_count = $PROPS['PRISME.warmup_apache'].to_i
>     request.headers.each do |elem|
>       @headers[elem.first.to_s] = elem.last.to_s
>     end
>     response.headers.each do |elem|
>       @headers[elem.first.to_s] = elem.last.to_s
> end
>     respond_to do |format|
>       format.html # list_headers.html.erb
>       format.json { render :json => params['counter'] }
>     end
>   end
> #######################
>
>
> Never sees those headers!  Help!
>
> Thanks,
>
> Cris
>
>
> On Tue, Jun 13, 2017 at 12:52 PM, Cris Shupp <cshupp@gmail.com> wrote:
>
>> Hello all...
>>
>> I have a simple mod_perl program that does some custom role based
>> authentication before granting access to certain resources.  That part does
>> work, but for a new feature I need to be able to embed roles into my
>> headers.  Try as may, try as I might, those roles never show up...
>>
>>
>> consider a portion of my mod_perl program:
>>
>> sub handler {
>> ...
>> if($user) {
>>         my $val = rest_call($user,$context, $r->log);
>>         my $roles = $cache_hash{'roles'}->{$user};
>>         my $role_string = join(',', @$roles);
>>         $r->headers_out->set('prisme-roles'=> $role_string );
>>         #$r->headers_out->add('prisme.roles'=> $role_string );
>>         $r->err_headers_out->add('prisme-roles2', $role_string);
>>         #$|++;
>>         $r->rflush();# $r->rflush can't be called before the response
>> phase if using PerlFixupHandler Prisme::ValidateHeader
>>         $r->log->info("Request end on pid $$: The user for this request
>> is $user, the roles are $role_string, returning $val");
>>         return $val; #OK or FORBIDDEN
>>         }
>>
>> With either config in http.conf:
>>
>> <Location /rails_prisme/>
>>   SetHandler perl-script
>>   PerlResponseHandler Prisme::ValidateHeader
>>   #PerlFixupHandler Prisme::ValidateHeader
>> </Location>
>>
>> My Ruby on Rails controller:
>>
>>
>>
>>
>
>
> ---------- Forwarded message ----------
> From: "André Warnier (tomcat)" <aw@ice-sa.com>
> To: modperl@perl.apache.org
> Cc:
> Bcc:
> Date: Wed, 14 Jun 2017 11:32:58 +0200
> Subject: Re: lost headers
> Hi.
> To avoid another round of questions/answers, it would be better to provide
> some versions of what you are using, right away.
> One quick way of doing this, is to insert here the line which appears in
> your Apache webserver main error logfile at startup.
> It shows the Apache httpd version, the version of perl, and the version of
> mod_perl.
>
> Secondly, in your explanation below, it is not very clear when/if your
> "Ruby on Rails controller" is even called.
>
> You are seting this in the Apache httpd configuration :
>
>  <Location /rails_prisme/>
>     SetHandler perl-script
>     PerlResponseHandler Prisme::ValidateHeader
>  </Location>
>
> That means that mod_perl (and the Prisme::ValidateHeader mod_perl module)
> are effectively, for Apache, the code which generates the HTTP response to
> this request.
> No further "response generator" will be called for this request (such as
> any "Ruby on Rails" module which might then have seen these response
> headers).
>
> (In other words : I think that your headers /are/ being set; but that
> there is nothing that runs afterward to show you that they are set.)
>
> Configuring your module as a PerlFixupHandler (*and* dropping the
> "SetHandler perl-script") would avoid this. But in such a handler, you can
> only return "OK" or "DECLINED" (and not "FORBIDDEN"), see :
> http://perl.apache.org/docs/2.0/user/handlers/intro.html#Stacked_Handlers
>
> Personally however, considering that this seems to be a part of an AAA
> phase, I would make adding this header as either a part of the
> already-existing Perl Authentication module, or configure your perl module
> as a PerlAuthenHandler.
> (In that case also, you /can/ return FORBIDDEN).
>
>
>
> On 13.06.2017 18:54, Cris Shupp wrote:
>
>> Hello all...
>>
>> I have a simple mod_perl program that does some custom role based
>> authentication before
>> granting access to certain resources.  That part does work, but for a new
>> feature I need
>> to be able to embed roles into my headers.  Try as may, try as I might,
>> those roles never
>> show up...
>>
>>
>> consider a portion of my mod_perl program:
>>
>> #####################
>> sub handler {
>> ...
>> if($user) {
>>          my $val = rest_call($user,$context, $r->log);
>>          my $roles = $cache_hash{'roles'}->{$user};
>>          my $role_string = join(',', @$roles);
>>          $r->headers_out->set('prisme-roles'=> $role_string );
>>          #$r->headers_out->add('prisme.roles'=> $role_string );
>>          $r->err_headers_out->add('prisme-roles2', $role_string);
>>          #$|++;
>>          $r->rflush();# $r->rflush can't be called before the response
>> phase if using
>> PerlFixupHandler Prisme::ValidateHeader
>>          $r->log->info("Request end on pid $$: The user for this request
>> is $user, the
>> roles are $role_string, returning $val");
>>          return $val; #OK or FORBIDDEN
>>          }
>> ###################################
>>
>> With either config in http.conf:
>> ##############################
>> <Location /rails_prisme/>
>>    SetHandler perl-script
>>    PerlResponseHandler Prisme::ValidateHeader
>>    #PerlFixupHandler Prisme::ValidateHeader
>> </Location>
>> ####################
>>
>>
>> My Ruby on Rails controller:
>> #######################
>> def warmup
>>      @headers = {}
>>      @warmup_count = $PROPS['PRISME.warmup_apache'].to_i
>>      request.headers.each do |elem|
>>        @headers[elem.first.to_s] = elem.last.to_s
>>      end
>>      response.headers.each do |elem|
>>        @headers[elem.first.to_s] = elem.last.to_s
>> end
>>      respond_to do |format|
>>        format.html # list_headers.html.erb
>>        format.json { render :json => params['counter'] }
>>      end
>>    end
>> #######################
>>
>>
>> Never sees those headers!  Help!
>>
>> Thanks,
>>
>> Cris
>>
>>
>> On Tue, Jun 13, 2017 at 12:52 PM, Cris Shupp <cshupp@gmail.com <mailto:
>> cshupp@gmail.com>>
>> wrote:
>>
>>     Hello all...
>>
>>     I have a simple mod_perl program that does some custom role based
>> authentication
>>     before granting access to certain resources.  That part does work,
>> but for a new
>>     feature I need to be able to embed roles into my headers.  Try as
>> may, try as I might,
>>     those roles never show up...
>>
>>
>>     consider a portion of my mod_perl program:
>>
>>     sub handler {
>>     ...
>>     if($user) {
>>              my $val = rest_call($user,$context, $r->log);
>>              my $roles = $cache_hash{'roles'}->{$user};
>>              my $role_string = join(',', @$roles);
>>              $r->headers_out->set('prisme-roles'=> $role_string );
>>              #$r->headers_out->add('prisme.roles'=> $role_string );
>>              $r->err_headers_out->add('prisme-roles2', $role_string);
>>              #$|++;
>>              $r->rflush();# $r->rflush can't be called before the
>> response phase if using
>>     PerlFixupHandler Prisme::ValidateHeader
>>              $r->log->info("Request end on pid $$: The user for this
>> request is $user, the
>>     roles are $role_string, returning $val");
>>              return $val; #OK or FORBIDDEN
>>              }
>>
>>     With either config in http.conf:
>>
>>     <Location /rails_prisme/>
>>        SetHandler perl-script
>>        PerlResponseHandler Prisme::ValidateHeader
>>        #PerlFixupHandler Prisme::ValidateHeader
>>     </Location>
>>
>>     My Ruby on Rails controller:
>>
>>
>>
>>
>>
>
>
>

[Attachment #3 (text/html)]

<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div><span \
style="font-size:16px">André,</span><span \
style="font-size:16px"><br></span></div><div><span \
style="font-size:16px"><br></span></div><div><span style="font-size:16px">Thank you \
for your response!   I had to read your post multiple times (your magic \
sentences):</span></div><span style="font-size:16px"><div><span \
style="font-size:16px"><br></span></div><div><span \
style="font-size:16px">---</span></div><div>No further &quot;response generator&quot; \
will be called for this request (such as any &quot;Ruby on Rails&quot; module which \
might then have seen these response headers).<span \
style="font-size:16px"><br></span></div>(In other words : I think that your headers \
/are/ being set; but that there is nothing that runs afterward to show you that they \
are set.)</span><br><div><span style="font-size:16px">---</span></div><div><span \
style="font-size:16px"><br></span></div><div><span style="font-size:16px">I \
couldn&#39;t figure out why you would think I couldn&#39;t tell if my Rails code was \
being hit.   I mean I am dense, but... He thinks I know what I am doing in my \
perl...</span></div><div><span style="font-size:16px"><br></span></div><div><span \
style="font-size:16px">OK, I did this:</span></div><div><span \
style="font-size:16px"><br></span></div><div><span style="font-size:16px">            \
$r-&gt;headers_out-&gt;set(&#39;prisme-</span><span \
style="font-size:16px"><wbr>roles&#39;=&gt; $role_string );</span><br \
style="font-size:16px"></div><div><span style="font-size:16px">Should of \
done:</span></div><div><span style="font-size:16px">                    \
$r-&gt;headers_in-&gt;set(&#39;prisme-</span><span \
style="font-size:16px">r<wbr>oles&#39;=&gt; $role_string );</span><br \
style="font-size:16px"></div><div><span \
style="font-size:16px"><br></span></div><div><span style="font-size:16px">I also put \
in more logging in my Rails controller, and it is a good thing I did (I never would \
have seen my header on the web page)...</span></div><div><span \
style="font-size:16px"><br></span></div><div><span \
style="font-size:16px">&quot;prisme-roles&quot; is transformed to \
&quot;HTTP_PRISME_ROLES&quot;</span></div><div><span \
style="font-size:16px"><br></span></div><div><span \
style="font-size:16px"><br></span></div><div><span style="font-size:16px">BTW, I am \
configured as a  </span><span style="font-size:16px">PerlFixupHandler, and it has \
always allowed a return of FORBIDEN.</span></div><div><span \
style="font-size:16px"><br></span></div><div><span style="font-size:16px">I tried \
(per your suggestion) using:  </span><span \
style="color:rgb(0,0,0);font-family:&quot;courier \
new&quot;,courier,monospace;font-size:medium">PerlAuthenHandler</span></div><div><span \
style="color:rgb(0,0,0);font-family:&quot;courier \
new&quot;,courier,monospace;font-size:medium"><br></span></div><div><span \
style="font-size:16px">but that doesn&#39;t work.   My mod perl module seems to not \
even run in that case.</span></div><div><span \
style="color:rgb(0,0,0);font-family:&quot;courier \
new&quot;,courier,monospace;font-size:medium"><br></span></div><div><span \
style="color:rgb(0,0,0);font-family:&quot;courier \
new&quot;,courier,monospace;font-size:medium"><br></span></div><div><span \
style="color:rgb(0,0,0);font-family:&quot;courier \
new&quot;,courier,monospace;font-size:medium">Thanks,</span></div><div><span \
style="color:rgb(0,0,0);font-family:&quot;courier \
new&quot;,courier,monospace;font-size:medium"><br></span></div><div><span \
style="color:rgb(0,0,0);font-family:&quot;courier \
new&quot;,courier,monospace;font-size:medium">Cris                 \
</span><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div \
class="h5">On Fri, Jun 16, 2017 at 4:02 AM,  <span dir="ltr">&lt;<a \
href="mailto:modperl-digest-help@perl.apache.org" \
target="_blank">modperl-digest-help@perl.<wbr>apache.org</a>&gt;</span> \
wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div \
class="h5"><br> modperl Digest 16 Jun 2017 08:02:57 -0000 Issue 3266<br>
<br>
Topics (messages 64692 through 64693)<br>
<br>
Re: lost headers<br>
            64692 by: Cris Shupp<br>
            64693 by: André Warnier (tomcat)<br>
<br>
Administrivia:<br>
<br>
------------------------------<wbr>------------------------------<wbr>---------<br>
To post to the list, e-mail: <a href="mailto:modperl@perl.apache.org" \
target="_blank">modperl@perl.apache.org</a><br> To unsubscribe, e-mail: <a \
href="mailto:modperl-digest-unsubscribe@perl.apache.org" \
target="_blank">modperl-digest-unsubscribe@per<wbr>l.apache.org</a><br> For \
additional commands, e-mail: <a href="mailto:modperl-digest-help@perl.apache.org" \
target="_blank">modperl-digest-help@perl.apach<wbr>e.org</a><br> <br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
<br><br></div></div>---------- Forwarded message ----------<br>From:  Cris Shupp \
&lt;<a href="mailto:cshupp@gmail.com" target="_blank">cshupp@gmail.com</a>&gt;<br>To: \
<a href="mailto:modperl@perl.apache.org" \
target="_blank">modperl@perl.apache.org</a><br>Cc:  <br>Bcc:  <br>Date:  Tue, 13 Jun \
2017 12:54:14 -0400<br>Subject:  Re: lost headers<br><div dir="ltr"><span \
style="font-size:16px">Hello all...</span><div style="font-size:16px"><br></div><div \
style="font-size:16px">I have a simple mod_perl program that does some custom role \
based authentication before granting access to certain resources.   That part does \
work, but for a new feature I need to be able to embed roles into my headers.   Try \
as may, try as I might, those roles never show up...</div><div \
style="font-size:16px"><br></div><div style="font-size:16px"><br></div><div \
style="font-size:16px">consider a portion of my mod_perl program:</div><div \
style="font-size:16px"><br></div><div \
style="font-size:16px">#####################</div><div style="font-size:16px">sub \
handler {<br></div><div style="font-size:16px">...</div><div \
style="font-size:16px"><div>if($user) {</div><div>            my $val = \
rest_call($user,$context, $r-&gt;log);</div><div>            my $roles = \
$cache_hash{&#39;roles&#39;}-&gt;{$user};</div><div>            my $role_string = \
join(&#39;,&#39;, @$roles);</div><div>            \
$r-&gt;headers_out-&gt;set(&#39;prisme-r<wbr>oles&#39;=&gt; $role_string \
);</div><div>            #$r-&gt;headers_out-&gt;add(&#39;prisme.<wbr>roles&#39;=&gt; \
$role_string );</div><div>            \
$r-&gt;err_headers_out-&gt;add(&#39;pris<wbr>me-roles2&#39;, \
$role_string);</div><div>            #$|++;</div><div>            $r-&gt;rflush();# \
$r-&gt;rflush can&#39;t be called before the response phase if using PerlFixupHandler \
Prisme::ValidateHeader</div><div>            $r-&gt;log-&gt;info(&quot;Request end on \
pid $$: The user for this request is $user, the roles are $role_string, returning \
$val&quot;);</div><div>            return $val; #OK or FORBIDDEN</div><div>           \
}</div></div><div style="font-size:16px">##############################<wbr>#####</div><div \
style="font-size:16px"><br></div><div style="font-size:16px">With either config in \
http.conf:</div><div style="font-size:16px">##############################</div><div \
style="font-size:16px"><div>&lt;Location /rails_prisme/&gt;</div><div>   SetHandler \
perl-script</div><div>   PerlResponseHandler Prisme::ValidateHeader</div><div>   \
#PerlFixupHandler Prisme::ValidateHeader</div><div>&lt;/Location&gt;</div></div><div \
style="font-size:16px">####################</div><div \
style="font-size:16px"><br></div><div style="font-size:16px"><br></div><div \
style="font-size:16px">My Ruby on Rails controller:</div><div \
style="font-size:16px">#######################</div><div \
style="font-size:16px"><div>def warmup</div><div>      @headers = {}</div><div>      \
@warmup_count = $PROPS[&#39;PRISME.warmup_apache&#39;]<wbr>.to_i</div><div>      \
request.headers.each do |elem|</div><div>         @headers[elem.first.to_s] = \
elem.last.to_s</div><div>      end</div><div>      response.headers.each do \
|elem|</div><div>         @headers[elem.first.to_s] = \
elem.last.to_s</div><div>end</div><div>      respond_to do |format|</div><div>        \
format.html # list_headers.html.erb</div><div>         format.json { render :json \
=&gt; params[&#39;counter&#39;] }</div><div>      end</div><div>   \
end</div><div>#######################</div><div><br></div><div><br></div><div>Never \
sees those headers!   \
Help!</div><div><br></div><div>Thanks,</div><div><br></div><div>Cris</div><div><br></div></div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 13, 2017 at 12:52 PM, \
Cris Shupp <span dir="ltr">&lt;<a href="mailto:cshupp@gmail.com" \
target="_blank">cshupp@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello all...<div><br></div><div>I \
have a simple mod_perl program that does some custom role based authentication before \
granting access to certain resources.   That part does work, but for a new feature I \
need to be able to embed roles into my headers.   Try as may, try as I might, those \
roles never show up...</div><div><br></div><div><br></div><div>consider a portion of \
my mod_perl program:</div><div><br></div><div>sub handler \
{<br></div><div>...</div><div><div>if($user) {</div><div>            my $val = \
rest_call($user,$context, $r-&gt;log);</div><div>            my $roles = \
$cache_hash{&#39;roles&#39;}-&gt;{$user};</div><div>            my $role_string = \
join(&#39;,&#39;, @$roles);</div><div>            \
$r-&gt;headers_out-&gt;set(&#39;prisme-r<wbr>oles&#39;=&gt; $role_string \
);</div><div>            #$r-&gt;headers_out-&gt;add(&#39;prisme.<wbr>roles&#39;=&gt; \
$role_string );</div><div>            \
$r-&gt;err_headers_out-&gt;add(&#39;pris<wbr>me-roles2&#39;, \
$role_string);</div><div>            #$|++;</div><div>            $r-&gt;rflush();# \
$r-&gt;rflush can&#39;t be called before the response phase if using PerlFixupHandler \
Prisme::ValidateHeader</div><div>            $r-&gt;log-&gt;info(&quot;Request end on \
pid $$: The user for this request is $user, the roles are $role_string, returning \
$val&quot;);</div><div>            return $val; #OK or FORBIDDEN</div><div>           \
}</div></div><div><br></div><div>With either config in \
http.conf:</div><div><br></div><div><div>&lt;Location /rails_prisme/&gt;</div><div>   \
SetHandler perl-script</div><div>   PerlResponseHandler \
Prisme::ValidateHeader</div><div>   #PerlFixupHandler \
Prisme::ValidateHeader</div><div>&lt;/Location&gt;</div></div><div><br></div><div>My \
Ruby on Rails controller:</div><div><br></div><div><br></div><div><br></div></div> \
</blockquote></div><br></div> <br><br>---------- Forwarded message \
----------<br>From:  &quot;André Warnier (tomcat)&quot; &lt;<a \
href="mailto:aw@ice-sa.com" target="_blank">aw@ice-sa.com</a>&gt;<br>To:  <a \
href="mailto:modperl@perl.apache.org" \
target="_blank">modperl@perl.apache.org</a><br>Cc:  <br>Bcc:  <br>Date:  Wed, 14 Jun \
2017 11:32:58 +0200<br>Subject:  Re: lost headers<br>Hi.<br> To avoid another round \
of questions/answers, it would be better to provide some versions of what you are \
using, right away.<br> One quick way of doing this, is to insert here the line which \
appears in your Apache webserver main error logfile at startup.<br> It shows the \
Apache httpd version, the version of perl, and the version of mod_perl.<br> <br>
Secondly, in your explanation below, it is not very clear when/if your &quot;Ruby on \
Rails controller&quot; is even called.<br> <br>
You are seting this in the Apache httpd configuration :<br>
<br>
  &lt;Location /rails_prisme/&gt;<br>
      SetHandler perl-script<br>
      PerlResponseHandler Prisme::ValidateHeader<br>
  &lt;/Location&gt;<br>
<br>
That means that mod_perl (and the Prisme::ValidateHeader mod_perl module) are \
effectively, for Apache, the code which generates the HTTP response to this \
request.<br> No further &quot;response generator&quot; will be called for this \
request (such as any &quot;Ruby on Rails&quot; module which might then have seen \
these response headers).<br> <br>
(In other words : I think that your headers /are/ being set; but that there is \
nothing that runs afterward to show you that they are set.)<br> <br>
Configuring your module as a PerlFixupHandler (*and* dropping the &quot;SetHandler \
perl-script&quot;) would avoid this. But in such a handler, you can only return \
&quot;OK&quot; or &quot;DECLINED&quot; (and not &quot;FORBIDDEN&quot;), see : <a \
href="http://perl.apache.org/docs/2.0/user/handlers/intro.html#Stacked_Handlers" \
rel="noreferrer" target="_blank">http://perl.apache.org/docs/2.<wbr>0/user/handlers/intro.html#Sta<wbr>cked_Handlers</a><br>
 <br>
Personally however, considering that this seems to be a part of an AAA phase, I would \
make adding this header as either a part of the already-existing Perl Authentication \
module, or configure your perl module as a PerlAuthenHandler.<br> (In that case also, \
you /can/ return FORBIDDEN).<br> <br>
<br>
<br>
On 13.06.2017 18:54, Cris Shupp wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"> Hello all...<br>
<br>
I have a simple mod_perl program that does some custom role based authentication \
before<br> granting access to certain resources.   That part does work, but for a new \
feature I need<br> to be able to embed roles into my headers.   Try as may, try as I \
might, those roles never<br> show up...<br>
<br>
<br>
consider a portion of my mod_perl program:<br>
<br>
#####################<br>
sub handler {<br>
...<br>
if($user) {<br>
              my $val = rest_call($user,$context, $r-&gt;log);<br>
              my $roles = $cache_hash{&#39;roles&#39;}-&gt;{$user};<br>
              my $role_string = join(&#39;,&#39;, @$roles);<br>
              $r-&gt;headers_out-&gt;set(&#39;prisme-<wbr>roles&#39;=&gt; \
                $role_string );<br>
              #$r-&gt;headers_out-&gt;add(&#39;prisme<wbr>.roles&#39;=&gt; \
                $role_string );<br>
              $r-&gt;err_headers_out-&gt;add(&#39;pri<wbr>sme-roles2&#39;, \
$role_string);<br>  #$|++;<br>
              $r-&gt;rflush();# $r-&gt;rflush can&#39;t be called before the response \
phase if using<br> PerlFixupHandler Prisme::ValidateHeader<br>
              $r-&gt;log-&gt;info(&quot;Request end on pid $$: The user for this \
request is $user, the<br> roles are $role_string, returning $val&quot;);<br>
              return $val; #OK or FORBIDDEN<br>
              }<br>
##############################<wbr>#####<br>
<br>
With either config in http.conf:<br>
##############################<br>
&lt;Location /rails_prisme/&gt;<br>
     SetHandler perl-script<br>
     PerlResponseHandler Prisme::ValidateHeader<br>
     #PerlFixupHandler Prisme::ValidateHeader<br>
&lt;/Location&gt;<br>
####################<br>
<br>
<br>
My Ruby on Rails controller:<br>
#######################<br>
def warmup<br>
        @headers = {}<br>
        @warmup_count = $PROPS[&#39;PRISME.warmup_apache&#39;]<wbr>.to_i<br>
        request.headers.each do |elem|<br>
           @headers[elem.first.to_s] = elem.last.to_s<br>
        end<br>
        response.headers.each do |elem|<br>
           @headers[elem.first.to_s] = elem.last.to_s<br>
end<br>
        respond_to do |format|<br>
           format.html # list_headers.html.erb<br>
           format.json { render :json =&gt; params[&#39;counter&#39;] }<br>
        end<br>
     end<br>
#######################<br>
<br>
<br>
Never sees those headers!   Help!<br>
<br>
Thanks,<br>
<br>
Cris<br>
<br>
<br>
On Tue, Jun 13, 2017 at 12:52 PM, Cris Shupp &lt;<a href="mailto:cshupp@gmail.com" \
target="_blank">cshupp@gmail.com</a> &lt;mailto:<a href="mailto:cshupp@gmail.com" \
target="_blank">cshupp@gmail.com</a>&gt;&gt;<br> wrote:<br>
<br>
      Hello all...<br>
<br>
      I have a simple mod_perl program that does some custom role based \
                authentication<br>
      before granting access to certain resources.   That part does work, but for a \
                new<br>
      feature I need to be able to embed roles into my headers.   Try as may, try as \
I might,<br>  those roles never show up...<br>
<br>
<br>
      consider a portion of my mod_perl program:<br>
<br>
      sub handler {<br>
      ...<br>
      if($user) {<br>
                    my $val = rest_call($user,$context, $r-&gt;log);<br>
                    my $roles = $cache_hash{&#39;roles&#39;}-&gt;{$user};<br>
                    my $role_string = join(&#39;,&#39;, @$roles);<br>
                    $r-&gt;headers_out-&gt;set(&#39;prisme-<wbr>roles&#39;=&gt; \
                $role_string );<br>
                    #$r-&gt;headers_out-&gt;add(&#39;prisme<wbr>.roles&#39;=&gt; \
                $role_string );<br>
                    $r-&gt;err_headers_out-&gt;add(&#39;pri<wbr>sme-roles2&#39;, \
$role_string);<br>  #$|++;<br>
                    $r-&gt;rflush();# $r-&gt;rflush can&#39;t be called before the \
response phase if using<br>  PerlFixupHandler Prisme::ValidateHeader<br>
                    $r-&gt;log-&gt;info(&quot;Request end on pid $$: The user for \
this request is $user, the<br>  roles are $role_string, returning $val&quot;);<br>
                    return $val; #OK or FORBIDDEN<br>
                    }<br>
<br>
      With either config in http.conf:<br>
<br>
      &lt;Location /rails_prisme/&gt;<br>
           SetHandler perl-script<br>
           PerlResponseHandler Prisme::ValidateHeader<br>
           #PerlFixupHandler Prisme::ValidateHeader<br>
      &lt;/Location&gt;<br>
<br>
      My Ruby on Rails controller:<br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
<br></blockquote></div><br></div></div>
</div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic