Skip to content

Instantly share code, notes, and snippets.

View rabzu's full-sized avatar
🤺
Compiling...

rabzu rabzu

🤺
Compiling...
View GitHub Profile
@daniel-shuy
daniel-shuy / KeycloakAuthorization.scala
Last active February 11, 2022 17:56
Akka HTTP (Scala) Keycloak token verifier
import akka.actor.ActorSystem
import akka.dispatch.MessageDispatcher
import akka.event.LoggingAdapter
import akka.http.scaladsl.model.headers.{Authorization, OAuth2BearerToken}
import akka.http.scaladsl.server.Directives.{optionalCookie, optionalHeaderValueByType, provide, reject}
import akka.http.scaladsl.server.{AuthorizationFailedRejection, Directive1, Directives}
import org.keycloak.adapters.KeycloakDeployment
import org.keycloak.adapters.rotation.AdapterTokenVerifier
import org.keycloak.representations.AccessToken

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.