1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-19 14:57:04 +00:00

Normalize local usernames using PRECIS

This patch implements local username normalization using PRECIS
(https://tools.ietf.org/html/rfc7564,
https://tools.ietf.org/html/rfc7613)

It makes chasquid accept local email and authentication regardless of
the case. It covers both userdb and aliases.

Note that non-local usernames remain untouched.
This commit is contained in:
Alberto Bertogli
2016-10-09 13:18:19 +01:00
parent 220b5d20ff
commit ad25706d72
8 changed files with 148 additions and 43 deletions

View File

@@ -19,6 +19,8 @@
// is a tradeoff between flexibility and keeping the file format easy to edit
// for people.
//
// User names will be normalized internally to lower-case.
//
// Usually there will be one database per domain, and there's no need to
// include the "@" in the user (in this case, "@" will be forbidden).
//
@@ -59,6 +61,7 @@ import (
"sync"
"blitiri.com.ar/go/chasquid/internal/envelope"
"blitiri.com.ar/go/chasquid/internal/normalize"
)
// Recipient represents a single recipient, after resolving aliases.
@@ -176,6 +179,7 @@ func (v *Resolver) cleanIfLocal(addr string) string {
user = removeAllAfter(user, v.SuffixSep)
user = removeChars(user, v.DropChars)
user, _ = normalize.User(user)
return user + "@" + domain
}
@@ -277,6 +281,7 @@ func parseFile(domain, path string) (map[string][]Recipient, error) {
}
addr = addr + "@" + domain
addr, _ = normalize.Addr(addr)
if rawalias[0] == '|' {
cmd := strings.TrimSpace(rawalias[1:])