Added X-Forwarded-For

Change-Id: I78abb77707b7109f6a742e10a0862800c76e9781
diff --git a/Changes b/Changes
index c01d2b7..7b53f14 100755
--- a/Changes
+++ b/Changes
@@ -1,3 +1,8 @@
+0.22 2017-04-24
+        - Added user authentification using Kustvakts LDAP
+          connection.
+        - Added X-Forwarded-For.
+
 0.21 2017-02-01
         - Use textSigle for API communication instead of
           {corpus,doc,text}ID.
diff --git a/Makefile.PL b/Makefile.PL
index 5de3390..4a07291 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -20,9 +20,10 @@
     'Mojolicious::Plugin::Notifications' => 0.04,
     'Mojolicious::Plugin::MailException' => 0.18,
     'Mojolicious::Plugin::CHI' => 0.09,
+    'Mojolicious::Plugin::ClientIP' => 0.01,
     'Cache::FastMmap' => 0,
     'Mojo::JWT' => 0.05,
-    'File::Temp' => 1,
+    'File::Temp' => 0.2304,
 
     # Currently on GitHub only (github.com/akron)
     'Mojolicious::Plugin::Search' => 0.04,
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 0bd2252..799d8d3 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -109,7 +109,8 @@
     'CHI',                       # Global caching mechanism
     'TagHelpers::MailToChiffre', # Obfuscate email addresses
     'KalamarHelpers',            # Specific Helpers for Kalamar
-    'KalamarUser'                # Specific Helpers for Kalamar
+    'KalamarUser',               # Specific Helpers for Kalamar
+    'ClientIP'                   # Get client IP from X-Forwarded-For
   ) {
     $self->plugin($_);
   };
diff --git a/lib/Kalamar/Plugin/KalamarUser.pm b/lib/Kalamar/Plugin/KalamarUser.pm
index 561720a..88de452 100644
--- a/lib/Kalamar/Plugin/KalamarUser.pm
+++ b/lib/Kalamar/Plugin/KalamarUser.pm
@@ -58,8 +58,6 @@
 
       return $plugin->ua unless $auth;
 
-      my $client = $c->req->headers->header('X-Forwarded-For');
-
       my $ua = Mojo::UserAgent->new(
         connect_timeout => 15,
         inactivity_timeout => 120
@@ -68,6 +66,9 @@
       # Set app to server
       $ua->server->app($c->app);
 
+      # Initiate client information
+      my $client = $c->client_ip;
+
       $ua->on(
         start => sub {
           my ($ua, $tx) = @_;