Skip to content

Commit

Permalink
Merge pull request #19 from libxengine/develop
Browse files Browse the repository at this point in the history
V3.7.0.1001 Merge
  • Loading branch information
xengine-qyt authored Apr 21, 2023
2 parents 3d43396 + 79c9c4a commit 2f72e7d
Show file tree
Hide file tree
Showing 125 changed files with 3,161 additions and 2,211 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
XEngine_Authorize V3.7.0.1001

添加:登录支持动态验证码功能
添加:禁用列表查询数量限制功能
更新:扩展HTTP缓冲区大小
更新:支持XEngine V8.x版本了
修改:公告协议现在有数量限制了
修正:获取公告功能开关错误

added:dynamic verfication code for login
added:limit query count for banned function
update:extend http buffer size
update:support xengine 8.x
modify:The number of announcements has been limited
fixed:get notice switch is incorrent
================================================================
XEngine_Authorize V3.6.0.1001

添加:公告功能支持
Expand Down
6 changes: 6 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ feature list:
15. black list management
16. local cdkey support
17. announecement management
18. support dynamic verifaction code

## install

Expand Down Expand Up @@ -77,6 +78,10 @@ make FLAGS=InstallAll Install File
make FLAGS=CleanAll Clear Complie

## how to use

#### upgrade
If it is an upgrade installation, after downloading the new version and modifying the configuration file, it can be run directly
database update need to open the database matching fields and tables are consistent
#### server(management)
Windows:complie complete,copy VSCopy_x86 or VSCopy_x64 to your complie dir,should copy depend module when execution complete,and copy XEngine_Release dir all file to complie dir
Linux or macos:it can be execution....
Expand All @@ -97,6 +102,7 @@ port :tcp port 5300,websocket port 5301,http management port 5302,Transmission v
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/3.png "在这里输入图片标题")
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/4.png "在这里输入图片标题")
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/5.png "在这里输入图片标题")
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/6.png "在这里输入图片标题")

## Participate in contribution

Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ V2可以直接升级到V3版本,因为数据库并没有修改,直接替换程
15. 黑名单管理
16. 本地cdkey生成验证支持
17. 支持功公告管理
18. 支持动态验证码登录

## 安装教程

Expand Down Expand Up @@ -77,6 +78,10 @@ make FLAGS=InstallAll 安装库程序
make FLAGS=CleanAll 清理编译

## 如何使用

