HSTSEnforcer
Superclasses: Object
Subclasses: HSTSEnforcerDB
Implemented Interfaces: SessionFeature
- Constructors:
HSTSEnforcer(**properties)
new() -> Soup.HSTSEnforcer
Constructors
- class HSTSEnforcer
- classmethod new() HSTSEnforcer
Creates a new
HSTSEnforcer
.The base
HSTSEnforcer
class does not support persistent storage of HSTS policies, seeHSTSEnforcerDB
for that.
Methods
- class HSTSEnforcer
- get_domains(session_policies: bool) list[str]
Gets a list of domains for which there are policies in
enforcer
.- Parameters:
session_policies – whether to include session policies
- get_policies(session_policies: bool) list[HSTSPolicy]
Gets a list with the policies in
enforcer
.- Parameters:
session_policies – whether to include session policies
- has_valid_policy(domain: str) bool
Gets whether
hsts_enforcer
has a currently valid policy fordomain
.- Parameters:
domain – a domain.
- set_policy(policy: HSTSPolicy) None
Sets
policy
tohsts_enforcer
.If
policy
is expired, any existing HSTS policy for its host will be removed instead. If a policy existed for this host, it will be replaced. Otherwise, the new policy will be inserted. If the policy is a session policy, that is, one created withnew_session_policy
, the policy will not expire and will be enforced during the lifetime ofhsts_enforcer
’sSession
.- Parameters:
policy – the policy of the HSTS host
- set_session_policy(domain: str, include_subdomains: bool) None
Sets a session policy for
domain
.A session policy is a policy that is permanent to the lifetime of
hsts_enforcer
’sSession
and doesn’t expire.- Parameters:
domain – policy domain or hostname
include_subdomains –
True
if the policy applies on sub domains
Signals
- class HSTSEnforcer.signals
- changed(old_policy: HSTSPolicy, new_policy: HSTSPolicy) None
Emitted when
hsts_enforcer
changes.If a policy has been added,
new_policy
will contain the newly-added policy andold_policy
will beNone
. If a policy has been deleted,old_policy
will contain the to-be-deleted policy andnew_policy
will beNone
. If a policy has been changed,old_policy
will contain its old value, andnew_policy
its new value.Note that you shouldn’t modify the policies from a callback to this signal.
- Parameters:
old_policy – the old
HSTSPolicy
valuenew_policy – the new
HSTSPolicy
value
Virtual Methods
- class HSTSEnforcer
- do_changed(old_policy: HSTSPolicy, new_policy: HSTSPolicy) None
- Parameters:
old_policy
new_policy
Fields
- class HSTSEnforcer
- parent_instance