FireDevOps FireMUD & Ops Projects

๐Ÿ” FireMUD System Architecture: Authentication & Authorization

This document describes how FireMUD authenticates clients, issues internal JWTs, manages session state, and enforces role-based access across services.

Authentication is performed via plaintext LOGIN commands. Clients are stateless; session state is managed server-side in Redis and restored via the Game Session Service.


๐Ÿ” Login and Session Flow

All clients โ€” whether connecting via Telnet or WebSocket โ€” must authenticate using the LOGIN command:

Clients must re-authenticate only after disconnecting (TCP or WebSocket loss). If a valid Redis session exists (accountId + playerId), the Game Session Service resumes gameplay seamlessly.

๐Ÿ”— For session resumption and reconnect edge cases, see Reconnection Strategy


๐Ÿ‘ฅ Multi-Client Behavior and Session Takeover

Each character can only be controlled by one session at a time.

If a new login is received for the same playerId:

This enables:

๐Ÿ”’ All session rebinding is enforced by the Game Session Service using Redis locks. ๐Ÿ”— See Redis Session Keys


๐Ÿงพ JWT Format and Role Claims

Internal JWTs are issued by the Account Service and used for backend gRPC authorization. Gameplay clients never store or transmit tokens. Admin UIs may supply JWTs for optional validation at the Spring Cloud Gateway.

๐Ÿง  Claims

FieldDescription
accountIdIdentity of the authenticated account
globalRolesCross-game privileges (e.g., platformAdmin, moderator)
scopedRolesMap of gameId โ†’ roles (e.g., "game-abc": ["admin", "designer"])

๐Ÿงพ Example JWT Payload

Tokens are short-lived and internal only. Gameplay context (e.g., playerId, worldId) is stored in Redis and sent via command envelopes.


๐Ÿ‘ฎ Role-Based Authorization

Access to services is governed by roles from the JWT:

ContextDescription
globalRolesPlatform-wide access (e.g., moderation, admin dashboards)
scopedRolesPer-game access (e.g., designer tools, admin features for a game)

JWT Usage Scope


๐Ÿ”„ Mid-Session Role Updates

If roles change during an active session (e.g., a player is promoted to admin):

  1. The Game Session Service detects or requests a role refresh
  2. It contacts the Account Service to obtain a new JWT
  3. Updated claims are injected into subsequent gRPC calls

โœ… This process is invisible to the client โ€” no re-login is needed.


๐Ÿง  Session and Identity Management

The Game Session Service is responsible for:

๐Ÿ”— See Session Keys and Gameplay Binding for Redis structure and gameplay rebinding.


โœ… Summary

TopicDescription
Auth CommandLOGIN (or LOGON) โ€” supports prompt or argument input
JWT UsageInternal-only for backend gRPC auth
ClaimsaccountId, globalRoles[], scopedRoles{}
Session StateStored in Redis; bound to socket by Game Session Service
ReauthenticationRequired after disconnect; resumes via Redis if valid
Role EnforcementMeta/control services only; gameplay services trust Game Session Service
Role UpdatesRefreshed in-session; no client interaction needed
Multi-Client BehaviorOne session per character; new login replaces old session