19
19
Package for parsing ``Authentication-Results`` headers as defined in RFC 5451.
20
20
Optional support for authentication methods defined in RFCs 5617, 6008, 6212,
21
7489 and draft-ietf-dmarc-arc-protocol-05.
21
and draft-kucherawy-dmarc-base-01.
23
23
>>> str(authres.AuthenticationResultsHeader('test.example.org', version=1))
24
24
'Authentication-Results: test.example.org 1; none'
525
525
... results = [mfrom_pass, helo_none]))
526
526
'Authentication-Results: example.com; spf=pass smtp.mailfrom=authenticated@example.net; spf=none reason="No SPF record for HELO" smtp.helo=mailserver.example.net'
528
# Create header field with ARC results (draft-ietf-dmarc-arc-protocol-05)
530
>>> import authres.arc
531
>>> arc_pass = authres.arc.ARCAuthenticationResult(result = 'pass',
532
... header_ams_d = 'example.net', header_ams_s='valimail2016', header_as_d="example.com", header_as_s="valimail2017")
533
>>> str(authres.AuthenticationResultsHeader(authserv_id = 'example.com',
534
... results = [arc_pass]))
535
'Authentication-Results: example.com; arc=pass header.ams-d=example.net header.ams-s=valimail2016 header.as-d=example.com header.as-s=valimail2017'
537
528
# Parsing IP6 address.
538
529
>>> arobj = authres_context.parse('Authentication-Results: mail.bmsi.com; iprev=pass policy.iprev="2001:748:100:40::2:2" (mout0.freenet.de); spf=none smtp.mailfrom=markuslaudi@freenet.de')
539
530
>>> str(arobj.results[0])
590
# RFC 7293, The Require-Recipient-Valid-Since Header Field and SMTP Service Extension, header field types
592
# Example 12.3 from RFC 7293
593
>>> import authres.rrvs
594
>>> rrvsarobj = authres_context.parse('Authentication-Results: mx.example.com; rrvs=pass smtp.rcptto=user@example.com')
595
>>> str(rrvsarobj.authserv_id)
597
>>> str(rrvsarobj.results[0].method)
599
>>> str(rrvsarobj.results[0].result)
601
>>> str(rrvsarobj.results[0].reason)
603
>>> str(rrvsarobj.results[0].properties[0].type)
605
>>> str(rrvsarobj.results[0].properties[0].name)
607
>>> str(rrvsarobj.results[0].properties[0].value)
610
>>> import authres.rrvs
611
>>> rrvs_fail = authres.rrvs.RRVSAuthenticationResult(result = 'fail', result_comment = 'Mail box expired.', smtp_rrvs = 'user@example.com', smtp_rrvs_comment = "These are not the droids you're looking for.")
612
>>> str(authres.AuthenticationResultsHeader(authserv_id='example.net',results = [rrvs_fail]))
613
"Authentication-Results: example.net; rrvs=fail (Mail box expired.) smtp.rrvs=user@example.com (These are not the droids you're looking for.)"
615
# New for RFC 7601 SMTP Auth Mail From
618
>>> arobj = authres.AuthenticationResultsHeader.parse('Authentication-Results: example.com; auth=pass smtp.mailfrom=sender@example.net')
619
>>> str(arobj.authserv_id)
621
>>> str(arobj.results[0])
622
'auth=pass smtp.mailfrom=sender@example.net'
623
>>> str(arobj.results[0].method)
625
>>> str(arobj.results[0].result)
627
>>> str(arobj.results[0].smtp_mailfrom)
629
>>> str(arobj.results[0].properties[0].type)
631
>>> str(arobj.results[0].properties[0].name)
633
>>> str(arobj.results[0].properties[0].value)
636
# Create header field with RFC 7601 SMTP Auth Mail From
638
>>> mfrom_auth = authres.SMTPAUTHAuthenticationResult(result = 'pass',
639
... smtp_mailfrom = 'mailauth@example.net')
640
>>> str(authres.AuthenticationResultsHeader(authserv_id = 'example.com',
641
... results = [mfrom_auth]))
642
'Authentication-Results: example.com; auth=pass smtp.mailfrom=mailauth@example.net'