What specific request are you looking for? Not every event will have a 1-1 relationship with an HTTP request. If, for example, it’s something that happens in the authentication flow, you could build a custom authenticator that would store the request for you.
I just need it for the admin REST calls events, so I think it will be 1-1 relationship with HTTP. I’m using a service account to call the REST API to have more fine grain control on what can be done and I need to pass header with extra context (real user behind the call, for e.g.). I wanted a simple solution, like @WebFilter or even a JAX-RS PreMatching Filters, but I see no way to register them via an extension. Any suggestion?
I am not familiar with adding filters to the admin resources, but it may be possible. Here or the keycloak-dev mailing list are likely the best places to ask.
There are many ways to register the custom filter, in my example I use a RealmResourceProviderFactory that just returns an empty resource. It would really be helpful if Keycloak had something like a BootstrapSpi that would allow you to register callbacks to register things like Request/Response filters or perform other types of server customization.
If you need to process also non API requests, then you could either try to add your filter directly in the KeycloakApplication or create an Undertow filter and propagate additional data via request attributes.
How can I register the filter in the KeycloakApplication? I’m using Keycloak version 23.0.4 and would like to intercept the Authenticator requests… Is it possible to override the KeycloakApplication? Because when I try to override it I get an error from Quarkus about not being able to handle multiple applications. Is there another way to register the filter?