Support JWT

This commit is contained in:
Paul-Henri Froidmont 2025-11-04 13:42:19 +01:00
parent 25318cd6de
commit aa9d60e4d1
Signed by: phfroidmont
GPG key ID: BE948AFD7E7873BE
9 changed files with 96 additions and 19 deletions

View file

@ -16,6 +16,8 @@ import zio.logging.LogFormat.*
import zio.logging.consoleLogger
import zio.schema.codec.JsonCodec.ExplicitConfig
import lu.foyer.auth.AuthMiddleware.jwtAuthentication
import lu.foyer.auth.JwtScalaTokenService
import lu.foyer.clients.*
import lu.foyer.contracts.*
@ -29,6 +31,7 @@ object HttpServer:
contract <- ZIO.service[ContractController]
openAPI = OpenAPIGen.fromEndpoints(client.endpoints ++ contract.endpoints)
yield (client.routes ++ contract.routes)
@@ jwtAuthentication("Insurance")
@@ cors(corsConfig) @@ Middleware.debug
++ SwaggerUI.routes("docs" / "openapi", openAPI)
@ -52,10 +55,12 @@ object App extends ZIOAppDefault:
val app =
for
routes <- HttpServer.routes
server <- Server.serve(routes).provide(Server.default)
server <- Server.serve(routes)
yield server
override def run = app.provide(
Server.default,
JwtScalaTokenService.live,
CommandEngine.layer[ClientCommand, ClientEvent, ClientState],
CommandEngine.layer[ContractCommand, ContractEvent, ContractState],
ClientHandlers.layer,