aboutsummaryrefslogtreecommitdiff
path: root/weed/sftpd/auth/publickey.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/sftpd/auth/publickey.go')
-rw-r--r--weed/sftpd/auth/publickey.go19
1 files changed, 1 insertions, 18 deletions
diff --git a/weed/sftpd/auth/publickey.go b/weed/sftpd/auth/publickey.go
index 83c5092a1..a0a49c6d1 100644
--- a/weed/sftpd/auth/publickey.go
+++ b/weed/sftpd/auth/publickey.go
@@ -1,7 +1,6 @@
package auth
import (
- "crypto/subtle"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/sftpd/user"
@@ -40,7 +39,7 @@ func (a *PublicKeyAuthenticator) Authenticate(conn ssh.ConnMetadata, key ssh.Pub
keyData := string(key.Marshal())
// Validate public key
- if ValidatePublicKey(a.userStore, username, keyData) {
+ if a.userStore.ValidatePublicKey(username, keyData) {
return &ssh.Permissions{
Extensions: map[string]string{
"username": username,
@@ -50,19 +49,3 @@ func (a *PublicKeyAuthenticator) Authenticate(conn ssh.ConnMetadata, key ssh.Pub
return nil, fmt.Errorf("authentication failed")
}
-
-// ValidatePublicKey checks if the provided public key is valid for the user
-func ValidatePublicKey(store user.Store, username string, keyData string) bool {
- user, err := store.GetUser(username)
- if err != nil {
- return false
- }
-
- for _, key := range user.PublicKeys {
- if subtle.ConstantTimeCompare([]byte(key), []byte(keyData)) == 1 {
- return true
- }
- }
-
- return false
-}