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

Add cookie to check share link access #691

Merged
merged 7 commits into from
Sep 6, 2024
Merged

Add cookie to check share link access #691

merged 7 commits into from
Sep 6, 2024

Conversation

feiniks
Copy link
Contributor

@feiniks feiniks commented Sep 5, 2024

No description provided.

cookie_header = g_strdup_printf ("Cookie: %s", cookie);
headers = curl_slist_append (headers, cookie_header);
g_free (cookie_header);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个代码的位置往下面移动一下吧,感觉中断了 token_header 的代码。

@@ -609,12 +610,17 @@ 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")");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

检查一下其他代码,这里的 User-Agent 应该改为 Seafile server 吧。

header := map[string][]string{
"Authorization": {"Token " + tokenString},
}
if cookie != "" {
header["Cookie"] = []string{cookie}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个请求没有设置 applicateion/json 的头部。可以在 HttpCommon 里面自动设置。HttpCommon 也需要增加请求超时。

@@ -365,7 +365,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/"SEAFILE_CLIENT_VERSION" ("USER_AGENT_OS")");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面不用加 version 了,而且你这个也是客户端的版本。这些宏也删掉吧。

@@ -20,7 +19,10 @@ func GetAuthorizationToken(h http.Header) string {
}

func HttpCommon(method, url string, header map[string][]string, reader io.Reader) (int, []byte, error) {
req, err := http.NewRequestWithContext(HttpReqContext, method, url, reader)
header["Content-Type"] = []string{"application/json"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里设置了这个头部,就不用再调用 HttpCommon 之前设置了。多余的代码删除吧。

"inline;filename=\"%s\"", filename);
}
snprintf(cont_filename, SEAF_PATH_MAX,
"inline;filename*=utf-8''%s;filename=\"%s\"", esc_filename, filename);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个需要在 Chrome, Firefox 和 Safari 三个浏览器上测试。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个测过了

@killing killing merged commit d01c46e into master Sep 6, 2024
6 checks passed
@killing killing deleted the set_cookie branch September 6, 2024 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants