Skip to content

Commit b53c265

Browse files
author
Jeremy Harris
committed
EXTERNAL authenticator
(cherry picked from commit c4a8c66)
1 parent 37942ad commit b53c265

File tree

21 files changed

+652
-9
lines changed

21 files changed

+652
-9
lines changed

doc/doc-docbook/spec.xfpt

Lines changed: 148 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26128,6 +26128,7 @@ included by setting
2612826128
AUTH_CRAM_MD5=yes
2612926129
AUTH_CYRUS_SASL=yes
2613026130
AUTH_DOVECOT=yes
26131+
AUTH_EXTERNAL=yes
2613126132
AUTH_GSASL=yes
2613226133
AUTH_HEIMDAL_GSSAPI=yes
2613326134
AUTH_PLAINTEXT=yes
@@ -26139,15 +26140,20 @@ authentication mechanism (RFC 2195), and the second provides an interface to
2613926140
the Cyrus SASL authentication library.
2614026141
The third is an interface to Dovecot's authentication system, delegating the
2614126142
work via a socket interface.
26142-
The fourth provides an interface to the GNU SASL authentication library, which
26143+
.new
26144+
The fourth provides for negotiation of authentication done via non-SMTP means,
26145+
as defined by RFC 4422 Appendix A.
26146+
.wen
26147+
The fifth provides an interface to the GNU SASL authentication library, which
2614326148
provides mechanisms but typically not data sources.
26144-
The fifth provides direct access to Heimdal GSSAPI, geared for Kerberos, but
26149+
The sixth provides direct access to Heimdal GSSAPI, geared for Kerberos, but
2614526150
supporting setting a server keytab.
26146-
The sixth can be configured to support
26151+
The seventh can be configured to support
2614726152
the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
26148-
not formally documented, but used by several MUAs. The seventh authenticator
26153+
not formally documented, but used by several MUAs.
26154+
The eighth authenticator
2614926155
supports Microsoft's &'Secure Password Authentication'& mechanism.
26150-
The eighth is an Exim authenticator but not an SMTP one;
26156+
The last is an Exim authenticator but not an SMTP one;
2615126157
instead it can use information from a TLS negotiation.
2615226158

