Fixed X-Forwarded-For handling
Change-Id: Ib7781801052fec8ab37cb095a0c370ac3fc7bbd9
diff --git a/lib/Kalamar/Plugin/KalamarUser.pm b/lib/Kalamar/Plugin/KalamarUser.pm
index 3465b1d..a5db867 100644
--- a/lib/Kalamar/Plugin/KalamarUser.pm
+++ b/lib/Kalamar/Plugin/KalamarUser.pm
@@ -99,7 +99,7 @@
my $tx;
if ($c->user_auth) {
$tx = $plugin->build_authorized_tx(
- $c->user_auth, uc($method), $path, @_
+ $c->user_auth, $c->client_ip, uc($method), $path, @_
);
}
else {
@@ -224,7 +224,12 @@
unless ($value) {
- my $tx = $plugin->build_authorized_tx($auth, 'GET', Mojo::URL->new($plugin->api)->path('user/' . $param));
+ my $tx = $plugin->build_authorized_tx(
+ $auth,
+ $c->client_ip,
+ 'GET',
+ Mojo::URL->new($plugin->api)->path('user/' . $param)
+ );
$tx = $plugin->ua->start($tx);
unless ($value = $tx->success) {
@@ -266,7 +271,7 @@
# Build a JSON transaction object
my $tx = $plugin->build_authorized_tx(
- $auth, 'POST', 'user/' . $param, json => $json_obj
+ $auth, $c->client_ip, 'POST', 'user/' . $param, json => $json_obj
);
# Start
@@ -314,7 +319,7 @@
my $plugin = shift;
my $ua = $plugin->ua;
- my ($auth, $method, $path, @values) = @_;
+ my ($auth, $client_ip, $method, $path, @values) = @_;
my $header;
if (@values && ref $values[0] eq 'HASH') {
@@ -327,6 +332,7 @@
my $url = Mojo::URL->new($path);
$header->{Authorization} = $auth;
+ $header->{'X-Forwarded-For'} = $client_ip;
return $ua->build_tx($method, $url => $header => @values);
};