Add XForwardedHeaders plugin

This commit is contained in:
William Brawner 2024-04-21 10:02:45 -06:00
parent 22061e3f4a
commit e92ffd376a
2 changed files with 4 additions and 0 deletions

View file

@ -33,6 +33,7 @@ import io.ktor.server.mustache.*
import io.ktor.server.plugins.callloging.* import io.ktor.server.plugins.callloging.*
import io.ktor.server.plugins.contentnegotiation.* import io.ktor.server.plugins.contentnegotiation.*
import io.ktor.server.plugins.cors.routing.* import io.ktor.server.plugins.cors.routing.*
import io.ktor.server.plugins.forwardedheaders.*
import io.ktor.server.response.* import io.ktor.server.response.*
import io.ktor.server.sessions.* import io.ktor.server.sessions.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
@ -167,6 +168,7 @@ fun Application.moduleWithDependencies(
jobs: List<Job>, jobs: List<Job>,
sessionValidator: suspend ApplicationCall.(Session) -> Principal? sessionValidator: suspend ApplicationCall.(Session) -> Principal?
) { ) {
install(XForwardedHeaders)
install(CallLogging) install(CallLogging)
install(Authentication) { install(Authentication) {
session<Session> { session<Session> {

View file

@ -29,6 +29,7 @@ ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" } ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" }
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" } ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
ktor-server-cors = { module = "io.ktor:ktor-server-cors", version.ref = "ktor" } ktor-server-cors = { module = "io.ktor:ktor-server-cors", version.ref = "ktor" }
ktor-server-forwarded-headers = { module = "io.ktor:ktor-server-forwarded-header", version.ref = "ktor" }
ktor-server-mustache = { module = "io.ktor:ktor-server-mustache", version.ref = "ktor" } ktor-server-mustache = { module = "io.ktor:ktor-server-mustache", version.ref = "ktor" }
ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor" } ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor" }
ktor-server-test = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" } ktor-server-test = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
@ -44,6 +45,7 @@ ktor-server = [
"ktor-server-content-negotiation", "ktor-server-content-negotiation",
"ktor-server-core", "ktor-server-core",
"ktor-server-cors", "ktor-server-cors",
"ktor-server-forwarded-headers",
"ktor-server-sessions" "ktor-server-sessions"
] ]