#### 升级
如果是升级安装,下载新版本后修改配置文件就可以直接运行了
数据库升级需要打开数据库匹配字段和表是否一致
#### 服务端(管理端)
Windows:编译成功后,拷贝VSCopy_x86或者VSCopy_x64 到你的编译目录,执行自动拷贝依赖的模块,然后把XEngine_Release下的文件全部拷贝到编译目录即可
Linux or macos:直接运行即可
Expand All @@ -97,6 +102,7 @@ Linux or macos:直接运行即可
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/3.png "在这里输入图片标题")
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/4.png "在这里输入图片标题")
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/5.png "在这里输入图片标题")
![输入图片说明](https://www.xyry.org/XEngine_StructPic/authorize/6.png "在这里输入图片标题")

## 参与贡献

Expand Down Expand Up @@ -126,9 +132,7 @@ V3版本为全新版本,为了适应过多环境要求开发

## 开发计划
mfc转qt界面库(我们需要会Qt的人员加入一起开发)
动态验证码
短信登录,扫码登录
消息公告
支持多端登录
多端登录合并用时
生成会话TOKEN分布式鉴权
Expand All @@ -138,11 +142,11 @@ token 自动续期
http basic和disgt支持
支持OAuth验证
mysql支持
列表数据分割,用于大型服务器
支持用户和硬件绑定同时验证
统计用户所有在线时间
持久层,redis,memcached等支持
支持代理端(序列号分发,权限控制)
支持设置用户可以使用IP地址段
支持绑定自定义内容
自动售卡(支付宝,微信)
MQTT协议支持,让你的嵌入式设备也用上授时验证
Expand Down
104 changes: 73 additions & 31 deletions XEngine_Apps/Authorize_APPClient/Authorize_APPClient.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef _WINDOWS
#ifdef _MSC_BUILD
#include <Windows.h>
#include <tchar.h>
#pragma comment(lib,"Ws2_32.lib")
Expand Down Expand Up @@ -32,16 +32,19 @@ using namespace std;
//Linux::g++ -std=c++17 -Wall -g Auth_APPClient.cpp -o Auth_APPClient.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_Core -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_Client -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lXEngine_OPenSsl -lXClient_Socket -lNetHelp_APIClient -lpthread -ljsoncpp -Wl,-rpath=../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_Core:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_Client:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp,--disable-new-dtags
//Macos::g++ -std=c++17 -Wall -g Auth_APPClient.cpp -o Auth_APPClient.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_Core -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_Client -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lXEngine_OPenSsl -lXClient_Socket -lNetHelp_APIClient -lpthread -ljsoncpp

BOOL bRun = TRUE;
BOOL bLogin = TRUE;
BOOL bTimeOut = TRUE;
BOOL bEncrypto = FALSE;

SOCKET m_Socket = 0;
LPCTSTR lpszUser = _T("123123aa");
LPCTSTR lpszPass = _T("123123");
LPCTSTR lpszSerial = _T("XAUTH-XYRYM-ZAA10-59NKW-KOFLP-35838-ZXC36-ZOVTH");
LPCTSTR lpszEmail = _T("[email protected]");
#define _DYNAMIC_CODE
bool bRun = true;
bool bLogin = true;
bool bTimeOut = true;
bool bEncrypto = false;
XNETHANDLE xhToken = 0;
int nDYCode = 0;

XSOCKET m_Socket = 0;
LPCXSTR lpszUser = _T("123123aa");
LPCXSTR lpszPass = _T("123123");
LPCXSTR lpszSerial = _T("XAUTH-XYRYM-ZAA10-59NKW-KOFLP-35838-ZXC36-ZOVTH");
LPCXSTR lpszEmail = _T("[email protected]");
__int64x nPhoneNumber = 1366666666;
__int64x nIDNumber = 511025111111111111;

Expand All @@ -50,13 +53,13 @@ XHTHREAD AuthClient_Thread()
while (bRun)
{
int nMsgLen = 0;
TCHAR *ptszMsgBuffer;
XCHAR *ptszMsgBuffer;
XENGINE_PROTOCOLHDR st_ProtocolHdr;

memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
if (XClient_TCPSelect_RecvPkt(m_Socket, &ptszMsgBuffer, &nMsgLen, &st_ProtocolHdr))
{
TCHAR tszMsgBuffer[4096];
XCHAR tszMsgBuffer[4096];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));

if (nMsgLen > 0 && bEncrypto)
Expand All @@ -71,7 +74,7 @@ XHTHREAD AuthClient_Thread()

if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REPLOGIN == st_ProtocolHdr.unOperatorCode)
{
bLogin = FALSE;
bLogin = false;
if (0 == st_ProtocolHdr.wReserve)
{
printf(_T("登录成功\n"));
Expand All @@ -83,7 +86,7 @@ XHTHREAD AuthClient_Thread()
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_TIMEDOUT == st_ProtocolHdr.unOperatorCode)
{
bTimeOut = FALSE;
bTimeOut = false;
printf(_T("用户过期\n"));
}
else
Expand All @@ -102,7 +105,7 @@ int AuthClient_Register()
Json::Value st_JsonRoot;
Json::Value st_JsonUserInfo;
Json::Value st_JsonUserTable;
LPCTSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/register");
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/register");

st_JsonUserInfo["tszUserName"] = lpszUser;
st_JsonUserInfo["tszUserPass"] = lpszPass;
Expand All @@ -129,7 +132,7 @@ int AuthClient_Pay()
int nHTTPCode = 0;
Json::Value st_JsonRoot;
Json::Value st_JsonObject;
LPCTSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/pay");
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/pay");

st_JsonObject["tszSerialNumber"] = lpszSerial;
st_JsonObject["tszUserName"] = lpszUser;
Expand All @@ -144,9 +147,39 @@ int AuthClient_Pay()

return 0;
}
int AuthClient_DynamicCode()
{
int nHTTPCode = 0;
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/api?function=dcode&user=get");

int nMsgLen = 0;
CHAR* ptszMsgBuffer = NULL;
APIClient_Http_Request(_T("GET"), lpszUrl, NULL, NULL, &ptszMsgBuffer, &nMsgLen);
printf("AuthClient_DynamicCode:\n%s\n", ptszMsgBuffer);

Json::Value st_JsonRoot;
JSONCPP_STRING st_JsonError;
Json::CharReaderBuilder st_ReaderBuilder;
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_ReaderBuilder.newCharReader());
if (!pSt_JsonReader->parse(ptszMsgBuffer, ptszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
{
return 0;
}
XCHAR tszDCodeStr[64];
XCHAR tszTokenStr[64];

memset(tszDCodeStr, '\0', sizeof(tszDCodeStr));
memset(tszTokenStr, '\0', sizeof(tszTokenStr));

nDYCode = st_JsonRoot["nDynamicCode"].asUInt();
xhToken = st_JsonRoot["xhToken"].asUInt64();
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);

return 0;
}
int AuthClient_Login()
{
TCHAR tszMsgBuffer[2048];
XCHAR tszMsgBuffer[2048];
XENGINE_PROTOCOLHDR st_ProtocolHdr; //协议头
XENGINE_PROTOCOL_USERAUTH st_AuthUser;

Expand All @@ -164,14 +197,20 @@ int AuthClient_Login()
strcpy(st_AuthUser.tszUserName, lpszUser);
strcpy(st_AuthUser.tszUserPass, lpszPass);

if (nDYCode > 0)
{
st_ProtocolHdr.xhToken = xhToken;
_stprintf(st_AuthUser.tszDCode, _T("%d"), nDYCode);
}

int nMsgLen = 0;
if (bEncrypto)
{
TCHAR tszCodecBuffer[2048];
XCHAR tszCodecBuffer[2048];
memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer));

