Support JWT
This commit is contained in:
parent
25318cd6de
commit
aa9d60e4d1
9 changed files with 96 additions and 19 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue