Giter Club home page Giter Club logo

Comments (7)

lukasniemeier-zalando avatar lukasniemeier-zalando commented on May 20, 2024

Maybe we just add a note in the README that error dispatch should not be used in such cases (or "must be handled by the dev").

We should still do the logging in a try-finally.

from logbook.

whiskeysierra avatar whiskeysierra commented on May 20, 2024
  • discourage use of ERROR dispatch in README
  • remove ERROR dispatch from examples
  • remove ERROR dispatch from Auto Configuration
  • log responses in authorized filter in a try-finally block
  • treat exceptions during chain execution in unauthorized filter as unauthorized requests (as long as the second filter didn't log them already? @lukasniemeier)
  • switch to jetty-based tests for logbook-servlet

from logbook.

lukasniemeier avatar lukasniemeier commented on May 20, 2024

as long as the second filter didn't log them already?

I am trying to identify the scenario: something after the authorized filter throws an exception, the authorized filter logs the response (bullet point 4), now the unauthorized filter would log the response again (due to the exception-as-unauthorized semantic). Correct?

If we would want to prevent such scenario the two filters would need to be linked somehow, so that the unauthorized filter knows to be silent. Is this something special for this two-filter-security setup?

from logbook.

whiskeysierra avatar whiskeysierra commented on May 20, 2024

I am trying to identify the scenario: something after the authorized filter throws an exception, the authorized filter logs the response (bullet point 4), now the unauthorized filter would log the response again (due to the exception-as-unauthorized semantic). Correct?

Correct.

If we would want to prevent such scenario the two filters would need to be linked somehow, so that the unauthorized filter knows to be silent.

Exactly.

Is this something special for this two-filter-security setup?

Yes, I think it would only apply in that case.

Communication between the filters can be done using request attributes.

from logbook.

lukasniemeier-zalando avatar lukasniemeier-zalando commented on May 20, 2024

Working on

  • log responses in authorized filter in a try-finally block
  • treat exceptions during chain execution in unauthorized filter as unauthorized requests (as long as the second filter didn't log them already)

in https://github.com/lukasniemeier-zalando/logbook/tree/log-despite-exception

from logbook.

lukasniemeier-zalando avatar lukasniemeier-zalando commented on May 20, 2024

After looking into this again I think we should not continue with the proposed change to always log responses in the authorized filter.

If there is a chain exception the state of the response that the filter will capture may not represent what is actually returned to the client. Other filters or the servlet container may decide to output something else. This is for example the case if you use Undertow and deactivate the error chain completely. Logbook would log an empty 200 response despite the client would actually receive a 500 (written by Undertow itself).

  • If there is an exception after the authorized filter Logbook would log the request but no response. In the end users would need to leverage the logging of the container to see what is going on.
  • If there is an exception before the authorized filter we could stick with the change of the unauthorized filter (exception as unauthorized) - Logbook would log a partial log.
  • If there is an exception before the unauthorized filter... 😉

Therefore I am proposing to just implement the exception-as-unauthorized semantic.

from logbook.

whiskeysierra avatar whiskeysierra commented on May 20, 2024

Therefore I am proposing to just implement the exception-as-unauthorized semantic.

Agreed.

from logbook.

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.