0

Estoy teniendo un problema, estoy desarrollando una aplcacion de seguridad la cual funciona como gateway usa webflux security y envia peticiones a una api rest la cual funciona como resource server (oauth2) , el problema radica en que inyecto un filtro el cual recoje un token y luego lo envia mediante los headers asi ese token puede llegar al resource server, el problema es que al loggear los headers en el resource server se muestra que los headers vienen duplicados adjunto el filtro:

    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {

        return exchange.getPrincipal()
                .filter(principal -> principal instanceof Authentication)
                .map(Authentication.class::cast)
                .doOnNext(authentication -> {
                    if (authentication != null) {
                        String tokenDetails = TokenUtils.extractTokenDetails(authentication);
                        // Añadir el token a los encabezados de la solicitud saliente
                        ServerHttpRequest mutatedRequest = exchange.getRequest()
                                .mutate()
                                .header("superToken", tokenDetails)
                                .build();
                        exchange.mutate().request(mutatedRequest);
                    }
                })
                .then(chain.filter(exchange));

    } ```

y estos son los logs provenientes del resource server:
```Header:  cache-controlmax-age=0
Header:  upgrade-insecure-requests1
Header:  user-agentMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Header:  accepttext/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Header:  sec-fetch-sitecross-site
Header:  sec-fetch-modenavigate
Header:  sec-fetch-user?1
Header:  sec-fetch-destdocument
Header:  sec-ch-ua"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"
Header:  sec-ch-ua-mobile?0
Header:  sec-ch-ua-platform"Windows"
Header:  accept-encodinggzip, deflate, br
Header:  accept-languagees-ES,es;q=0.9
Header:  supertokeneyJraWQiOiI4ZTA5ODhmMC1iMjg4LTExZWUtODYyZi0zN2EwYTRmY2RjM2IiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGgucGluZ29uZS5jb20vMGM0OGJkYzgtODA1MC00OTVkLTg0M2QtYmYwZGY5NjcyZGVhL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A_QabGrUA1TDowFjmjIjNQy-5l0atwkBYtu7vVsyD2dvbLWQVQdjyMcPTL4NdTKEg8aA
Header:  forwardedproto=http;host="localhost:8090";for="[0:0:0:0:0:0:0:1]:51180"
Header:  x-forwarded-for0:0:0:0:0:0:0:1
Header:  x-forwarded-protohttp
Header:  x-forwarded-port8090
Header:  x-forwarded-hostlocalhost:8090
Header:  hostlocalhost:8080
Header:  content-length0
Header:  cache-controlmax-age=0
Header:  upgrade-insecure-requests1
Header:  user-agentMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Header:  accepttext/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Header:  sec-fetch-sitecross-site
Header:  sec-fetch-modenavigate
Header:  sec-fetch-user?1
Header:  sec-fetch-destdocument
Header:  sec-ch-ua"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"
Header:  sec-ch-ua-mobile?0
Header:  sec-ch-ua-platform"Windows"
Header:  accept-encodinggzip, deflate, br
Header:  accept-languagees-ES,es;q=0.9
Header:  supertokeneyJraWQiOiI4ZTA5ODhmMC1iMjg4LTExZWUtODYyZi0zN2EwYTRmY2RjM2IiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGgucGluZ29uZS5jb20vMGM0OGJkYzgtODA1MC00OTVkLTg0M2QtYmYwZGY5NjcyZGVhL2FzIiwic3ViIjoiNWMzOTAyOTMtYWYwZi00NzhlLTg5YmUtYzI5NDQ0NTI5NTk5IiwiYXVkIjoiMTM3NTQyMTItZDBmOC00YTQ3LWFiOGYtNGVlNjNlYzZjNmYyIiwiaWF0IjoxNzA3NDA2OTI2LCJleHAiOjE3MDc0MTA1MjYsImFjciI6IlNpbmdsZV9GYWN0b3IiLCJhbXIiOlsicHdkIl0sImF1dGhfdGltZSI6MTcwNzQwMzQ1MiwiYXRfa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Zi00ZWU2M2VjNmM2ZjIiLCJpc3MiOiJodHRwczovL2F1dGgucGluZ29uZS5jb20vMGM0OGJkYzgtODA1MC00OTVkLTg0M2QtYmYwZGY5NjcyZGVhL2FzIiwiaWF0IjoxNzA3NDA2OTI2LCJleHAiOjE3MDc0MTA1MjYsImF1ZCI6WyJodHRwczovL2FwaS5waW5nb25lLmNvbSJdLCJzY29wZSI6ImFkZHJlc3MgcGhvbmUgb3BlbmlkIHByb2ZpbGUgZW1haWwgcDE6cmVzZXQ6dXNlclBhc3N3b3JkIiwic3ViIjoiNWMzOTAyOTMtYWYwZi00NzhlLTg5YmUtYzI5NDQ0NTI5NTk5Iiwic2lkIjoiZjRlMTBjZGUtNzA3MC00MDQyLWE4NWUtZGJhODE5MjJkZDlhIiwiZW52IjoiMGM0OGJkYzgtODA1MC00OTVkLTg0M2QtYmYwZGY5NjcyZGVhIiwib3JnIjoiYzAzZTgzOGQtY2RlMC00ZWRhLWI0MzYtNGVlMzVjMTczNDdlIn0.DzgajPezQeJEW0g1qSZdBc8VR8OgQNZ1uVgNYs3iCABYYOThlDbqt5vK6TvcNkOzqnA8kxzG4z8iD0EDBTnbP34-ZFmQpIVDjpYaMsuewrTza9o7HVlPMyRDtpUthtr2HWzW_m72sGy2ylugV35OdONGAtHzYjEXpCqEtwc3_zGZSp79rkHWYfffHEvUzmKmj3ysEoQXr9593EbMMk45Z-qrxydBwKDAibsICDLDkgBRPJ0uiOr8osVQCgrEoLq8xRKCn3U3_vXMqjq8fmA_QabGrUA1TDowFjmjIjNQy-5l0atwkBYtu7vVsyD2dvbLWQVQdjyMcPTL4NdTKEg8aA
Header:  forwardedproto=http;host="localhost:8090";for="[0:0:0:0:0:0:0:1]:51180"
Header:  x-forwarded-for0:0:0:0:0:0:0:1
Header:  x-forwarded-protohttp
Header:  x-forwarded-port8090
Header:  x-forwarded-hostlocalhost:8090
Header:  hostlocalhost:8080
Header:  content-length0```

como se puede ver los logs estan duplicados

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.