chapps.spf_policy module
SPF Enforcement policy manager
Isolated here to prevent the core codebase from depending upon the SPF libraries.
- class chapps.spf_policy.PostfixSPFActions[source]
Bases:
chapps.policy.PostfixActions
Postfix Action translator for
chapps.policy.SPFEnforcementPolicy
Caution
The SPF functionality of CHAPPS is not considered complete. YMMV
- __init__(spf_policy, cfg=None)[source]
Create a new PostfixSPFActions instance
- Parameters
spf_policy (SPFEnforcementPolicy) – The SPF policy object which instantiated this actions object
cfg (
Optional
[CHAPPSConfig
]) – Optional config override
The config is normally taken from the
SPFEnforcementPolicy
passed in as the first argument, but that config may be overridden by providing the config argument.
- action_for(spf_result)[source]
Override
chapps.policy.PostfixActions.action_for()
to provide action closures for the different SPF results. The closures are memoized, so that they only need be constructed once per runtime.
- class chapps.spf_policy.SPFEnforcementPolicy[source]
Bases:
chapps.policy.InboundPolicy
Policy manager which enforces SPF policy
Instance attributes (in addition to those of
EmailPolicy
):- actions
a
PostfixSPFActions
instance
Behavior of the SPF enforcer is configured under the
[PostfixSPFActions]
heading in the config file.- redis_key_prefix = 'spf'
For option flag in Redis
- __init__(cfg=None)[source]
Setup an SPF enforcement policy manager
- Parameters
cfg (chapps.config.CHAPPSConfig) – optional config override
- acquire_policy_for(ppr)[source]
Determine whether this PPR’s recipient wants SPF enforcement
- Parameters
ppr (
InboundPPR
) – A PPR representing the email- Raises
NoSuchDomainException
if the recipient domain is not present in the configuration RDBMS- Return type
- enabled(ppr)[source]
Main entry point to determining whether to enforce SPF
- Parameters
ppr (
InboundPPR
) – A PPR representing the email- Return type
Returns a boolean indicating whether to enforce SPF for this recipient.
- Return type
- Parameters
ppr (chapps.inbound.InboundPPR) –