Code Monkey home page Code Monkey logo

Comments (11)

arukompas avatar arukompas commented on June 10, 2024 2

hey all, thanks for bringing this up!

Starting with v3.3.0, Log Viewer will be unauthorized in production by default, if no gate or auth callback is set up.

from log-viewer.

samuelsih avatar samuelsih commented on June 10, 2024

I got this problem before. And after some try and error, i got this working by using the Gate like this.

Gate::define("viewLogViewer", fn () => auth()->user()->isAdmin());

instead of this

Gate::define('viewLogViewer', function (?User $user) {
        return $user->isAdmin();
});

I use the global helper instead of grab the user from the function parameter like in the documentation.

I hope it helps.

from log-viewer.

dev-mo-ali avatar dev-mo-ali commented on June 10, 2024

Hi
I would like to add extra thing here, our team have used Cloudflare to limit access to log-viewer url from whitelisted IPs only

from log-viewer.

zoispag avatar zoispag commented on June 10, 2024

I have been using a middleware since forever:

'middleware' => ['web', 'auth', 'role:support|superadmin'],

Now, this is no longer enough! Not great for a non major release.

from log-viewer.

arukompas avatar arukompas commented on June 10, 2024

I have been using a middleware since forever:

'middleware' => ['web', 'auth', 'role:support|superadmin'],

Now, this is no longer enough! Not great for a non major release.

Hey @zoispag , you're not using the \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer middleware, so I don't what exactly is blocking your access here 🤔

The change should only apply to the default installations where the above middleware is applied by default. If you're not using that middleware then you're responsible for the access to the Log Viewer - and looks like you did add it already.

So, it should be working for you just fine 🤔

from log-viewer.

zoispag avatar zoispag commented on June 10, 2024

It doesn't however. I get 403 when it tries to access the log files. Maybe a bug?

from log-viewer.

arukompas avatar arukompas commented on June 10, 2024

@zoispag , do you also use the same middleware in api_middleware configuration? Or maybe you're calling LogViewer::auth() somewhere else in the system?

from log-viewer.

arukompas avatar arukompas commented on June 10, 2024

hey @zoispag , try the new release, v3.3.1 which should fix the issue.

from log-viewer.

zoispag avatar zoispag commented on June 10, 2024

Hi @arukompas. My published config was apparently a very old one, with no api_middleware in place. So for the API only, it was using \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class which started failing. I updated the api_middleware to

'api_middleware' => [EnsureFrontendRequestsAreStateful::class, 'auth', 'role:support|superadmin'],

and now it works. Thanks for pointing me to the direction. Once I removed the AuthorizeLogViewer::class from the api_middleware array, I no longer need to create a Gate for the API to work.

from log-viewer.

zoispag avatar zoispag commented on June 10, 2024

By the way I would like to apologize for "bitching" earlier.
I had a very bad start of the day!

Apologies again and thanks for the quick reaction!! 💪🏼

from log-viewer.

arukompas avatar arukompas commented on June 10, 2024

@zoispag no worries at all, it kept me on my toes! :)

Enjoy the rest of the week 💪

from log-viewer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.