mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-16 07:06:45 +00:00
GODT-1609: apply change from MR
This commit is contained in:
committed by
James Houlahan
parent
b536b8707e
commit
51633e000b
@ -1,6 +1,7 @@
|
|||||||
package bridge
|
package bridge
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/subtle"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ProtonMail/proton-bridge/v2/internal/user"
|
"github.com/ProtonMail/proton-bridge/v2/internal/user"
|
||||||
@ -23,7 +24,7 @@ func (backend *smtpBackend) Login(state *smtp.ConnectionState, username string,
|
|||||||
defer backend.usersLock.RUnlock()
|
defer backend.usersLock.RUnlock()
|
||||||
|
|
||||||
for _, user := range backend.users {
|
for _, user := range backend.users {
|
||||||
if slices.Contains(user.Emails(), username) && string(user.BridgePass()) == password {
|
if slices.Contains(user.Emails(), username) && subtle.ConstantTimeCompare(user.BridgePass(), []byte(password)) != 1 {
|
||||||
return user.NewSMTPSession(username), nil
|
return user.NewSMTPSession(username), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,7 +206,7 @@ func (user *User) GluonKey() []byte {
|
|||||||
|
|
||||||
// BridgePass returns the user's bridge password, used for authentication over SMTP and IMAP.
|
// BridgePass returns the user's bridge password, used for authentication over SMTP and IMAP.
|
||||||
func (user *User) BridgePass() []byte {
|
func (user *User) BridgePass() []byte {
|
||||||
return []byte(user.vault.BridgePass())
|
return user.vault.BridgePass()
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsedSpace returns the total space used by the user on the API.
|
// UsedSpace returns the total space used by the user on the API.
|
||||||
|
|||||||
@ -57,7 +57,7 @@ type SMTP struct {
|
|||||||
// Leave Username blank to do not use SMTP authentication.
|
// Leave Username blank to do not use SMTP authentication.
|
||||||
Username string
|
Username string
|
||||||
// Leave Password blank to use IMAP credentials.
|
// Leave Password blank to use IMAP credentials.
|
||||||
Password string
|
Password []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) WriteOut(w io.Writer) error {
|
func (c *Config) WriteOut(w io.Writer) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user