mirror of
https://github.com/drakkan/sftpgo.git
synced 2026-03-14 14:25:52 +01:00
portable mode: improve password generation and perms
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
03ae0a1c84
commit
6cef669b8d
2 changed files with 5 additions and 7 deletions
|
|
@ -39,7 +39,6 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
chars = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
|
||||
graceTime int
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -144,16 +144,15 @@ func (s *Service) configurePortableUser() string {
|
|||
printablePassword = "[redacted]"
|
||||
}
|
||||
if len(s.PortableUser.PublicKeys) == 0 && s.PortableUser.Password == "" {
|
||||
var b strings.Builder
|
||||
for i := 0; i < 16; i++ {
|
||||
b.WriteRune(chars[rand.Intn(len(chars))])
|
||||
}
|
||||
s.PortableUser.Password = b.String()
|
||||
s.PortableUser.Password = util.GenerateUniqueID()
|
||||
printablePassword = s.PortableUser.Password
|
||||
}
|
||||
s.PortableUser.Filters.WebClient = []string{sdk.WebClientSharesDisabled, sdk.WebClientInfoChangeDisabled,
|
||||
sdk.WebClientPubKeyChangeDisabled, sdk.WebClientPasswordChangeDisabled, sdk.WebClientAPIKeyAuthChangeDisabled,
|
||||
sdk.WebClientMFADisabled,
|
||||
sdk.WebClientMFADisabled, sdk.WebClientPasswordResetDisabled, sdk.WebClientTLSCertChangeDisabled,
|
||||
}
|
||||
if !s.PortableUser.HasAnyPerm([]string{dataprovider.PermUpload, dataprovider.PermOverwrite}, "/") {
|
||||
s.PortableUser.Filters.WebClient = append(s.PortableUser.Filters.WebClient, sdk.WebClientWriteDisabled)
|
||||
}
|
||||
s.configurePortableSecrets()
|
||||
return printablePassword
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue