class OutboundProviderSync extends SynchronousProvider implements OutboundSecurityProvider {

    @Override
    protected OutboundSecurityResponse syncOutbound(ProviderRequest providerRequest,
                                                    SecurityEnvironment outboundEnv,
                                                    EndpointConfig outboundEndpointConfig) {

        // let's just add current user's id as a custom header, otherwise do nothing
        return providerRequest.securityContext()
                .user()
                .map(Subject::principal)
                .map(Principal::getName)
                .map(name -> OutboundSecurityResponse
                        .withHeaders(Map.of("X-AUTH-USER", List.of(name))))
                .orElse(OutboundSecurityResponse.abstain());
    }

}