HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter)

Tracker6 months ago

Greetings. Could anyone guide me how to solve this problem? This happens when deleting a user.
There are no errors in the logs.ser.
I saw something in a topic but in the version 5.9 code this implementation already exists.

Thank you in advance, have a great day everyone!

Correção
https://github.com/traccar/traccar-web/commit/47ffffb6f90bfd9a8aaae1fd696d588c175c94a6

Error

HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:128 < ... < OverrideFilter:49 < ...) 

Log's

2023-11-08 18:50:19  INFO: Health check enabled with period 480000
2023-11-08 18:52:05  INFO: user: 0, action: create, object: user, id: 1
2023-11-08 18:52:12  INFO: user: 1, action: login, from: 192.168.1.67
2023-11-08 18:52:22  INFO: user: 1, action: create, object: user, id: 2
2023-11-08 18:52:27  INFO: user: 1, action: remove, object: user, id: 2
Anton Tananaev6 months ago

This issue is already fixed on master.

Tracker6 months ago

Without wanting to abuse Anton, could you tell me if it was on the Web or server? On the server I commented these lines in the OverrideFilter.java file and the error stopped.
Thanks.
Commented code

if (((HttpServletRequest) request).getServletPath().startsWith("/api")) {
            chain.doFilter(request, response);
            return;
}
 @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {

       /* if (((HttpServletRequest) request).getServletPath().startsWith("/api")) {
            chain.doFilter(request, response);
            return;
        }*/

        ResponseWrapper wrappedResponse = new ResponseWrapper((HttpServletResponse) response);

        chain.doFilter(request, wrappedResponse);

        byte[] bytes = wrappedResponse.getCapture();
        if (bytes != null) {
            if (wrappedResponse.getContentType() != null && wrappedResponse.getContentType().contains("text/html")
                    || ((HttpServletRequest) request).getPathInfo().endsWith("manifest.webmanifest")) {

                Server server;
                try {
                    server = permissionsServiceProvider.get().getServer();
                } catch (StorageException e) {
                    throw new RuntimeException(e);
                }

                String title = server.getString("title", "Traccar");
                String description = server.getString("description", "Traccar GPS Tracking System");
                String colorPrimary = server.getString("colorPrimary", "#1a237e");

                String alteredContent = new String(wrappedResponse.getCapture())
                        .replace("${title}", title)
                        .replace("${description}", description)
                        .replace("${colorPrimary}", colorPrimary);

                response.setContentLength(alteredContent.length());
                response.getOutputStream().write(alteredContent.getBytes());

            } else {
                response.getOutputStream().write(bytes);
            }
        }
    }
Tracker6 months ago

I apologize Anton, it was not resolved by commenting on the lines mentioned above, after deleting, I went to navigate to another page and was logged out again. I thought it was important to add so that other users don't think it's the solution.

Anton Tananaev6 months ago

Look through git history.

Tracker6 months ago

Anton, I didn't find it in the history, please could you at least give a date, last week, last month. I downloaded the front directly from the master and the error still persists, the UpdateController.tsx file.
https://github.com/traccar/traccar-web/commit/85d5322a78332175fd870e588469fc9653fa8257

Anton Tananaev6 months ago
Tracker6 months ago

Thank you very much Anton.

Tracker6 months ago

It worked perfectly Anton. Thanks!