Complete Game User Login Flow
Minigames can quickly and conveniently obtain the user identity through the login capability provided by SUD OpenPaaS, and build a user system within the minigame.
1. Architecture Overview and Participating Roles
This flow describes how, when a user opens a game within the app, the game client completes identity authentication through the SUD platform and establishes a secure custom login state on the game server. At the same time, this flow is also responsible for generating the underlying session key (sessionKey) used for subsequent data encryption.
- APP: the app client
- SUD OP: the communication middleware (SDK) integrated into the client
- Game: the game client
- Game SVR: the game server
- SUD OP SVR: the SUD server (the core hub for authentication and account system management)
- APP SVR: the app server (note: it does not directly participate in the interaction in this login flow)
2. Interaction Sequence Diagram
3. Key Step Descriptions
The entire login authorization flow can be broken down into two core phases: the client obtaining the credential and the server exchanging for the session.
Phase 1: The client obtains the login credential Code
- Trigger login: The
Gameclient callsSUD OPto initiate alogin()request. - Extract identity:
SUD OPinitiates the callback onGetLegacyUserIdentity() to theAPP, requesting the app to provide the current user's original identity information. - Return identity information: The
APPreturns the local identityuserIdentitytoSUD OP. - Request authorization code:
SUD OPcarriesaccessToken,userToken(the in-platform user identifier),gameID, and theuserIdentityjust obtained, and initiates agetGameCodenetwork request toSUD OP SVR. - Platform internal state generation (key action): After receiving the request,
SUD OP SVRperforms a series of core state-generation actions internally on the server:generateCode(): generates a one-time short-lived authorization codecodebound to this login action.generateOpenID(gameID): generates the user's unique isolated identifieropenIDwithin this game based on the game ID.generateUnionID(appGroupID): generates a unified identifierunionIDthat connects multiple apps under the same developer entity.
- Issue authorization code:
SUD OP SVRreturns the generatedcodeto the client'sSUD OP. - Pass through to the game:
SUD OPresponds with thecodeto theGameclient.
Phase 2: The server exchanges for the session and key
- Game server verification: After the
Gameclient obtains thecode, it calls its own game server's authentication interfacelogin(code)to request establishing the game login state. - S2S credential exchange: The
Game SVR, as the trusted backend, carries the receivedcode, the game app'sgameID, andgameSecret(the app secret), and initiates the server-side S2S requestcode2sessiontoSUD OP SVR. - Generate the core session key (key action): After
SUD OP SVRverifies that thecodeandgameSecretare valid, it internally callsgenerateSessionKeyto generate the symmetric keysession_keyused for data encryption. - Issue account data and key:
SUD OP SVRresponds to theGame SVRwith the generatedsession_key, together with the account system identifiers generated in the previous step (openID,unionID,resUniqueID). - Establish the custom login state: The
Game SVRsaves the user'ssession_keyand various IDs in its own database, generates the game's own business session (game custom session/ Token), and returns it to theGameclient. At this point, the login loop is complete.
4. Architecture Context and Data Flow Statement
- Isolation and security design:
- The SUD platform, by issuing
openIDandunionID, achieves data isolation and mapping between different games, and between games and the app. - The
session_keyonly circulates between the two trusted servers,SUD OP SVRandGame SVR, and is never exposed to theGameclient or theAPPclient, ensuring absolute security when subsequently encrypting sensitive information based on this key.
- The SUD platform, by issuing
