mardi 17 mars 2020

Laravel Telescope - 403 Forbidden

I have implemented Laravel Telescope and I can only acces if APP_ENV=local

I have followed Laravel's documentation and I changed code in TelescopeServiceProvider.php (take in care that my evironments are called loca, dev, testing and prod).

The only way I can access Telescope is changing APP_ENV=local in each enviroment.

Does anyone knows which can be by issue?

Regards

<?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();

        $this->hideSensitiveRequestDetails();

        Telescope::filter(function (IncomingEntry $entry) {
            if ($this->app->environment('local') || $this->app->environment('dev') || $this->app->environment('test') || $this->app->environment('prod')) {
                return true;
            }


            return $entry->isReportableException() ||
                   $entry->isFailedRequest() ||
                   $entry->isFailedJob() ||
                   $entry->isScheduledTask() ||
                   $entry->hasMonitoredTag();
        });
    }

    /**
     * Prevent sensitive request details from being logged by Telescope.
     *
     * @return void
     */
    protected function hideSensitiveRequestDetails()
    {
        if ($this->app->environment('local') || $this->app->environment('dev') || $this->app->environment('test') || $this->app->environment('prod')) {
            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.
     *
     * @return void
     */
    protected function gate()
    {
        Gate::define('viewTelescope', function ($user) {
            return in_array($user->email, [
                //
            ]);
        });
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire