diff options
Diffstat (limited to 'src/main/scala/xyz/driver/core/app/DriverApp.scala')
-rw-r--r-- | src/main/scala/xyz/driver/core/app/DriverApp.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/core/app/DriverApp.scala b/src/main/scala/xyz/driver/core/app/DriverApp.scala index bf18c3d..56ee898 100644 --- a/src/main/scala/xyz/driver/core/app/DriverApp.scala +++ b/src/main/scala/xyz/driver/core/app/DriverApp.scala @@ -127,7 +127,7 @@ class DriverApp( val combinedRoute = Route.seal(modules.map(_.route).foldLeft(basicRoutes.routeWithDefaults)(_ ~ _) ~ defaultOptionsRoute) - (extractHost & extractClientIP & trace(tracer)) { + (extractHost & extractClientIP & trace(tracer) & handleRejections(authenticationRejectionHandler)) { case (origin, ip) => ctx => val trackingId = extractTrackingId(ctx.request) @@ -153,6 +153,15 @@ class DriverApp( } } + protected def authenticationRejectionHandler: RejectionHandler = + RejectionHandler + .newBuilder() + .handle { + case AuthenticationFailedRejection(_, challenge) => + complete(HttpResponse(StatusCodes.Unauthorized, entity = challenge.realm)) + } + .result() + protected def bindHttp(modules: Seq[Module]): Unit = { val _ = http.bindAndHandle(route2HandlerFlow(appRoute), interface, port)(materializer) } |