It would be nice if there was a sample on how to h...
# kotlinx-rpc
h
It would be nice if there was a sample on how to handle auth with kotlinx-rpc
plus1 2
m
Agreed. For what it's worth, I wrote down an approach when I experimented with a migration away from Wire before, maybe it'll provide some inspiration for you too. https://kotlinlang.slack.com/archives/C072YJ3Q91V/p1779981247863549?thread_ts=1779423476.511239&cid=C072YJ3Q91V
👍 1
a
We will have samples closer to time we promote the grpc from dev state For krpc - there are samples here, but we don't expect any official any time soon, as we have a rework process planned for it, which didn't yet start
👍 1
d
gRPC Free Pass the ApplicationCall/principal down to the RpcService constructor on server module (I suppose you already have installed Auth on your Ktor server, and you have some protected endpoints)
Copy code
fun Route.rpcRoute() {
 rpc("/krpc-route") {
  rpcConfig {
   serialization { json(get<Json>()); }
  }
  val currentPrincipal = call.principal<UserPrincipal>()
  registerService<KrpcRandomServiceImpl> { 
    KrpcRandomServiceImpl(currentPrincipal) 
  }
}
👍 1