首页 > 解决方案 > 如何使用 keycloak 保护 http4s webapp?

问题描述

我想用 Keycloak 保护我的基于 Http4s 的 webapp,这在https://www.keycloak.org/docs/latest/securing_apps/index.html#_jetty9_adapter中有描述。

如代码片段所示,http4s webapp 在 Jetty 上运行

object UserSvcServer {

  def stream[F[_]: ConcurrentEffect](implicit T: Timer[F], C: ContextShift[F]): Stream[F, Nothing] = {

    val helloWorldAlg = HelloWorld.impl[F]
    val httpApp = (
      UserSvcRoutes.helloWorldRoutes[F](helloWorldAlg)
      ).orNotFound

    val finalHttpApp = Logger.httpApp(true, true)(httpApp)

    for {

      exitCode <- JettyBuilder[F]
        .bindHttp(8080, "0.0.0.0")
        .mountHttpApp(finalHttpApp, "/")
        .serve
    } yield exitCode
  }.drain

}  

而且我不必从https://www.eclipse.org/jetty/下载码头容器。

有没有办法使用 Keycloak 码头适配器保护基于 Http4s 的 webapp?

标签: scalajettyjetty-9http4s

解决方案


推荐阅读