0

My app gets deployed to customer sites. Some customers have proxies that perform authentication of users then forward a particular HTTP cookie/header. These can be of custom format. I want to be able to provide one micronaut URL e.g. /customAuth That a customer can provide an override for Allowing them to forward the request from their proxy and handle it themselves.

Unfortunately this is proving very hard in micronaut as:

  1. It inists I specify @Post/@Get or what the HTTP method should be.
  2. It parses the headers/body before forwarding.

What I really need is:

@All(/customAuth) HttpResponse customAuth(String fullRawHttpRequestWithHeaders) {

I've seen this question on raaw body (Get raw HttpRequest body in Micronaut). I share their problem that I don't even know if there will be a body.

I've seen this question on getting headers: How to get full list of request headers in Micronaut

It seems micronaut really just does NOT want to give raw access which is what some people really need, e.g. in my case.

Is this the case?

Ryan Hamilton
  • 2,601
  • 16
  • 17
  • Are you asking how to map all requests to a certain URI to a particular controller method and not having to specify which http methods are applicable, or are you asking how to get a reference to the HTTP request, or are you asking something else? – Jeff Scott Brown Nov 11 '22 at 15:28
  • "Are you asking how to map all requests to a certain URI to a particular controller method and not having to specify which http methods are applicable," Yes. That plus how to get the whole HTTP request as a string. – Ryan Hamilton Nov 15 '22 at 13:19
  • I don't think we have support for doing exactly that. You could address some of it by implementing an HTTP filter. – Jeff Scott Brown Nov 15 '22 at 13:53

1 Answers1

0

One solution would be to recreate the raaw requests as best as possible .e.g

    StringBuilder ms = new StringBuilder();
    // add cookies
    Map<String, Cookie> m = req.getCookies().asMap();
    m.forEach((t, u) -> ms.append(t + ":" + u.getValue()));
        
    // add headers
    req.getHeaders().asMap().entrySet().
    .. add body

This seems a huge waste of effort, inefficient and likely to go wrong.

Ryan Hamilton
  • 2,601
  • 16
  • 17
  • "One solution would be to recreate the raaw requests as best as possible" - The code in this answer does not look like it is recreating any request. – Jeff Scott Brown Nov 11 '22 at 15:29