Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted for Lumen #89

Open
wants to merge 1 commit into
base: feature/debugger
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
<div>
<div class="flex">
<div class="col bold tright pad pad-wide-3x">Client</div>
<div class="col pad"><code>{{ request()->getClientIp() }}</code></div>
<div class="col pad"><code>{{ $request->getClientIp() }}</code></div>
<div class="col pad tsm">
<p>The IP address the app thinks is the client. If TrustedProxy is misconfigured, this will be the IP address of an intermediary server such as a load balancer, cache, or CDN.</p>
<p>If this shows your IP address (your home or office network public address), then this is correctly configured.</p>
</div>
</div>
<div class="flex odd">
<div class="col bold tright pad pad-wide-3x min-wide">Scheme</div>
<div class="col pad"><code>{{ request()->getScheme() }}</code></div>
<div class="col pad"><code>{{ $request->getScheme() }}</code></div>
<div class="col pad tsm">
<p>If your site is using an SSL certificate, this should say <code>https</code>.</p>
</div>
</div>
<div class="flex">
<div class="col bold tright pad pad-wide-3x min-wide">Host</div>
<div class="col pad"><code>{{ request()->getHost() }}</code></div>
<div class="col pad"><code>{{ $request->getHost() }}</code></div>
<div class="col pad tsm">
<p>The hostname the application thinks your application is running as.</p>
<p>If this does not match the hostname used in your browser, than your proxy is not passing the correct <code>Host</code> header along to the application server.</p>
Expand All @@ -45,7 +45,7 @@
@foreach($headers as $header)
<li class="flex lh-2x">
<strong class="col">{{ $header }}</strong>
@if( array_key_exists($header, request()->headers->all()) ) <span class="col text-success">✔ found</span> @else <span class="col text-danger">𝗫 not found</span> @endif</li>
@if( array_key_exists($header, $request->headers->all()) ) <span class="col text-success">✔ found</span> @else <span class="col text-danger">𝗫 not found</span> @endif</li>
@endforeach
</ul>
<p>Note that not every header needs to be found. For example, the <code>forwarded</code> header is not yet commonly used.<br />
Expand All @@ -58,7 +58,7 @@
<div class="panel-heading marg-top">HTTP Request Headers</div>
<div>

@foreach(request()->headers as $header => $value)
@foreach($request->headers as $header => $value)
<div class="flex">
<div class="col bold tright pad pad-wide-3x min-wide">{{ $header }}</div>
@if($header == 'cookie')
Expand Down
4 changes: 0 additions & 4 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">

<title>TrustedProxy</title>

<!-- Styles -->
Expand Down
4 changes: 1 addition & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<?php

use Illuminate\Support\Facades\Route;

Route::get('/', '\Fideloper\Proxy\Http\Controllers\ProxyController@index');
$router->get('/', '\Fideloper\Proxy\Http\Controllers\ProxyController@index');
7 changes: 4 additions & 3 deletions src/Http/Controllers/ProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Fideloper\Proxy\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
#use Illuminate\Routing\Controller as BaseController;

class ProxyController extends BaseController
class ProxyController /*extends BaseController*/
{
/**
* Show the Proxy debugger dashboard
Expand All @@ -17,7 +17,7 @@ public function index()
{
$headers = app($laravel55Middleware)->getTrustedHeaderNames();
} else {
$headers = app(Fideloper\Proxy\TrustProxies::class)->getTrustedHeaderNames();
$headers = app(\Fideloper\Proxy\TrustProxies::class)->getTrustedHeaderNames();
}

$headers = collect($headers)->map(function($item, $key) {
Expand All @@ -26,6 +26,7 @@ public function index()

return view('proxy::dashboard', [
'headers' => $headers,
'request' => app(\Illuminate\Http\Request::class)
]);
}
}
15 changes: 7 additions & 8 deletions src/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,24 @@ public static function check($request)
public static function auth(Closure $callback)
{
static::$authUsing = $callback;
$registerRoutes = static::check(request());

$registerRoutes = static::check(
app(\Illuminate\Http\Request::class)
);
if( $registerRoutes )
{
static::routes();
}

return new static;
}

public static function routes()
{
Route::group([
$router = app();
$router->group([
'prefix' => 'trusted-proxy',
'middleware' => 'web',
], function () {
if (! app()->routesAreCached()) {
/*'middleware' => 'web',*/
], function () use ($router) {
require __DIR__.'/../routes/web.php';
}
});
}
}