Skip to content

Commit

Permalink
Modify RPC name
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Jul 31, 2024
1 parent c0b9650 commit ee9a4c0
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions common/rpc-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions common/seaf-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion common/seaf-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion include/seafile-rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/seafile/rpcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions python/seaserv/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion server/http-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions server/notif-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions server/seaf-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions server/seafile-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion server/seafile-session.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct _SeafileSession {

// For notification server
NotifManager *notif_mgr;
char *private_key;
char *notif_server_private_key;

gboolean is_repair;
};
Expand Down

0 comments on commit ee9a4c0

Please sign in to comment.