Re: lost headers

Cris Shupp <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CA+gaLa28uOTmpB30e8q0KSb9hH=R=FZ0imp7Ki8g5x+uPL80Yw@mail.gmail.com>
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 <[email protected]> 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:
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.