jakartaee / jakartaee/authentication

Support for events

Open
#21 5 comments 0 reactions 2 assignees Claimed by @arjantijms View on GitHub
Priority: Major Type: New Feature
Dominant language
Java
Stars
27
Forks
35
PR merge metrics
No merged PRs in 30d

Description

For several use cases it would be quite convenient if JASPIC would throw events at several important moments of the authentication message exchange.

Such events could be:

* PreAuthenticate
* PostAuthenticate
* PreLogout
* PostLogout

User code could possibly register for such events in [the same way](https://javaee-spec.java.net/nonav/javadocs/javax/servlet/http/HttpSessionIdListener.html) such code can register for events from the Servlet container; annotating the listener class and implementing an interface.

E.g.

```
@SecurityListener
public class MyListener implements AuthenticationListener {

public void preAuthenticate(AuthEvent authEvent) {
// ...
}

public void postAuthenticate(AuthEvent authEvent) {
// ...
}
}
```

Additionally CDI style events can be supported as well.

Use cases for such event listeners are among others:

* Keeping track of the number of logged-in users
* Protecting against brute-force attacks by keeping count of failed login attempts for a certain account
* Creating a new local user after the first successful authentication via a remote authentication provider
* Loading application specific preferences into the HTTP session after a user logs-in

Specifically for the second use case a PreAutenticate listener should be able to veto the authentication attempt (at which JASPIC could respond by e.g. sending a 403 to the client).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.