mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-01 15:36:37 +00:00
Add cookie to check share link access (#691)
* Add cookie to check share link access * Modify user agent and add timeout * Add filename to attachment * Go set filename to attach * C set filename to attachment * Adjust position of check priviate key * Set Content-Type and User-Agent --------- Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
@@ -17,22 +17,6 @@
|
||||
#define DEBUG_FLAG SEAFILE_DEBUG_TRANSFER
|
||||
#include "log.h"
|
||||
|
||||
#ifndef SEAFILE_CLIENT_VERSION
|
||||
#define SEAFILE_CLIENT_VERSION PACKAGE_VERSION
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define USER_AGENT_OS "Windows NT"
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define USER_AGENT_OS "Apple OS X"
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#define USER_AGENT_OS "Linux"
|
||||
#endif
|
||||
|
||||
/* Http connection and connection pool. */
|
||||
|
||||
struct _Connection {
|
||||
@@ -365,7 +349,7 @@ http_post (Connection *conn, const char *url, const char *token,
|
||||
|
||||
curl = conn->curl;
|
||||
|
||||
headers = curl_slist_append (headers, "User-Agent: Seafile/"SEAFILE_CLIENT_VERSION" ("USER_AGENT_OS")");
|
||||
headers = curl_slist_append (headers, "User-Agent: Seafile Server");
|
||||
|
||||
if (token) {
|
||||
token_header = g_strdup_printf ("Authorization: Token %s", token);
|
||||
@@ -506,7 +490,7 @@ http_tx_manager_get_nickname (const char *modifier)
|
||||
json_decref (content);
|
||||
|
||||
curl = conn->curl;
|
||||
headers = curl_slist_append (headers, "User-Agent: Seafile/"SEAFILE_CLIENT_VERSION" ("USER_AGENT_OS")");
|
||||
headers = curl_slist_append (headers, "User-Agent: Seafile Server");
|
||||
token_header = g_strdup_printf ("Authorization: Token %s", jwt_token);
|
||||
headers = curl_slist_append (headers, token_header);
|
||||
headers = curl_slist_append (headers, "Content-Type: application/json");
|
||||
@@ -580,10 +564,11 @@ out:
|
||||
}
|
||||
|
||||
SeafileShareLinkInfo *
|
||||
http_tx_manager_query_share_link_info (const char *token, const char *type)
|
||||
http_tx_manager_query_share_link_info (const char *token, const char *cookie, const char *type)
|
||||
{
|
||||
Connection *conn = NULL;
|
||||
char *token_header;
|
||||
char *cookie_header;
|
||||
struct curl_slist *headers = NULL;
|
||||
int ret = 0;
|
||||
CURL *curl;
|
||||
@@ -607,14 +592,19 @@ http_tx_manager_query_share_link_info (const char *token, const char *type)
|
||||
}
|
||||
|
||||
curl = conn->curl;
|
||||
headers = curl_slist_append (headers, "User-Agent: Seafile/"SEAFILE_CLIENT_VERSION" ("USER_AGENT_OS")");
|
||||
headers = curl_slist_append (headers, "User-Agent: Seafile Server");
|
||||
token_header = g_strdup_printf ("Authorization: Token %s", jwt_token);
|
||||
headers = curl_slist_append (headers, token_header);
|
||||
headers = curl_slist_append (headers, "Content-Type: application/json");
|
||||
g_free (token_header);
|
||||
if (cookie) {
|
||||
cookie_header = g_strdup_printf ("Cookie: %s", cookie);
|
||||
headers = curl_slist_append (headers, cookie_header);
|
||||
g_free (cookie_header);
|
||||
}
|
||||
headers = curl_slist_append (headers, "Content-Type: application/json");
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||
|
||||
url = g_strdup_printf("%s/share-link-info/?token=%s&type=%s", seaf->seahub_url, token, type);
|
||||
url = g_strdup_printf("%s/check-share-link-access/?token=%s&type=%s", seaf->seahub_url, token, type);
|
||||
ret = http_get_common (curl, url, jwt_token, &rsp_status,
|
||||
&rsp_content, &rsp_size, NULL, NULL, TRUE);
|
||||
if (ret < 0) {
|
||||
|
Reference in New Issue
Block a user