https://kotlinlang.org logo
#spring
Title
j

Jonas Bark

08/07/2019, 10:56 AM
While digging deeper into Webflux, Coroutines and Spring Security I found that I can't access the ServerRequests pricinipal:
reqeust.awaitPrincipal()
always returns null. I'm using coRouter and all I do is:
Copy code
suspend fun categoriesGet(request: ServerRequest): ServerResponse {
       val principal = request.awaitPrincipal()
       println("PRINCIP: $principal")
}
when I use the standard-non-coroutine router I'm getting the expected result:
Copy code
fun hello(request: ServerRequest): Mono<ServerResponse> {
        return request.principal()
            .map { it.name }
            .flatMap { userName ->
                ok().contentType(MediaType.APPLICATION_JSON)
                    .syncBody("Hello $userName")
            }
    }
is this a bug?