Soup.HSTSEnforcer

g GObject.GInterface GObject.GInterface Soup.SessionFeature Soup.SessionFeature GObject.GInterface->Soup.SessionFeature GObject.Object GObject.Object Soup.HSTSEnforcer Soup.HSTSEnforcer GObject.Object->Soup.HSTSEnforcer Soup.SessionFeature->Soup.HSTSEnforcer

Subclasses:

Soup.HSTSEnforcerDB

Methods

Inherited:

GObject.Object (37), Soup.SessionFeature (5)

Structs:

GObject.ObjectClass (5)

class

new ()

get_domains (session_policies)

get_policies (session_policies)

has_valid_policy (domain)

is_persistent ()

set_policy (policy)

set_session_policy (domain, include_subdomains)

Virtual Methods

Inherited:

GObject.Object (7), Soup.SessionFeature (8)

do_changed (old_policy, new_policy)

do_has_valid_policy (domain)

do_hsts_enforced (message)

do_is_persistent ()

Properties

None

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

Emitted when hsts_enforcer changes.

hsts-enforced

Emitted when hsts_enforcer has upgraded the protocol for message to HTTPS as a result of matching its domain with a HSTS policy.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Soup.HSTSEnforcer(**kwargs)
Bases:

GObject.Object, Soup.SessionFeature

Abstract:

No

Structure:

Soup.HSTSEnforcerClass

classmethod new()
Returns:

a new Soup.HSTSEnforcer

Return type:

Soup.HSTSEnforcer

Creates a new Soup.HSTSEnforcer. The base Soup.HSTSEnforcer class does not support persistent storage of HSTS policies, see Soup.HSTSEnforcerDB for that.

New in version 2.68.

get_domains(session_policies)
Parameters:

session_policies (bool) – whether to include session policies

Returns:

a newly allocated list of domains. Use g_list_free_full() and GLib.free() to free the list.

Return type:

[str]

Gets a list of domains for which there are policies in enforcer.

New in version 2.68.

get_policies(session_policies)
Parameters:

session_policies (bool) – whether to include session policies

Returns:

a newly allocated list of policies. Use g_list_free_full() and Soup.HSTSPolicy.free() to free the list.

Return type:

[Soup.HSTSPolicy]

Gets a list with the policies in enforcer.

New in version 2.68.

has_valid_policy(domain)
Parameters:

domain (str) – a domain.

Returns:

True if access to domain should happen over HTTPS, false otherwise.

Return type:

bool

Gets whether self has a currently valid policy for domain.

New in version 2.68.

is_persistent()
Returns:

True if self storage is persistent or False otherwise.

Return type:

bool

Gets whether self stores policies persistenly.

New in version 2.68.

set_policy(policy)
Parameters:

policy (Soup.HSTSPolicy) – the policy of the HSTS host

Sets policy to self. 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 with Soup.HSTSPolicy.new_session_policy(), the policy will not expire and will be enforced during the lifetime of self's Soup.Session.

New in version 2.68.

set_session_policy(domain, include_subdomains)
Parameters:
  • domain (str) – policy domain or hostname

  • include_subdomains (bool) – True if the policy applies on sub domains

Sets a session policy for domain. A session policy is a policy that is permanent to the lifetime of self's Soup.Session and doesn’t expire.

New in version 2.68.

do_changed(old_policy, new_policy) virtual
Parameters:
do_has_valid_policy(domain) virtual
Parameters:

domain (str) – a domain.

Returns:

True if access to domain should happen over HTTPS, false otherwise.

Return type:

bool

Gets whether hsts_enforcer has a currently valid policy for domain.

New in version 2.68.

do_hsts_enforced(message) virtual
Parameters:

message (Soup.Message) –

do_is_persistent() virtual
Returns:

True if hsts_enforcer storage is persistent or False otherwise.

Return type:

bool

Gets whether hsts_enforcer stores policies persistenly.

New in version 2.68.

Signal Details

Soup.HSTSEnforcer.signals.changed(h_s_t_s_enforcer, old_policy, new_policy)
Signal Name:

changed

Flags:

RUN_FIRST

Parameters:

Emitted when hsts_enforcer changes. If a policy has been added, new_policy will contain the newly-added policy and old_policy will be None. If a policy has been deleted, old_policy will contain the to-be-deleted policy and new_policy will be None. If a policy has been changed, old_policy will contain its old value, and new_policy its new value.

Note that you shouldn’t modify the policies from a callback to this signal.

Soup.HSTSEnforcer.signals.hsts_enforced(h_s_t_s_enforcer, message)
Signal Name:

hsts-enforced

Flags:

RUN_FIRST

Parameters:
  • h_s_t_s_enforcer (Soup.HSTSEnforcer) – The object which received the signal

  • message (Soup.Message) – the message for which HSTS is being enforced

Emitted when hsts_enforcer has upgraded the protocol for message to HTTPS as a result of matching its domain with a HSTS policy.