first commit
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?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.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
// Telescope::night();
|
||||
|
||||
$this->hideSensitiveRequestDetails();
|
||||
|
||||
// Telescope::filter(function (IncomingEntry $entry) {
|
||||
// if ($this->app->environment('local')) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// return $entry->isReportableException() ||
|
||||
// $entry->isFailedRequest() ||
|
||||
// $entry->isFailedJob() ||
|
||||
// $entry->isScheduledTask() ||
|
||||
// $entry->hasMonitoredTag();
|
||||
// });
|
||||
|
||||
Telescope::tag(function (IncomingEntry $entry) {
|
||||
if ($entry->type === 'request') {
|
||||
return ['status:' . $entry->content['response_status']];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
Telescope::tag(function (IncomingEntry $entry) {
|
||||
if ($entry->type === 'request' && $entry->user?->mobile)
|
||||
return [$entry->user->mobile];
|
||||
if ($entry->type === 'request' && $entry->user?->email)
|
||||
return [$entry->user->email];
|
||||
});
|
||||
|
||||
Telescope::tag(function (IncomingEntry $entry) {
|
||||
if ($entry->type === 'request')
|
||||
return [$entry->content['ip_address']];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent sensitive request details from being logged by Telescope.
|
||||
*/
|
||||
protected function hideSensitiveRequestDetails(): void
|
||||
{
|
||||
if ($this->app->environment('local')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Telescope::hideRequestParameters(['_token']);
|
||||
|
||||
Telescope::hideRequestHeaders([
|
||||
'cookie',
|
||||
'x-csrf-token',
|
||||
'x-xsrf-token',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Telescope gate.
|
||||
*
|
||||
* This gate determines who can access Telescope in non-local environments.
|
||||
*/
|
||||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewTelescope', function ($user) {
|
||||
return true;
|
||||
// return in_array($user->email, [
|
||||
// //
|
||||
// ]);
|
||||
});
|
||||
}
|
||||
|
||||
protected function authorization()
|
||||
{
|
||||
$this->gate();
|
||||
|
||||
Telescope::auth(function ($request) {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user