elastic / elastic/apm-agent-java

user.name is always UUID when using OIDC and Spring Security

Open
#4,109 8 comments 0 reactions 0 assignees View on GitHub
agent-java community
Dominant language
Java
Stars
594
Forks
338
Avg merge
1d 13h
Merged PRs (30d)
25

Description

## Is your feature request related to a problem?

When using Spring Security oauth2 authentication to secure an API server, `user.name` in APM always shows the user ID (as it's the "name" of the Principal).

If a user describes an issue and I go into the APM service view to investigate, I don't typically have their UUID (and neither do they). I do however have their email (login) or preferred username, so I need to recover their UUID manually from Keycloak.

## Describe the solution you'd like

I'd like a different claim, in case of JWTs, to be logged instead of or in addition to the UUID. preferred_username is already mentioned in an Azure SSO fallback. Ideally, which claim is used would be configurable. Of course this is only valid for JWTs and similar tokens, which is my use case, so not entirely generic.

This may require going through the Spring MVC plugin instead of the Servlet one?

## Describe alternatives you've considered

Using MDC to get additional claims into the transaction data, but it doesn't fit well in the ECS schema and it requires adding code to every backend service.

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.