mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-09 19:29:03 +00:00
Use JWT_PRIVATE_KEY (#697)
Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
@@ -46,8 +46,6 @@ var (
|
|||||||
// notification server
|
// notification server
|
||||||
EnableNotification bool
|
EnableNotification bool
|
||||||
NotificationURL string
|
NotificationURL string
|
||||||
// notification options
|
|
||||||
PrivateKey string
|
|
||||||
|
|
||||||
// GROUP options
|
// GROUP options
|
||||||
GroupTableName string
|
GroupTableName string
|
||||||
@@ -107,11 +105,6 @@ func LoadFileServerOptions(centralDir string) {
|
|||||||
if EnableNotification {
|
if EnableNotification {
|
||||||
var notifServer string
|
var notifServer string
|
||||||
var notifPort uint32
|
var notifPort uint32
|
||||||
if section, err := config.GetSection("notification"); err == nil {
|
|
||||||
if key, err := section.GetKey("jwt_private_key"); err == nil {
|
|
||||||
PrivateKey = key.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if section, err := config.GetSection("notification"); err == nil {
|
if section, err := config.GetSection("notification"); err == nil {
|
||||||
if key, err := section.GetKey("host"); err == nil {
|
if key, err := section.GetKey("host"); err == nil {
|
||||||
notifServer = key.String()
|
notifServer = key.String()
|
||||||
|
@@ -771,7 +771,7 @@ func genJWTToken(repoID, user string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
token := jwt.NewWithClaims(jwt.GetSigningMethod("HS256"), &claims)
|
token := jwt.NewWithClaims(jwt.GetSigningMethod("HS256"), &claims)
|
||||||
tokenString, err := token.SignedString([]byte(option.PrivateKey))
|
tokenString, err := token.SignedString([]byte(seahubPK))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("failed to gen jwt token for repo %s", repoID)
|
err := fmt.Errorf("failed to gen jwt token for repo %s", repoID)
|
||||||
return "", err
|
return "", err
|
||||||
|
@@ -204,10 +204,7 @@ seafile_session_new(const char *central_config_dir,
|
|||||||
"notification", "port",
|
"notification", "port",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
notif_server_private_key = g_key_file_get_string (config,
|
session->notif_server_private_key = g_strdup (private_key);
|
||||||
"notification", "jwt_private_key",
|
|
||||||
NULL);
|
|
||||||
session->notif_server_private_key = notif_server_private_key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (load_database_config (session) < 0) {
|
if (load_database_config (session) < 0) {
|
||||||
|
Reference in New Issue
Block a user