Skip to content

Commit

Permalink
add usage example for #2074
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Jan 22, 2025
1 parent aec33a1 commit 9599a96
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions otoroshi/app/next/extensions/example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package otoroshi.next.extensions
import akka.actor.ActorSystem
import akka.stream.Materializer
import akka.util.ByteString
import com.nimbusds.jose.jwk.Curve
import com.nimbusds.jose.jwk.gen.OctetKeyPairGenerator
import otoroshi.api._
import otoroshi.cluster.ClusterMode
import otoroshi.env.Env
Expand Down Expand Up @@ -232,6 +234,18 @@ class FooAdminExtension(val env: Env) extends AdminExtension {
}
}

override def publicKeys(): Seq[PublicKeyJwk] = {
val jwk = new OctetKeyPairGenerator(Curve.Ed25519).keyID("fake-key").generate
val publicJWK = jwk.toPublicJWK.toJSONString.parseJson
Seq(PublicKeyJwk(publicJWK))
// Seq(PublicKeyJwk(Json.obj(
// "kty" -> "OKP",
// "crv" -> "Ed25519",
// "kid" -> "123",
// "x" -> "sO3w8_ow469Fu7vuNEssGLC-06fz8iRRjOJN_au6vug"
// )))
}

override def frontendExtensions(): Seq[AdminExtensionFrontendExtension] = {
Seq(
AdminExtensionFrontendExtension("/__otoroshi_assets/javascripts/extensions/foos.js")
Expand Down
2 changes: 1 addition & 1 deletion otoroshi/app/plugins/apikeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ class ClientCredentialService extends RequestSink {
): Future[Result] = {
JWKSHelper.jwks(ctx.request, conf.defaultKeyPair.some.toSeq).map {
case Left(body) => Results.NotFound(body)
case Right(body) => Results.Ok(body)
case Right(keys) => Results.Ok(Json.obj("keys" -> JsArray(keys)))
}
}

Expand Down
1 change: 1 addition & 0 deletions otoroshi/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ libraryDependencies ++= Seq(
"com.nixxcode.jvmbrotli" % "jvmbrotli" % "0.2.0",
"io.azam.ulidj" % "ulidj" % "1.0.4",
"fr.maif" %% "wasm4s" % "3.7.0" classifier "bundle",
"com.google.crypto.tink" % "tink" % "1.16.0",
// included in libs as jitpack is not stable at all
// "com.github.Opetushallitus" % "scala-schema" % "2.34.0_2.12" excludeAll (
// ExclusionRule("com.github.spotbugs", "spotbugs-annotations"),
Expand Down

0 comments on commit 9599a96

Please sign in to comment.