<@UB61X37CY> the easiest thing is to just reimplem...
# http4k
d
@Xavier Hanin the easiest thing is to just reimplement the BearerAuth filter to stick the principal into the request context:
Copy code
val contexts = RequestContexts()

    val key = RequestContextKey.required<Credentials>(contexts)

    fun lookupCredentials(token: String): Credentials? = if (token == "Bearer: 42") Credentials("user", "pass") else null

    val app = ServerFilters.InitialiseRequestContext(contexts)
        .then(Filter { next ->
            { req ->
                req.header("Authorization")
                    ?.let(::lookupCredentials)
                    ?.let { next(req.with(key of it)) }
                    ?: Response(UNAUTHORIZED)
            }
        }).then { Response(OK).body(key(it).toString()) }