spring-projects / spring-projects/spring-boot

AuthorizationAuditListener.onAuthorizationFailureEvent() should store accessed resource into event data

Open
#10,104 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Hello, this is an enhancement request for actuator security audit.

Currently, when an access is denied for a REST endpoint, AuthorizationAuditListener publishes an AuditEvent with timestamp, principal, type and data map which stores a subset of the original event data: exception class, exception message, authentication details.

I think this data map should also contains the URI of the resource that was access denied which can be extracted from event.getSource().

        Object source = event.getSource();
        if (source instanceof FilterInvocation) {
            String requestUrl = ((FilterInvocation) source).getRequestUrl();
            data.put("url", requestUrl);
        }

While it is relatively easy to extend AuthorizationAuditListener to add this data, it seems to be a common use case that could be part of the default implementation.

Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/security/AuthorizationAuditListener.java and inspect onAuthorizationFailureEvent(). Follow event.getSource() and FilterInvocation.getRequestUrl(); done means the published AuditEvent data includes the denied resource URI alongside the existing fields. The issue does not name a test, so locate the listener's existing coverage before changing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
security
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.