Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

分group配置是否支持token验证 #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static char flv_header[] = "FLV\x1\x1\0\0\0\x9\0\0\0\x9";
typedef struct tagGroupStorePaths {
char group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
int group_name_len;
bool check_token;
int storage_server_port;
FDFSStorePaths store_paths;
} GroupStorePaths;
Expand Down Expand Up @@ -112,6 +113,10 @@ static int fdfs_load_groups_store_paths(IniContext *pItemContext)
return ENOENT;
}

group_store_paths[i].check_token = iniGetBoolValue(section_name, \
"check_token", \
pItemContext, false);

group_store_paths[i].storage_server_port = iniGetIntValue( \
section_name, "storage_server_port", pItemContext, \
FDFS_STORAGE_SERVER_DEF_PORT);
Expand Down Expand Up @@ -791,6 +796,7 @@ int fdfs_http_request_handler(struct fdfs_http_context *pContext)
FDFSFileInfo file_info;
bool bFileExists;
bool bSameGroup; //if in my group
bool checkToken = g_http_params.anti_steal_token;
bool bTrunkFile;
FDFSTrunkFullInfo trunkInfo;

Expand Down Expand Up @@ -887,6 +893,7 @@ int fdfs_http_request_handler(struct fdfs_http_context *pContext)
the_storage_port = group_store_paths[i]. \
storage_server_port;
bSameGroup = true;
checkToken = group_store_paths[i].check_token;
pStorePaths = &group_store_paths[i].store_paths;
break;
}
Expand Down Expand Up @@ -914,7 +921,7 @@ int fdfs_http_request_handler(struct fdfs_http_context *pContext)
return HTTP_BADREQUEST;
}

if (g_http_params.anti_steal_token)
if (g_http_params.anti_steal_token && checkToken)
{
char *token;
char *ts;
Expand Down
2 changes: 2 additions & 0 deletions src/mod_fastdfs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ group_count = 0
# when support multi-group on this storage server, uncomment following section
#[group1]
#group_name=group1
#check_token=false
#storage_server_port=23000
#store_path_count=2
#store_path0=/home/yuqing/fastdfs
Expand All @@ -127,6 +128,7 @@ group_count = 0
# when support multi-group, uncomment following section as neccessary
#[group2]
#group_name=group2
#check_token=false
#storage_server_port=23000
#store_path_count=1
#store_path0=/home/yuqing/fastdfs
Expand Down