diff --git a/connector/smtp/smtp.go b/connector/smtp/smtp.go index facc651347..548404c006 100644 --- a/connector/smtp/smtp.go +++ b/connector/smtp/smtp.go @@ -58,17 +58,18 @@ func (sc *smtpConnector) Login(ctx context.Context, _ connector.Scopes, username return } - // Add and check domain + // Check domain - at := "@" + sc.cfg.Domain - if !strings.Contains(username, "@") { - username = username + at - } - if !strings.HasSuffix(username, at) { - // username ends in something other than @$DOMAIN, so we reject it. - valid = false - err = nil - return + name, domain, found := strings.Cut(username, "@") + if found { + if domain != sc.cfg.Domain { + // username ends in something other than @$DOMAIN, so we reject it. + valid = false + err = nil + return + } + } else { + username += "@" + sc.cfg.Domain } // Auth and check @@ -87,10 +88,12 @@ func (sc *smtpConnector) Login(ctx context.Context, _ connector.Scopes, username return } + // Prepare id + id = connector.Identity{ UserID: username, - Username: username, - PreferredUsername: username, + Username: name, + PreferredUsername: name, Email: username, EmailVerified: true, } diff --git a/examples/smtp/config-smtp-vvf.yaml b/examples/smtp/config-smtp-vvf.yaml new file mode 100644 index 0000000000..b47c86f598 --- /dev/null +++ b/examples/smtp/config-smtp-vvf.yaml @@ -0,0 +1,23 @@ +issuer: http://127.0.0.1:5556/dex +storage: + type: sqlite3 + config: + file: examples/dex.db +web: + http: 0.0.0.0:5556 + +connectors: +- type: smtp + name: Vigilfuoco + id: smtp-vigilfuoco + config: + host: smtp-s.vigilfuoco.it:465 + domain: vigilfuoco.it + label: Username (nome.cognome) + +staticClients: +- id: example-app + redirectURIs: + - 'http://127.0.0.1:5555/callback' + name: 'Example App' + secret: ZXhhbXBsZS1hcHAtc2VjcmV0