st_ProtocolHdr.wCrypto = ENUM_XENGINE_PROTOCOLHDR_CRYPTO_TYPE_XCRYPT;
OPenSsl_XCrypto_Encoder((LPCTSTR)&st_AuthUser, (int*)&st_ProtocolHdr.unPacketSize, (UCHAR*)tszCodecBuffer, lpszPass);
OPenSsl_XCrypto_Encoder((LPCXSTR)&st_AuthUser, (int*)&st_ProtocolHdr.unPacketSize, (UCHAR*)tszCodecBuffer, lpszPass);

memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), tszCodecBuffer, st_ProtocolHdr.unPacketSize);
Expand Down Expand Up @@ -200,7 +239,7 @@ int AuthClient_Login()
int AuthClient_Notice()
{
int nHTTPCode = 0;
LPCTSTR lpszUrl = _T("http://127.0.0.1:5302/api?function=notice");
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/api?function=notice");

int nMsgLen = 0;
CHAR* ptszMsgBuffer = NULL;
Expand All @@ -217,7 +256,7 @@ int AuthClient_Notice()
}
for (unsigned int i = 0; i < st_JsonRoot["Array"].size(); i++)
{
TCHAR tszMsgBuffer[2048];
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
Json::Value st_JsonArray = st_JsonRoot["Array"][i];

Expand All @@ -234,7 +273,7 @@ int AuthClient_GetPass()
int nHTTPCode = 0;
Json::Value st_JsonRoot;
Json::Value st_JsonObject;
LPCTSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/pass");
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/pass");

st_JsonObject["tszUserName"] = lpszUser;
st_JsonObject["tszEMailAddr"] = lpszEmail;
Expand All @@ -256,7 +295,7 @@ int AuthClient_GetTime()
int nHTTPCode = 0;
Json::Value st_JsonRoot;
Json::Value st_JsonObject;
LPCTSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/time");
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/time");

st_JsonObject["tszUserName"] = lpszUser;
st_JsonObject["tszUserPass"] = lpszPass;
Expand All @@ -275,7 +314,7 @@ int AuthClient_Delete()
int nHTTPCode = 0;
Json::Value st_JsonRoot;
Json::Value st_JsonObject;
LPCTSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/delete");
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/delete");

st_JsonObject["tszUserName"] = lpszUser;
st_JsonObject["tszUserPass"] = lpszPass;
Expand All @@ -298,8 +337,8 @@ int AuthClient_Try()
int nHTTPCode = 0;
Json::Value st_JsonRoot;
Json::Value st_JsonObject;
LPCTSTR lpszSerialNet = _T("cpuid:112233"); //通过此可以做临时网络验证,安全性比本地临时验证高
LPCTSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/try");
LPCXSTR lpszSerialNet = _T("cpuid:112233"); //通过此可以做临时网络验证,安全性比本地临时验证高
LPCXSTR lpszUrl = _T("http://127.0.0.1:5302/auth/user/try");

st_JsonObject["tszSerial"] = lpszSerialNet;
st_JsonRoot["st_UserTry"] = st_JsonObject;
Expand All @@ -314,12 +353,12 @@ int AuthClient_Try()
}
int main()
{
#ifdef _WINDOWS
#ifdef _MSC_BUILD
WSADATA st_WSAData;
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
#endif
int nPort = 5300;
LPCTSTR lpszAddr = _T("127.0.0.1");
LPCXSTR lpszAddr = _T("127.0.0.1");

if (!XClient_TCPSelect_Create(&m_Socket, lpszAddr, nPort))
{
Expand All @@ -330,18 +369,21 @@ int main()

AuthClient_Register();
AuthClient_Pay();
#ifdef _DYNAMIC_CODE
AuthClient_DynamicCode();
#endif
AuthClient_Login();
AuthClient_Notice();
AuthClient_GetPass();
AuthClient_GetTime();
AuthClient_Delete();
AuthClient_Try();

bRun = FALSE;
bRun = false;
XClient_TCPSelect_Close(m_Socket);
pSTDThread.join();

#ifdef _WINDOWS
#ifdef _MSC_BUILD
WSACleanup();
#endif
return 0;
Expand Down
16 changes: 8 additions & 8 deletions XEngine_Apps/Authorize_APPLocal/Authorize_APPLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

//#define XENGINE_AUTHORIZE_CDKEY_CRYPTO

LPCTSTR lpszPasswd = _T("123123");
LPCXSTR lpszPasswd = _T("123123");

int main()
{
Expand Down Expand Up @@ -63,8 +63,8 @@ int main()
st_JsonRoot["st_AuthRegInfo"] = st_JsonREGInfo;
st_JsonRoot["st_AuthUserInfo"] = st_JsonUserInfo;

TCHAR* ptszCreateBuffer = NULL;
LPCTSTR lpszCreateUrl = _T("http://192.168.1.10:5302/auth/cdkey/create");
XCHAR* ptszCreateBuffer = NULL;
LPCXSTR lpszCreateUrl = _T("http://192.168.1.10:5302/auth/cdkey/create");
//1. 创建CDKEY
#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO
//加密
Expand All @@ -82,7 +82,7 @@ int main()
return 0;
}

TCHAR tszMsgBuffer[4096];
XCHAR tszMsgBuffer[4096];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO
//解密
Expand All @@ -98,8 +98,8 @@ int main()
#endif
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszCreateBuffer);
//2. 授权CDKEY
TCHAR* ptszAuthBuffer = NULL;
LPCTSTR lpszAuthUrl = _T("http://192.168.1.10:5302/auth/cdkey/auth");
XCHAR* ptszAuthBuffer = NULL;
LPCXSTR lpszAuthUrl = _T("http://192.168.1.10:5302/auth/cdkey/auth");
#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO
//加密
memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer));
Expand Down Expand Up @@ -127,8 +127,8 @@ int main()
#endif
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszAuthBuffer);
//3. 验证CDKEY
TCHAR* ptszVerBuffer = NULL;
LPCTSTR lpszVerUrl = _T("http://192.168.1.10:5302/auth/cdkey/ver");
XCHAR* ptszVerBuffer = NULL;
LPCXSTR lpszVerUrl = _T("http://192.168.1.10:5302/auth/cdkey/ver");

XENGINE_AUTHORIZE_LOCAL st_Authorize;
memset(&st_Authorize, '\0', sizeof(XENGINE_AUTHORIZE_LOCAL));
Expand Down
Binary file modified XEngine_Docment/Docment_en.docx
Binary file not shown.
Binary file modified XEngine_Docment/Docment_zh.docx
Binary file not shown.
Loading

0 comments on commit 2f72e7d

Please sign in to comment.