Skip to content

Commit

Permalink
Fix signer not found
Browse files Browse the repository at this point in the history
  • Loading branch information
AminArria committed Jun 5, 2024
1 parent b213941 commit eaf81d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/arena/lib/arena/authentication/gateway_token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion apps/arena/lib/arena/socket_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
Expand Down

0 comments on commit eaf81d2

Please sign in to comment.