【更新】授权模块

This commit is contained in:
2025-02-21 23:49:18 +08:00
parent ebca2120c0
commit b9005b7acc
2 changed files with 24 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ std::string AppCfg::m_work_path="";
std::string AppCfg::m_license="";
float AppCfg::m_face_match_threshold = 0.78f;
void AppCfg::SetWorkPath(const std::string& work_path) {
m_work_path = work_path;
}
const std::string AppCfg::GetWorkPath() {
@@ -18,6 +18,6 @@ bool AppCfg::SetLicense(const std::string& license) {
}
void AppCfg::SetFaceMatchThreshold(float threshold) {
m_face_match_threshold = threshold;
}

View File

@@ -8,6 +8,7 @@
#include <vector>
#include "openssl/aes.h"
#include "AuthModule.h"
#include "DeviceInfo.h"
#include "Base64.h"
#include "HttpRequest.h"
// 获取时间戳
@@ -115,8 +116,7 @@ void TimeInfo::Show() {
}
AuthInfo::AuthInfo() :
m_type(AUTH_TYPE_INVALID) {
}
m_type(AUTH_TYPE_INVALID) { }
AuthInfo::AuthInfo(const std::string& key_data) {
std::istringstream iss(key_data);
@@ -144,6 +144,7 @@ AuthInfo::AuthInfo(const std::string& key_data) {
ret_t AuthModule::CheckKey(const std::string& key) {
return RET_AUTH_FAILED;
}
@@ -155,12 +156,13 @@ ret_t AuthModule::CheckKeyFile(const std::string& key_file) {
}
m_auth_info = AuthInfo(key_data);
// m_auth_info.m_expire_time.Show();
switch (m_auth_info.m_type){
switch (m_auth_info.m_type) {
case AUTH_TYPE_OFFLINE_TIME:
ret = CheckOfflineTime();
break;
case AUTH_TYPE_OFFLINE_MAC:
ret = CheckOfflineMac();
break;
case AUTH_TYPE_ONLINE:
ret = CheckOnline();
break;
@@ -242,6 +244,14 @@ ret_t AuthModule::CheckOfflineTime() {
}
ret_t AuthModule::CheckOfflineMac() {
std::vector<std::string> mac_list = DeviceInfo::GetInstance().GetMacAddress();
for (auto& mac : mac_list) {
for (auto& auth_mac : m_auth_info.m_mac_list) {
if (mac == auth_mac) {
return RET_OK;
}
}
}
return RET_AUTH_FAILED;
}