From eaf81d2cda5d2fe7d8c10a2c3d27907c164cc577 Mon Sep 17 00:00:00 2001 From: Amin Arria Date: Wed, 5 Jun 2024 20:38:11 +0200 Subject: [PATCH] Fix signer not found --- apps/arena/lib/arena/authentication/gateway_token.ex | 2 +- apps/arena/lib/arena/socket_handler.ex | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/arena/lib/arena/authentication/gateway_token.ex b/apps/arena/lib/arena/authentication/gateway_token.ex index cf0e702ca..151e90636 100644 --- a/apps/arena/lib/arena/authentication/gateway_token.ex +++ b/apps/arena/lib/arena/authentication/gateway_token.ex @@ -2,8 +2,8 @@ defmodule Arena.Authentication.GatewayToken do @moduledoc """ Module responsible to verify and validate the JWT emitted by gateway app. """ - alias Arena.Authentication.GatewaySigner use Joken.Config, default_signer: nil + alias Arena.Authentication.GatewaySigner @impl Joken.Config def token_config do diff --git a/apps/arena/lib/arena/socket_handler.ex b/apps/arena/lib/arena/socket_handler.ex index 6b88fff34..c2bb57101 100644 --- a/apps/arena/lib/arena/socket_handler.ex +++ b/apps/arena/lib/arena/socket_handler.ex @@ -3,6 +3,7 @@ defmodule Arena.SocketHandler do Module that handles cowboy websocket requests """ require Logger + alias Arena.Authentication.GatewaySigner alias Arena.Authentication.GatewayToken alias Arena.GameLauncher alias Arena.Serialization.GameState @@ -16,7 +17,8 @@ defmodule Arena.SocketHandler do @impl true def init(req, _opts) do [{"gateway_jwt", jwt}] = :cowboy_req.parse_qs(req) - {:ok, %{"sub" => user_id}} = GatewayToken.verify_and_validate(jwt) + signer = GatewaySigner.signer() + {:ok, %{"sub" => user_id}} = GatewayToken.verify_and_validate(jwt, signer) character_name = :cowboy_req.binding(:character_name, req) player_name = :cowboy_req.binding(:player_name, req) {:cowboy_websocket, req, %{client_id: user_id, character_name: character_name, player_name: player_name}}