updated-packages
This commit is contained in:
14
vendor/fideloper/proxy/.github/ISSUE_TEMPLATE/laravel-9-updates.md
vendored
Normal file
14
vendor/fideloper/proxy/.github/ISSUE_TEMPLATE/laravel-9-updates.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: Laravel 9 Updates
|
||||
about: Inform about Laravel 9 changes
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
NOTE: Laravel has incorporated this package into the core of Laravel as of Laravel 9.
|
||||
|
||||
Do not use this package in Laravel 9. Details here: https://github.com/fideloper/TrustedProxy/issues/152
|
||||
-->
|
||||
51
vendor/fideloper/proxy/.github/workflows/tests.yml
vendored
Normal file
51
vendor/fideloper/proxy/.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Tests
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
run_tests:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [7.2, 7.3, 7.4, 8.0, 8.1]
|
||||
|
||||
name: PHP ${{ matrix.php }}
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
uses: nick-invision/retry@v1
|
||||
with:
|
||||
timeout_minutes: 5
|
||||
max_attempts: 5
|
||||
command: composer update --prefer-dist --no-interaction --no-progress
|
||||
|
||||
- name: Execute tests
|
||||
run: vendor/bin/phpunit --verbose
|
||||
13
vendor/fideloper/proxy/LICENSE.md
vendored
Normal file
13
vendor/fideloper/proxy/LICENSE.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
35
vendor/fideloper/proxy/composer.json
vendored
Executable file
35
vendor/fideloper/proxy/composer.json
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "fideloper/proxy",
|
||||
"description": "Set trusted proxies for Laravel",
|
||||
"keywords": ["proxy", "trusted proxy", "load balancing"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Chris Fidao",
|
||||
"email": "fideloper@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/http": "^5.0|^6.0|^7.0|^8.0|^9.0",
|
||||
"mockery/mockery": "^1.0",
|
||||
"phpunit/phpunit": "^8.5.8|^9.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Fideloper\\Proxy\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Fideloper\\Proxy\\TrustedProxyServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
46
vendor/fideloper/proxy/config/trustedproxy.php
vendored
Normal file
46
vendor/fideloper/proxy/config/trustedproxy.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* Set trusted proxy IP addresses.
|
||||
*
|
||||
* Both IPv4 and IPv6 addresses are
|
||||
* supported, along with CIDR notation.
|
||||
*
|
||||
* The "*" character is syntactic sugar
|
||||
* within TrustedProxy to trust any proxy
|
||||
* that connects directly to your server,
|
||||
* a requirement when you cannot know the address
|
||||
* of your proxy (e.g. if using ELB or similar).
|
||||
*
|
||||
*/
|
||||
'proxies' => null, // [<ip addresses>,], '*', '<ip addresses>,'
|
||||
|
||||
/*
|
||||
* To trust one or more specific proxies that connect
|
||||
* directly to your server, use an array or a string separated by comma of IP addresses:
|
||||
*/
|
||||
// 'proxies' => ['192.168.1.1'],
|
||||
// 'proxies' => '192.168.1.1, 192.168.1.2',
|
||||
|
||||
/*
|
||||
* Or, to trust all proxies that connect
|
||||
* directly to your server, use a "*"
|
||||
*/
|
||||
// 'proxies' => '*',
|
||||
|
||||
/*
|
||||
* Which headers to use to detect proxy related data (For, Host, Proto, Port)
|
||||
*
|
||||
* Options include:
|
||||
*
|
||||
* - All headers (see below) - Trust all x-forwarded-* headers
|
||||
* - Illuminate\Http\Request::HEADER_FORWARDED - Use the FORWARDED header to establish trust
|
||||
* - Illuminate\Http\Request::HEADER_X_FORWARDED_AWS_ELB - If you are using AWS Elastic Load Balancer
|
||||
*
|
||||
* @link https://symfony.com/doc/current/deployment/proxies.html
|
||||
*/
|
||||
'headers' => Illuminate\Http\Request::HEADER_X_FORWARDED_FOR | Illuminate\Http\Request::HEADER_X_FORWARDED_HOST | Illuminate\Http\Request::HEADER_X_FORWARDED_PORT | Illuminate\Http\Request::HEADER_X_FORWARDED_PROTO | Illuminate\Http\Request::HEADER_X_FORWARDED_AWS_ELB,
|
||||
|
||||
];
|
||||
144
vendor/fideloper/proxy/src/TrustProxies.php
vendored
Normal file
144
vendor/fideloper/proxy/src/TrustProxies.php
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Fideloper\Proxy;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
|
||||
class TrustProxies
|
||||
{
|
||||
/**
|
||||
* The config repository instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* The trusted proxies for the application.
|
||||
*
|
||||
* @var null|string|array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The proxy header mappings.
|
||||
*
|
||||
* @var null|string|int
|
||||
*/
|
||||
protected $headers;
|
||||
|
||||
/**
|
||||
* Create a new trusted proxies middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*/
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$request::setTrustedProxies([], $this->getTrustedHeaderNames()); // Reset trusted proxies between requests
|
||||
$this->setTrustedProxyIpAddresses($request);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the trusted proxies on the request to the value of trustedproxy.proxies
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
protected function setTrustedProxyIpAddresses(Request $request)
|
||||
{
|
||||
$trustedIps = $this->proxies ?: $this->config->get('trustedproxy.proxies');
|
||||
|
||||
// Trust any IP address that calls us
|
||||
// `**` for backwards compatibility, but is deprecated
|
||||
if ($trustedIps === '*' || $trustedIps === '**') {
|
||||
return $this->setTrustedProxyIpAddressesToTheCallingIp($request);
|
||||
}
|
||||
|
||||
// Support IPs addresses separated by comma
|
||||
$trustedIps = is_string($trustedIps) ? array_map('trim', explode(',', $trustedIps)) : $trustedIps;
|
||||
|
||||
// Only trust specific IP addresses
|
||||
if (is_array($trustedIps)) {
|
||||
return $this->setTrustedProxyIpAddressesToSpecificIps($request, $trustedIps);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the IP addresses to trust explicitly.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param array $trustedIps
|
||||
*/
|
||||
private function setTrustedProxyIpAddressesToSpecificIps(Request $request, $trustedIps)
|
||||
{
|
||||
$request->setTrustedProxies((array) $trustedIps, $this->getTrustedHeaderNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the trusted proxy to be the IP address calling this servers
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
private function setTrustedProxyIpAddressesToTheCallingIp(Request $request)
|
||||
{
|
||||
$request->setTrustedProxies([$request->server->get('REMOTE_ADDR')], $this->getTrustedHeaderNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve trusted header name(s), falling back to defaults if config not set.
|
||||
*
|
||||
* @return int A bit field of Request::HEADER_*, to set which headers to trust from your proxies.
|
||||
*/
|
||||
protected function getTrustedHeaderNames()
|
||||
{
|
||||
$headers = $this->headers ?: $this->config->get('trustedproxy.headers');
|
||||
switch ($headers) {
|
||||
case 'HEADER_X_FORWARDED_AWS_ELB':
|
||||
case Request::HEADER_X_FORWARDED_AWS_ELB:
|
||||
return Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
break;
|
||||
case 'HEADER_FORWARDED':
|
||||
case Request::HEADER_FORWARDED:
|
||||
return Request::HEADER_FORWARDED;
|
||||
break;
|
||||
case 'HEADER_X_FORWARDED_FOR':
|
||||
case Request::HEADER_X_FORWARDED_FOR:
|
||||
return Request::HEADER_X_FORWARDED_FOR;
|
||||
break;
|
||||
case 'HEADER_X_FORWARDED_HOST':
|
||||
case Request::HEADER_X_FORWARDED_HOST:
|
||||
return Request::HEADER_X_FORWARDED_HOST;
|
||||
break;
|
||||
case 'HEADER_X_FORWARDED_PORT':
|
||||
case Request::HEADER_X_FORWARDED_PORT:
|
||||
return Request::HEADER_X_FORWARDED_PORT;
|
||||
break;
|
||||
case 'HEADER_X_FORWARDED_PROTO':
|
||||
case Request::HEADER_X_FORWARDED_PROTO:
|
||||
return Request::HEADER_X_FORWARDED_PROTO;
|
||||
break;
|
||||
default:
|
||||
return Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
41
vendor/fideloper/proxy/src/TrustedProxyServiceProvider.php
vendored
Normal file
41
vendor/fideloper/proxy/src/TrustedProxyServiceProvider.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Fideloper\Proxy;
|
||||
|
||||
use Illuminate\Foundation\Application as LaravelApplication;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Lumen\Application as LumenApplication;
|
||||
|
||||
class TrustedProxyServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../config/trustedproxy.php') ?: $raw;
|
||||
|
||||
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
|
||||
$this->publishes([$source => config_path('trustedproxy.php')]);
|
||||
} elseif ($this->app instanceof LumenApplication) {
|
||||
$this->app->configure('trustedproxy');
|
||||
}
|
||||
|
||||
|
||||
if ($this->app instanceof LaravelApplication && ! $this->app->configurationIsCached()) {
|
||||
$this->mergeConfigFrom($source, 'trustedproxy');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user