mirror of
https://github.com/rclone/rclone.git
synced 2025-08-18 01:20:16 +02:00
committed by
Nick Craig-Wood
parent
e0356f5aae
commit
6d58d9a86f
33
vendor/goftp.io/server/auth.go
generated
vendored
Normal file
33
vendor/goftp.io/server/auth.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2018 The goftp Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
)
|
||||
|
||||
// Auth is an interface to auth your ftp user login.
|
||||
type Auth interface {
|
||||
CheckPasswd(string, string) (bool, error)
|
||||
}
|
||||
|
||||
var (
|
||||
_ Auth = &SimpleAuth{}
|
||||
)
|
||||
|
||||
// SimpleAuth implements Auth interface to provide a memory user login auth
|
||||
type SimpleAuth struct {
|
||||
Name string
|
||||
Password string
|
||||
}
|
||||
|
||||
// CheckPasswd will check user's password
|
||||
func (a *SimpleAuth) CheckPasswd(name, pass string) (bool, error) {
|
||||
return constantTimeEquals(name, a.Name) && constantTimeEquals(pass, a.Password), nil
|
||||
}
|
||||
|
||||
func constantTimeEquals(a, b string) bool {
|
||||
return len(a) == len(b) && subtle.ConstantTimeCompare([]byte(a), []byte(b)) == 1
|
||||
}
|
Reference in New Issue
Block a user