Micronaut's netty server http request missing headers

460 Views Asked by At

I'm trying to integrate custom authentication service with micronaut security and to do this I've implemented my own AuthenticationProvider and that works fine for basic auth, however I also need to take care of authentication tokens passed in the request.

To do this I'm trying to implement my own AuthenticationFetcher and in the fetchAuthentication method I'm trying to get my custom authentication header and then authenticate the request.

  @Override
    public Publisher<Authentication> fetchAuthentication(HttpRequest<?> request) {
        if (request.getHeaders().get(authConfiguration.getTokenHeader()) != null) {

The issue I'm having is that netty's request.getHeaders() doesn't return all headers that are being sent to the webservice (I confirmed from my browsers developer console)

GET /service/all HTTP/1.1
Accept: application/json, text/plain, */*
Cookie: m=2258:Z3Vlc3Q6Z3Vlc3Q%253D
Accept-Encoding: gzip, deflate
Host: localhost:4200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Safari/605.1.15
Accept-Language: pl-pl
Referer: http://localhost:4200/campaigns
Connection: keep-alive
X-Token: my.token.here

headers visible in webservice

And here are my app settings

micronaut:
  server:
    netty:
      maxHeaderSize: 1024
      worker:
        threads: 4
      parent:
        threads: 4
      childOptions:
        autoRead: true
  application:
    name: appName

Any feedback appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

It was caused by cors config:

micronaut:
  server:
    cors:
      enabled: true

After adding this my request header was removed in the filter chains.