spring-projects / spring-projects/spring-security

Example for customising AuthenticationEventPublisher does not work

Open
#16,866 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Describe the bug
https://docs.spring.io/spring-security/reference/6.4/servlet/authentication/events.html has the following example:

DefaultAuthenticationEventPublisher authenticationEventPublisher =
        new DefaultAuthenticationEventPublisher(applicationEventPublisher);
authenticationEventPublisher.setDefaultAuthenticationFailureEvent
        (AbstractAuthenticationFailureEvent.class);

This does not work, as AbstractAuthenticationFailureEvent is abstract, and attempting to call its constructor throws an InstantiationException, which is silently ignored.

To Reproduce
Follow the directions given in the documentation.

Expected behavior
All authentication exceptions are resolved to a failure event, even if not individually registered.

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 with the authentication events documentation page and the DefaultAuthenticationEventPublisher example described in the issue. Check how the default authentication failure event is instantiated and how AbstractAuthenticationFailureEvent is handled. Done means the documented example works and unregistered authentication exceptions resolve to a failure event without an instantiation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, documentation, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.