跳到主要内容

game_server.game_auth

简介

基于engine层的游戏服务器认证模块

组件接口

game_auth.gs

将一个验证服务器账号认证成功后获得的token兑换成登录游戏服务器的的token

一些简单说明:

  1. 本模块是做为engine层LoginD认证模块的一种实现,为游戏服务器提供认证功能:
    1. 检查客户端提供的凭据,并兑换成游戏服务器的凭据
    2. 检查游戏服务器的凭据是否有效(阅后即焚或者可重复检查)
  2. 本模块默认行为的一些说明
    1. 默认接入authserver(可设置no_authserver屏蔽)
    2. 客户端默认的验证行为(可设置auth_func): 客户端提供账号和验证服务器token做为凭据,通过验证后兑换一个gs token
    3. 服务器默认的验证行为(可设置check_auth_func): 提供服务器token以及待验证数据进行验证
    4. 默认gs token生成为new_guid(可设置token_func)
    5. gs token默认超时为180秒
    6. 默认token数量超过10000个启动超时回收,回收检查间隔为30秒
  3. 本模块需要调用setup()函数设置初始化
函数原型函数作用
void setup(map para)设置初始化
string alloc_token(string account, map token_binding_data)分配一个gs token
bool free_token(string token)回收一个gs token
mixed find_token(string token)查找一个gs token并返回和该token绑定的数据
array check_repeatable_auth(map auth_data)检查待验证的数据是否有效(验证成功后不删除token-可多次重复检查)
array check_auth(map auth_data)检查待验证的数据是否有效(验证成功后删除token-阅后即焚)
array auth(string account, string pass_md5, map auth_args)验证客户端凭证(将客户端的凭证兑换成游戏服务器的token)

SimpleAccountD.gs

本地默认的简单账号模块,用于不连接authserver时候的一个默认账号实现

包括账号的增删查改

函数原型函数作用
mixed register_account(string account, string passwd_md5)注册账号(创建账号)
map get_account(string account)根据账号获取账号信息
array debug_get_all_accounts()调试方法:获取所有账号
bool check_account_exist(string account, string passwd_md5)账号是否存在
mixed take_over(string account, string passwd_md5, string reason, int seconds = 0)接管账号
mixed cancel_take_over(string account)取消账号接管
mixed block_account(string account, string reason, int expiration_time = -1)封闭帐号
mixed unblock_account(string account)取消封闭帐号
bool check_password(map data, string pass_md5)检查密码

样例

// TODO