[Koha-bugs] [Bug 17050] Accessing the REST API through Plack kicks the session out

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Aug 22 13:35:15 CEST 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17050

--- Comment #18 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
Created attachment 54680
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=54680&action=edit
Bug 17050: (QA followup) Use Mojo::Transaction to get the remote address

While the original patch fixes the issue, reading at Mojolicious source code,
revealed
that Mojo::Transaction already has proper processing for detecting the remote
address:

sub remote_address {
  my $self = shift;

  return $self->original_remote_address(@_) if @_;
  return $self->original_remote_address unless $self->req->reverse_proxy;

  # Reverse proxy
  return ($self->req->headers->header('X-Forwarded-For') // '') =~ /([^,\s]+)$/
    ? $1
    : $self->original_remote_address;
}

Without this patch, if there's a request without HTTP_X_FORWARDED_FOR, then the
remote
address would be empty. Such would be the case of a dev/standard setup without
Plack.

This patch makes Koha::REST::V1::startup use tx->remote_address instead of
dealing with the
headers on its own.

Signed-off-by: Tomas Cohen Arazi <tomascohen at theke.io>
Signed-off-by: Benjamin Rokseth <benjamin.rokseth at kul.oslo.kommune.no>

Signed-off-by: Jonathan Druart <jonathan.druart at bugs.koha-community.org>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list