2615326159
The authenticators are configured using the same syntax as other drivers (see
@@ -27382,6 +27388,143 @@ msn:
2738227388

2738327389

2738427390

27391+
. ////////////////////////////////////////////////////////////////////////////
27392+
. ////////////////////////////////////////////////////////////////////////////
27393+
27394+
.chapter "The external authenticator" "CHAPexternauth"
27395+
.scindex IIDexternauth1 "&(external)& authenticator"
27396+
.scindex IIDexternauth2 "authenticators" "&(external)&"
27397+
.cindex "authentication" "Client Certificate"
27398+
.cindex "authentication" "X509"
27399+
.cindex "Certificate-based authentication"
27400+
The &(external)& authenticator provides support for
27401+
authentication based on non-SMTP information.
27402+
The specification is in RFC 4422 Appendix A
27403+
(&url(https://tools.ietf.org/html/rfc4422)).
27404+
It is only a transport and negotiation mechanism;
27405+
the process of authentication is entirely controlled
27406+
by the server configuration.
27407+
27408+
The client presents an identity in-clear.
27409+
It is probably wise for a server to only advertise,
27410+
and for clients to only attempt,
27411+
this authentication method on a secure (eg. under TLS) connection.
27412+
27413+
One possible use, compatible with the
27414+
K-9 Mail Andoid client (&url(https://k9mail.github.io/)),
27415+
is for using X509 client certificates.
27416+
27417+
It thus overlaps in function with the TLS authenticator
27418+
(see &<<CHAPtlsauth>>&)
27419+
but is a full SMTP SASL authenticator
27420+
rather than being implicit for TLS-connection carried
27421+
client certificates only.
27422+
27423+
The examples and discussion in this chapter assume that
27424+
client-certificate authentication is being done.
27425+
27426+
The client must present a certificate,
27427+
for which it must have been requested via the
27428+
&%tls_verify_hosts%& or &%tls_try_verify_hosts%& main options
27429+
(see &<<CHAPTLS>>&).
27430+
For authentication to be effective the certificate should be
27431+
verifiable against a trust-anchor certificate known to the server.
27432+
27433+
.section "External options" "SECTexternsoptions"
27434+
.cindex "options" "&(external)& authenticator (server)"
27435+
The &(external)& authenticator has two server options:
27436+
27437+
.option server_param2 external string&!! unset
27438+
.option server_param3 external string&!! unset
27439+
.cindex "variables (&$auth1$& &$auth2$& etc)" "in &(external)& authenticator"
27440+
These options are expanded before the &%server_condition%& option
27441+
and the result are placed in &$auth2$& and &$auth3$& resectively.
27442+
If the expansion is forced to fail, authentication fails. Any other expansion
27443+
failure causes a temporary error code to be returned.
27444+
27445+
They can be used to clarify the coding of a complex &%server_condition%&.
27446+
27447+
.section "Using external in a server" "SECTexternserver"
27448+
.cindex "AUTH" "in &(external)& authenticator"
27449+
.cindex "numerical variables (&$1$& &$2$& etc)" &&&
27450+
"in &(external)& authenticator"
27451+
.vindex "&$auth1$&, &$auth2$&, etc"
27452+
.cindex "base64 encoding" "in &(external)& authenticator"
27453+
27454+
When running as a server, &(external)& performs the authentication test by
27455+
expanding a string. The data sent by the client with the AUTH command, or in
27456+
response to subsequent prompts, is base64 encoded, and so may contain any byte
27457+
values when decoded. The decoded value is treated as
27458+
an identity for authentication and
27459+
placed in the expansion variable &$auth1$&.
27460+
27461+
For compatibility with previous releases of Exim, the value is also placed in
27462+
the expansion variable &$1$&. However, the use of this
27463+
variable for this purpose is now deprecated, as it can lead to confusion in
27464+
string expansions that also use them for other things.
27465+
27466+
.vindex "&$authenticated_id$&"
27467+
Once an identity has been received,
27468+
&%server_condition%& is expanded. If the expansion is forced to fail,
27469+
authentication fails. Any other expansion failure causes a temporary error code
27470+
to be returned. If the result of a successful expansion is an empty string,
27471+
&"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
27472+
expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds and the
27473+
generic &%server_set_id%& option is expanded and saved in &$authenticated_id$&.
27474+
For any other result, a temporary error code is returned, with the expanded
27475+
string as the error text.
27476+
27477+
Example:
27478+
.code
27479+
ext_ccert_san_mail:
27480+
driver = external
27481+
public_name = EXTERNAL
27482+
27483+
server_advertise_condition = $tls_in_certificate_verified
27484+
server_param2 = ${certextract {subj_altname,mail,>:} \
27485+
{$tls_in_peercert}}
27486+
server_condition = ${if forany {$auth2} \
27487+
{eq {$item}{$auth1}}}
27488+
server_set_id = $auth1
27489+
.endd
27490+
This accepts a client certificate that is verifiable against any
27491+
of your configured trust-anchors
27492+
(which usually means the full set of public CAs)
27493+
and which has a mail-SAN matching the claimed identity sent by the client.
27494+
27495+
Note that, up to TLS1.2, the client cert is on the wire in-clear, including the SAN,
27496+
The account name is therefore guessable by an opponent.
27497+
TLS 1.3 protects both server and client certificates, and is not vulnerable
27498+
in this way.
27499+
Likewise, a traditional plaintext SMTP AUTH done inside TLS is not.
27500+
27501+
27502+
.section "Using external in a client" "SECTexternclient"
27503+
.cindex "options" "&(external)& authenticator (client)"
27504+
The &(external)& authenticator has one client option:
27505+
27506+
.option client_send external string&!! unset
27507+
This option is expanded and sent with the AUTH command as the
27508+
identity being asserted.
27509+
27510+
Example:
27511+
.code
27512+
ext_ccert:
27513+
driver = external
27514+
public_name = EXTERNAL
27515+
27516+
client_condition = ${if !eq{$tls_out_cipher}{}}
27517+
client_send = myaccount@smarthost.example.net
27518+
.endd
27519+
27520+
27521+
.ecindex IIDexternauth1
27522+
.ecindex IIDexternauth2
27523+
27524+
27525+
27526+
27527+
2738527528
. ////////////////////////////////////////////////////////////////////////////
2738627529
. ////////////////////////////////////////////////////////////////////////////
2738727530

doc/doc-txt/NewStuff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ the documentation is updated, this file is reduced to a short list.
99
Version 4.93
1010
------------
1111

12-
(none yet)
12+
1. An "external" authenticator, per RFC 4422 Appendix A.
1313

1414

1515
Version 4.92

doc/doc-txt/OptionLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ client_ignore_invalid_base64 boolean false plaintext
132132
client_name string* + cram_md5 3.10
133133
client_secret string* unset cram_md5 3.10
134134
client_send string* unset plaintext 3.10
135+
client_send string* unset external (auth) 4.93
135136
command string* unset lmtp 3.20
136137
unset pipe
137138
unset queryprogram 4.00
@@ -501,6 +502,8 @@ server_password string unset gsasl
501502
server_param1 string* unset tls (auth) 4.86
502503
server_param2 string* unset tls (auth) 4.86
503504
server_param3 string* unset tls (auth) 4.86
505+
server_param2 string* unset tls (auth) 4.86 (tls-only) 4.93 (external)
506+
server_param3 string* unset tls (auth) 4.86 (tls-only) 4.93 (external)
504507
server_prompts string* unset plaintext 3.10
505508
server_realm string unset cyrus_sasl,gsasl 4.43 (cyrus-only) 4.80 (others)
506509
server_scram_iter string* unset gsasl 4.80

src/OS/Makefile-Base

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ OBJ_MACRO = macro_predef.o \
135135
macro-smtp.o macro-accept.o macro-dnslookup.o macro-ipliteral.o macro-iplookup.o \
136136
macro-manualroute.o macro-queryprogram.o macro-redirect.o \
137137
macro-auth-spa.o macro-cram_md5.o macro-cyrus_sasl.o macro-dovecot.o macro-gsasl_exim.o \
138-
macro-heimdal_gssapi.o macro-plaintext.o macro-spa.o macro-authtls.o \
138+
macro-heimdal_gssapi.o macro-plaintext.o macro-spa.o macro-authtls.o macro-external.o \
139139
macro-dkim.o macro-malware.o macro-signing.o
140140

141141
$(OBJ_MACRO): $(MACRO_HSRC)
@@ -212,6 +212,9 @@ macro-cyrus_sasl.o : auths/cyrus_sasl.c
212212
macro-dovecot.o: auths/dovecot.c
213213
@echo "$(CC) -DMACRO_PREDEF auths/dovecot.c"
214214
$(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/dovecot.c
215+
macro-external.o: auths/external.c
216+
@echo "$(CC) -DMACRO_PREDEF auths/external.c"
217+
$(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/external.c
215218
macro-gsasl_exim.o : auths/gsasl_exim.c
216219
@echo "$(CC) -DMACRO_PREDEF auths/gsasl_exim.c"
217220
$(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/gsasl_exim.c

src/scripts/MakeLinks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ for f in README Makefile call_pam.c call_pwcheck.c \
7575
gsasl_exim.h get_data.c get_no64_data.c heimdal_gssapi.c heimdal_gssapi.h \
7676
md5.c xtextencode.c xtextdecode.c cram_md5.c cram_md5.h plaintext.c plaintext.h \
7777
pwcheck.c pwcheck.h auth-spa.c auth-spa.h dovecot.c dovecot.h sha1.c spa.c \
78-
spa.h tls.c tls.h
78+
spa.h tls.c tls.h external.c external.h
7979
do
8080
ln -s ../../src/auths/$f $f
8181
done

src/src/EDITME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ FIXED_NEVER_USERS=root
643643
# AUTH_CRAM_MD5=yes
644644
# AUTH_CYRUS_SASL=yes
645645
# AUTH_DOVECOT=yes
646+
# AUTH_EXTERNAL=yes
646647
# AUTH_GSASL=yes
647648
# AUTH_GSASL_PC=libgsasl
648649
# AUTH_HEIMDAL_GSSAPI=yes

src/src/auths/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
OBJ = auth-spa.o call_pam.o call_pwcheck.o \
99
call_radius.o check_serv_cond.o cram_md5.o cyrus_sasl.o dovecot.o \
10-
get_data.o get_no64_data.o gsasl_exim.o heimdal_gssapi.o \
10+
external.o get_data.o get_no64_data.o gsasl_exim.o heimdal_gssapi.o \
1111
md5.o plaintext.o pwcheck.o \
1212
spa.o tls.o xtextdecode.o xtextencode.o
1313

@@ -36,6 +36,7 @@ xtextencode.o: $(HDRS) xtextencode.c
3636
cram_md5.o: $(HDRS) cram_md5.c cram_md5.h
3737
cyrus_sasl.o: $(HDRS) cyrus_sasl.c cyrus_sasl.h
3838
dovecot.o: $(HDRS) dovecot.c dovecot.h
39+
external.o: $(HDRS) external.c external.h
3940
gsasl_exim.o: $(HDRS) gsasl_exim.c gsasl_exim.h
4041
heimdal_gssapi.o: $(HDRS) heimdal_gssapi.c heimdal_gssapi.h
4142
plaintext.o: $(HDRS) plaintext.c plaintext.h

0 commit comments

Comments
 (0)