From ee9a4c09b5832c36266212f9617f3314a0224ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B5=AB=E7=84=B6?= Date: Wed, 31 Jul 2024 17:51:00 +0800 Subject: [PATCH] Modify RPC name --- common/rpc-service.c | 4 ++-- common/seaf-utils.c | 6 +++--- common/seaf-utils.h | 2 +- include/seafile-rpc.h | 2 +- python/seafile/rpcclient.py | 2 +- python/seaserv/api.py | 4 ++-- server/http-server.c | 2 +- server/notif-mgr.c | 4 ++-- server/seaf-server.c | 4 ++-- server/seafile-session.c | 8 ++++---- server/seafile-session.h | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/common/rpc-service.c b/common/rpc-service.c index d6d9b3a2..d896184d 100644 --- a/common/rpc-service.c +++ b/common/rpc-service.c @@ -4606,14 +4606,14 @@ seafile_search_files_by_path (const char *repo_id, const char *path, const char } char * -seafile_generate_jwt_token (const char *repo_id, const char *username, GError **error) +seafile_generate_notif_server_jwt (const char *repo_id, const char *username, GError **error) { if (!repo_id || !username) { g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Argument should not be null"); return NULL; } - char *token = seaf_gen_jwt_token (repo_id, username); + char *token = seaf_gen_notif_server_jwt (repo_id, username); if (!token) { g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_INTERNAL, "Failed to generate jwt token"); diff --git a/common/seaf-utils.c b/common/seaf-utils.c index f3f63679..30e1e37d 100644 --- a/common/seaf-utils.c +++ b/common/seaf-utils.c @@ -446,14 +446,14 @@ load_seahub_private_key (SeafileSession *session, const char *conf_dir) } char * -seaf_gen_jwt_token (const char *repo_id, const char *username) +seaf_gen_notif_server_jwt (const char *repo_id, const char *username) { char *jwt_token = NULL; gint64 now = (gint64)time(NULL); jwt_t *jwt = NULL; - if (!seaf->private_key) { + if (!seaf->notif_server_private_key) { seaf_warning ("No private key is configured for generating jwt token\n"); return NULL; } @@ -479,7 +479,7 @@ seaf_gen_jwt_token (const char *repo_id, const char *username) seaf_warning ("Failed to expire time to jwt\n"); goto out; } - ret = jwt_set_alg (jwt, JWT_ALG_HS256, (unsigned char *)seaf->private_key, strlen(seaf->private_key)); + ret = jwt_set_alg (jwt, JWT_ALG_HS256, (unsigned char *)seaf->notif_server_private_key, strlen(seaf->notif_server_private_key)); if (ret != 0) { seaf_warning ("Failed to set alg\n"); goto out; diff --git a/common/seaf-utils.h b/common/seaf-utils.h index 06ca41c1..6aecc618 100644 --- a/common/seaf-utils.h +++ b/common/seaf-utils.h @@ -22,6 +22,6 @@ load_seahub_private_key (SeafileSession *session, const char *conf_dir); #endif char * -seaf_gen_jwt_token (const char *repo_id, const char *username); +seaf_gen_notif_server_jwt (const char *repo_id, const char *username); #endif diff --git a/include/seafile-rpc.h b/include/seafile-rpc.h index 56b6198b..b03d5415 100644 --- a/include/seafile-rpc.h +++ b/include/seafile-rpc.h @@ -1150,7 +1150,7 @@ GList * seafile_search_files_by_path (const char *repo_id, const char *path, const char *str, GError **error); char * -seafile_generate_jwt_token (const char *repo_id, const char *username, GError **error); +seafile_generate_notif_server_jwt (const char *repo_id, const char *username, GError **error); /*Following is ccnet rpc*/ int diff --git a/python/seafile/rpcclient.py b/python/seafile/rpcclient.py index ac4027a7..531578cf 100644 --- a/python/seafile/rpcclient.py +++ b/python/seafile/rpcclient.py @@ -822,7 +822,7 @@ def search_files_by_path(self, repo_id, path, search_str): pass @searpc_func("string", ["string", "string"]) - def generate_jwt_token(self, repo_id, username): + def generate_notif_server_jwt(self, repo_id, username): pass #user management diff --git a/python/seaserv/api.py b/python/seaserv/api.py index da8f32d8..d4b7270f 100644 --- a/python/seaserv/api.py +++ b/python/seaserv/api.py @@ -859,8 +859,8 @@ def search_files(self, repo_id, search_str): def search_files_by_path (self, repo_id, path, search_str): return seafserv_threaded_rpc.search_files_by_path(repo_id, path, search_str) - def gen_jwt_token (self, repo_id, username): - return seafserv_threaded_rpc.generate_jwt_token (repo_id, username) + def gen_notif_server_jwt (self, repo_id, username): + return seafserv_threaded_rpc.generate_notif_server_jwt (repo_id, username) seafile_api = SeafileAPI() diff --git a/server/http-server.c b/server/http-server.c index 18926324..1cba4ea4 100644 --- a/server/http-server.c +++ b/server/http-server.c @@ -2402,7 +2402,7 @@ get_jwt_token_cb (evhtp_request_t *req, void *arg) goto out; } - jwt_token = seaf_gen_jwt_token (repo_id, username); + jwt_token = seaf_gen_notif_server_jwt (repo_id, username); if (!jwt_token) { seaf_warning ("Failed to gen jwt token for repo %s\n", repo_id); evhtp_send_reply (req, EVHTP_RES_SERVERR); diff --git a/server/notif-mgr.c b/server/notif-mgr.c index 6f8a5bb4..5d2b7f2e 100644 --- a/server/notif-mgr.c +++ b/server/notif-mgr.c @@ -59,7 +59,7 @@ gen_jwt_token () jwt_t *jwt = NULL; - if (!seaf->private_key) { + if (!seaf->notif_server_private_key) { seaf_warning ("No private key is configured for generating jwt token\n"); return NULL; } @@ -75,7 +75,7 @@ gen_jwt_token () seaf_warning ("Failed to expire time to jwt\n"); goto out; } - ret = jwt_set_alg (jwt, JWT_ALG_HS256, (unsigned char *)seaf->private_key, strlen(seaf->private_key)); + ret = jwt_set_alg (jwt, JWT_ALG_HS256, (unsigned char *)seaf->notif_server_private_key, strlen(seaf->notif_server_private_key)); if (ret != 0) { seaf_warning ("Failed to set alg\n"); goto out; diff --git a/server/seaf-server.c b/server/seaf-server.c index 7d6a72cd..a0b45e99 100644 --- a/server/seaf-server.c +++ b/server/seaf-server.c @@ -351,8 +351,8 @@ static void start_rpc_service (const char *seafile_dir, searpc_signature_objlist__string_string_string()); searpc_server_register_function ("seafserv-threaded-rpcserver", - seafile_generate_jwt_token, - "generate_jwt_token", + seafile_generate_notif_server_jwt, + "generate_notif_server_jwt", searpc_signature_string__string_string()); /* share repo to user */ diff --git a/server/seafile-session.c b/server/seafile-session.c index e7cb3cdf..4db9a577 100644 --- a/server/seafile-session.c +++ b/server/seafile-session.c @@ -121,7 +121,7 @@ seafile_session_new(const char *central_config_dir, gboolean notif_enabled = FALSE; char *notif_server = NULL; int notif_port = 8083; - char *private_key = NULL; + char *notif_server_private_key = NULL; abs_ccnet_dir = ccnet_expand_path (ccnet_dir); abs_seafile_dir = ccnet_expand_path (seafile_dir); @@ -202,10 +202,10 @@ seafile_session_new(const char *central_config_dir, "notification", "port", NULL); - private_key = g_key_file_get_string (config, + notif_server_private_key = g_key_file_get_string (config, "notification", "jwt_private_key", NULL); - session->private_key = private_key; + session->notif_server_private_key = notif_server_private_key; } if (load_database_config (session) < 0) { @@ -307,7 +307,7 @@ seafile_session_new(const char *central_config_dir, onerror: g_free (notif_server); - g_free (private_key); + g_free (notif_server_private_key); free (abs_seafile_dir); free (abs_ccnet_dir); g_free (tmp_file_dir); diff --git a/server/seafile-session.h b/server/seafile-session.h index a42e45d9..66c3818a 100644 --- a/server/seafile-session.h +++ b/server/seafile-session.h @@ -93,7 +93,7 @@ struct _SeafileSession { // For notification server NotifManager *notif_mgr; - char *private_key; + char *notif_server_private_key; gboolean is_repair; };