-
Notifications
You must be signed in to change notification settings - Fork 590
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
Could not get it to work for non-local environment #76
Comments
Remove this from the register function
|
@L3o-pold Perfect, Thanks |
excuse me I can not connect to the dashboard with a non
|
@120dev It should works, what kind of message do you have? |
+1, can't connect the dashboard with production env. |
+1 I got 403 Forbidden in Production even if the Gate returns always true |
I am not sure if it's only me or it is a bug but, i think i found the issue. The problem is it doesn't discover
and in
then without any issue i can reach |
Same here! It works when I use I tried @DrAmen solution but It didn't worked for me. app.php 'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
App\Providers\RouteServiceProvider::class,
// Agregados por mí.
crocodicstudio\crudbooster\CRUDBoosterServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
], TelescopeServiceProvider.php protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return true;
// return \CRUDBooster::isSuperadmin();
});
} |
Telescope here works perfectly local, we have a 'staging' environment where we setup Telescope now like this:
Locally this works fine, the viewTelescope protection works fine too in staging. We can open Telescope but there are no entries in staging, EXCEPT when we change We need to distinguish our environments for monitoring errors and other relevant environment based information. Any suggestions? |
I just updated to Telescope 1.0 and the problem is still the same. Gate::define('viewTelescope', function ($user) {
return true;
// return \CRUDBooster::isSuperadmin();
}); |
I'm having this issue as well now, as of 13 days ago. Requests aren't being logged (among other things) in a production environment anymore. |
Guys, we'd love to help but we aren't able to reproduce this. So, here are some guidelines/checks:
If all of these are okay but you're still facing issues, please share a Github repo with this reproducible issue. |
|
@Braunson number 2 seems to be your issue. Your filter is setup to only record reportable exceptions, failed jobs, scheduled tasks or monitored tags in production but will record everything in local. If you remove the |
@paras-malhotra Ah ok, It was weird because this previous to v0.1.8/1.0 everything recorded regardless of environment. Must have been a code change |
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// Telescope::night();
Telescope::filter(function (IncomingEntry $entry) {
if ($this->app->environment('local')) {
return true;
}
return $entry->isReportableException() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return true;
// return \CRUDBooster::isSuperadmin();
});
}
}
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
App\Providers\RouteServiceProvider::class,
// Agregados por mí.
crocodicstudio\crudbooster\CRUDBoosterServiceProvider::class,
\Laravel\Telescope\TelescopeServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
], |
If I change APP_ENV to local in the server, It shows the dashboard. |
Changed the Authorize middleware by my own as following:
It fixed the 403 Forbidden on a production server. |
@EdwinDayot, if you do that, there's no security because It doesn't check for the user. |
If you've been following the instructions in the section "Installing Only In Specific Environments" you'll need to ensure that you update your
|
Is it possible to remove selected incoming entries from Telescope::filter(function (IncomingEntry $entry) {
return $entry->isReportableException() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
// Allow more entries here. Redis, Mail, Events...
}); I would like to track error exceptions, dispatched events or sent mails for example. thanks |
Hi, is there a reason why Telescope does not register any of my browser actions? Dump, requests, sql queries, etc... do not show up on my telescope application. I've also checked my telescope entries table and there are no rows being created for my browser's actions. |
in my side, i found the problem was on its Authorization mechanism. so, we can replace it with our own auth mechanisme. now, mine is: in
|
The problem appears to be the following method in /**
* Configure the Telescope authorization services.
*
* @return void
*/
protected function authorization()
{
$this->gate();
Telescope::auth(function ($request) {
return app()->environment('local') ||
Gate::check('viewTelescope', [$request->user()]);
});
} I overrode this method in my /**
* Configure the Telescope authorization services.
*
* @return void
*/
protected function authorization()
{
$this->gate();
Telescope::auth(function ($request) {
return app()->environment(['local', 'staging']) ||
Gate::check('viewTelescope', [$request->user()]);
});
} This allowed me to access telescope in my staging environment. I tried changing my |
As @glendmaatita says I did a middleware exclusively for telescope 'middleware' => [
'web',
TelescopeMiddleware::class,
// Authorize::class,
], php artisan make:middleware TelescopeMiddleware class TelescopeMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(auth()->check() && auth()->user()->email == "punksolid@gmail.com"){
return $next($request);
}
abort(403);
}
} |
Literally tried everything in this thread and nothing worked other than modifying TelescopeServiceProvider closure. The Gate:: facade call ALWAYS returned false no matter the logic defined in the Provider. I ended up removing it entirely and adding in my own function call for IP whitelisting. Works!
|
Changing telescope authorization middleware with laravel's authentication middleware worked for me. It's just a workaround. 'middleware' => [
'web',
// Authorize::class,
\App\Http\Middleware\Authenticate::class,
], |
Thanks, i just comment 'Authorize::class' |
@RuanHerculano that error is caused because your assets are not being served over https we use this in production |
Telescope's gate can run right when |
This issue is due to an empty or non logged user. Laravel gate receives user as the first argument if it's empty it doesn't care about internal code. If you want to use it without gate just remove gate function from TelescopeServiceProvider class and override authorization function. See the example below.
I removed the gate define as well as gate check, so the issue is resolved. |
In config/telescope.php you can configure your own authentication with a middleware if you want to build your own thing (if your company has it's own CMS for example) or just want to only let through whitelisted ip's |
Hello Team With these steps you resolve the issue:
public function handle($request, Closure $next, ...$guards): mixed
{
if (app()->environment('local')) {
return $next($request);
}
if (app()->environment('production') && !$request->expectsJson()) {
parent::handle($request, $next, ...$guards);
}
return abort(403);
}
'middleware' => [
'web',
AuthorizeTelescope::class,
], |
Fresh install of latest Laravel and Telescope and this is still not working on non-local environments. Simple returning the TRUE is not working in the
|
I can solve it by rewrite authorization method /**
* Configure the Telescope authorization services.
*
* @return void
*/
protected function authorization()
{
$this->gate();
Telescope::auth(function ($request) {
if ($request->get('_token')) {
$user = PersonalAccessToken::findToken($request->get('_token'))->tokenable;
return $user->name === 'admin';
}
return Gate::check('viewTelescope', [$request]);
});
} |
My issue was mostly that I wasn't logged in, when i logged in I could then access the user param and that worked as expected. |
Hi guys, to all of you who come across this problem - I have been struggling with this for hours now and finally found the "solution" (aka easier fix to this instead of creating a whole new middleware etc.). The reason for this "issue" that we all had is because Laravel has some internal check whether this callback is supported for also work with guest-visitors (aka non-logged-in users). The default is (since it comes with the provider from telescope) that it does not support these guest users! To make it work, you need to change the code a tiny bit from protected function gate(): void
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
//
]);
});
} to this: protected function gate(): void
{
Gate::define('viewTelescope', function ($user = null) {
return in_array($user->email, [
//
]);
});
} The only change is that you have to add the default value The only thing you have to aware of is that the user object then is always null but you can still do things like: protected function gate(): void
{
Gate::define('viewTelescope', function ($user = null) {
return in_array(request()->ip(), ['123.123.123.123', ...]);
});
} |
laravel telescope is not working in my domain ip address.but all configuration is correctly.why ? i am using domain ip . |
i have made this
|
At first, i'd like to appreciate your efforts in producing such an amazing package.
I've updated the
Gate::define
method to return always trueNothing is being logged to telescope. telescope entries table is empty, although I made sure the all flags in
config/telescope
is set to true.Any clue where the problem could be ?
The text was updated successfully, but these errors were encountered: