Plack-Middleware-XForwardedFor

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Plack middleware to handle X-Forwarded-For headers",
   "author" : [
      "Graham Barr"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Plack middleware to handle X-Forwarded-For headers'
author:
  - 'Graham Barr'
build_requires: {}
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html

Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.008.
use strict;
use warnings;



use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Plack middleware to handle X-Forwarded-For headers",
  "AUTHOR" => "Graham Barr",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "Plack-Middleware-XForwardedFor",
  "LICENSE" => "perl",
  "NAME" => "Plack::Middleware::XForwardedFor",
  "PREREQ_PM" => {
    "Net::IP" => "1.26",
    "Plack" => "0.9913",

README.md  view on Meta::CPAN

# Plack::Middleware::XForwardedFor

Plack middleware handler for X-Forwarded-For headers

Using this module early in the plack stack will cause later modules
to see the REMOTE_ADDR the original source when the plack app is
behind a trusted proxy that supports adding X-Forwarded-For headers

This software is copyright (c) 2010 by Graham Barr <gbarr@pobox.com>.
    
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

lib/Plack/Middleware/XForwardedFor.pm  view on Meta::CPAN

package Plack::Middleware::XForwardedFor;
# ABSTRACT: Plack middleware to handle X-Forwarded-For headers
$Plack::Middleware::XForwardedFor::VERSION = '0.172050';
use strict;
use warnings;
use parent qw(Plack::Middleware);
use Plack::Util::Accessor qw(trust);
use Net::IP qw();

sub prepare_app {
  my $self = shift;

lib/Plack/Middleware/XForwardedFor.pm  view on Meta::CPAN

    $env->{REMOTE_ADDR} = $addr;
  }

  $self->app->($env);
}

1;

=head1 NAME

Plack::Middleware::XForwardedFor - Plack middleware to handle X-Forwarded-For headers

=head1 VERSION

version 0.172050

=head1 SYNOPSIS

  builder {
    enable "Plack::Middleware::XForwardedFor",
      trust => [qw(127.0.0.1/8)];
  };

=head1 DESCRIPTION

C<Plack::Middleware::XForwardedFor> will look for C<X-Forwarded-For>
header in the incoming request and change C<REMOTE_ADDR> to the
real client IP

=head1 PARAMETERS

=over

=item trust

If not specified then all addressed are trusted and C<REMOTE_ADDR> will be set to the
first IP in the C<X-Forwarded-For> header.

If given, it should be a list of IPs or Netmasks that can be trusted. Starting with the IP
of the client in C<REMOTE_ADDR> then the IPs in the C<X-Forwarded-For> header from right to left.
The first untrusted IP found is set to be C<REMOTE_ADDR>

=back

=head1 SEE ALSO

L<Plack::Middleware>, L<Net::IP>

=head1 AUTHOR



( run in 0.474 second using v1.01-cache-2.11-cpan-4e96b696675 )