mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-22 15:27:02 +00:00
Add checks to prevent unauthorized relaying and impersonation
This patch adds checks that verify: - The envelope from must match the authenticated user. This prevents impersonation at the envelope level (while still allowing bounces, of course). - If the destination is remote, then the user must have completed authentication. This prevents unauthorized relaying. The patch ends up adjusting quite a few tests, as they were not written considering these restrictions so they have to be changed accordingly.
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// Split an user@domain address into user and domain.
|
||||
func split(addr string) (string, string) {
|
||||
func Split(addr string) (string, string) {
|
||||
ps := strings.SplitN(addr, "@", 2)
|
||||
if len(ps) != 2 {
|
||||
return addr, ""
|
||||
@@ -19,12 +19,12 @@ func split(addr string) (string, string) {
|
||||
}
|
||||
|
||||
func UserOf(addr string) string {
|
||||
user, _ := split(addr)
|
||||
user, _ := Split(addr)
|
||||
return user
|
||||
}
|
||||
|
||||
func DomainOf(addr string) string {
|
||||
_, domain := split(addr)
|
||||
_, domain := Split(addr)
|
||||
return domain
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user