Skip to content

Forward request information to Acceptor#accept (to get the client ip) #231

@mihai1voicescu

Description

@mihai1voicescu

Forward the request information of Ktor to the Acceptor#accept method so we can see the request headers, IP, and other request details.

Motivation

Determining the IP of the client is impossible now. You can make some hacks to determine it with some degree of certainty but it's not enough. Having access to the ApplicationRequest allows us to access the origin IP and the headers (in case we are behind load balancers).

Desired solution

Forward the ApplicationRequest of Ktor to the Acceptor#accept method.

Considered alternatives

  1. Have a special kind of Acceptor that we can use with Ktor HTTP and WebSockets.

  2. Forward the IP (but this is hard because of load balancers and proxies, usually needs to be done by a higher level with knowledge about the node architecture (eg: number of trusted proxies for x-forwarded-for)).

  3. Pass a "requestContext" map to the acceptor where we can store values regarding the request. Add a callback to Route.RSocket where we get the application context and we can build it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions