mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
add support for inter-node communications
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -52,6 +52,7 @@ const (
|
||||
claimUsernameKey = "username"
|
||||
claimPermissionsKey = "permissions"
|
||||
claimAPIKey = "api_key"
|
||||
claimNodeID = "node_id"
|
||||
claimMustSetSecondFactorKey = "2fa_required"
|
||||
claimRequiredTwoFactorProtocols = "2fa_protos"
|
||||
claimHideUserPageSection = "hus"
|
||||
@@ -74,6 +75,7 @@ type jwtTokenClaims struct {
|
||||
Signature string
|
||||
Audience []string
|
||||
APIKeyID string
|
||||
NodeID string
|
||||
MustSetTwoFactorAuth bool
|
||||
RequiredTwoFactorProtocols []string
|
||||
HideUserPageSections int
|
||||
@@ -97,6 +99,9 @@ func (c *jwtTokenClaims) asMap() map[string]any {
|
||||
if c.APIKeyID != "" {
|
||||
claims[claimAPIKey] = c.APIKeyID
|
||||
}
|
||||
if c.NodeID != "" {
|
||||
claims[claimNodeID] = c.NodeID
|
||||
}
|
||||
claims[jwt.SubjectKey] = c.Signature
|
||||
if c.MustSetTwoFactorAuth {
|
||||
claims[claimMustSetSecondFactorKey] = c.MustSetTwoFactorAuth
|
||||
@@ -157,6 +162,13 @@ func (c *jwtTokenClaims) Decode(token map[string]any) {
|
||||
}
|
||||
}
|
||||
|
||||
if val, ok := token[claimNodeID]; ok {
|
||||
switch v := val.(type) {
|
||||
case string:
|
||||
c.NodeID = v
|
||||
}
|
||||
}
|
||||
|
||||
permissions := token[claimPermissionsKey]
|
||||
c.Permissions = c.decodeSliceString(permissions)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user