Skip to main content

JWT logo

For custom authentication implementations Idem supports JWT tokens as an authentication method.

Game client implementation

Opening the websocket

For authorization via a custom JWT, the request to open the websocket connection from your game client must include an authorization parameter using the following format:

CustomJWT <jwt>

The JWT must contain the desired playerId for the player as a claim called playerId.

This replaces the default value Demo described in the Setting up player based article.

The JWT must be signed with the secret_key for the game_mode the player should be authorized for. To configure custom JWT authentication and get a secret_key for your game_mode/s, please reach out to match@idem.gg. They ability to do so yourself will be added to the Idem console for self-service soon.

Overall, this leads to the following URL and parameters for the WebSocket:

URL = WEBSOCKET_API_URL/?playerId=PLAYER_ID&code=JOIN_CODE&authorization=AUTHORIZATION
  • WEBSOCKET_API_URL: The base URL for websocket connections, e.g. wss://ws.sandbox-1.idem.gg (see websocket for more info)
  • PLAYER_ID: Steam ID of the player signed in to Steam on the client
  • JOIN_CODE: Idem join code for the game mode (see Setting up player based)
  • AUTHORIZATION: CustomJWT <jwt> (Note the whitespace in the middle)

Behavior

Once player authorization via a custom JWT is configured, Idem will try to decode the JWT whenever a client tries to open up a new websocket connection. The connection will be rejected with a 403 error, if the JWT token can not be decoded, the JWT does not contain a playerId or no JWT token was provided in the authorization parameter at all.

If the validation is successful, Idem will accept the websocket connection request. After that, Idem will check for each addPlayer request, that the playerId submitted is equivalent to the playerId retrieved via the auth token. If this is not the case, Idem will reject the addPlayer request.