1.16 <SoupHSTSEnforcer>

Class: <SoupHSTSEnforcer>

It derives from <GObject>.

Automatic HTTP Strict Transport Security enforcing for Session.

A HSTSEnforcer stores HSTS policies and enforces them when required. HSTSEnforcer implements SessionFeature, so you can add an HSTS enforcer to a session with Session.add_feature or Session.add_feature_by_type.

HSTSEnforcer keeps track of all the HTTPS destinations that, when connected to, return the Strict-Transport-Security header with valid values. HSTSEnforcer will forget those destinations upon expiry or when the server requests it.

When the Session the HSTSEnforcer is attached to queues or restarts a message, the HSTSEnforcer will rewrite the URI to HTTPS if the destination is a known HSTS host and is contacted over an insecure transport protocol (HTTP). Users of HSTSEnforcer are advised to listen to changes in the Message:uri property in order to be aware of changes in the message URI.

Note that HSTSEnforcer does not support any form of long-term HSTS policy persistence. See HSTSEnforcerDB for a persistent enforcer.

Fields

parent-instance

Procedures

Method: hstsenforcer:get-domains self session-policies ⇒ %return
Method: get-domains self session-policies ⇒ %return

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

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

session-policies

Passed: a boolean.

whether to include session policies

%return

Returned: a list, each a string.

a newly allocated list of domains. Use GLib.List.free_full and byte-array:free to free the list.

Method: hstsenforcer:get-policies self session-policies ⇒ %return
Method: get-policies self session-policies ⇒ %return

Gets a list with the policies in enforcer.

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

session-policies

Passed: a boolean.

whether to include session policies

%return

Returned: a list, each a <SoupHSTSPolicy>.

a newly allocated list of policies. Use GLib.List.free_full and HSTSPolicy.free to free the list.

Method: hstsenforcer:has-valid-policy? self domain ⇒ %return
Method: has-valid-policy? self domain ⇒ %return

Gets whether self has a currently valid policy for domain.

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

domain

Passed: a string.

a domain.

%return

Returned: a boolean.

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

Method: hstsenforcer:is-persistent? self ⇒ %return
Method: is-persistent? self ⇒ %return

Gets whether self stores policies persistenly.

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

%return

Returned: a boolean.

#t if self storage is persistent or #f otherwise.

Procedure: hstsenforcer:new ⇒ %return

Creates a new HSTSEnforcer.

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

%return

Returned: a <SoupHSTSEnforcer>.

a new <SoupHSTSEnforcer>

Method: hstsenforcer:set-policy self policy
Method: set-policy self policy

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 HSTSPolicy.new_session_policy, the policy will not expire and will be enforced during the lifetime of self’s Session.

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

policy

Passed: a <SoupHSTSPolicy>.

the policy of the HSTS host

Method: hstsenforcer:set-session-policy self domain include-subdomains
Method: set-session-policy self domain include-subdomains

Sets a session policy for domain.

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

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

domain

Passed: a string.

policy domain or hostname

include-subdomains

Passed: a boolean.

#t if the policy applies on sub domains

Signals

Signal: hstsenforcer:changed

Connect a handler with (connect object hstsenforcer:changed handler). It is called as (handler self old-policy new-policy).

Emitted when hsts-enforcer changes.

If a policy has been added, new-policy will contain the newly-added policy and old-policy will be #f. If a policy has been deleted, old-policy will contain the to-be-deleted policy and new-policy will be #f. 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.

self

Passed: a <SoupHSTSEnforcer>.

old-policy

Passed: a <SoupHSTSPolicy>.

the old <SoupHSTSPolicy> value

new-policy

Passed: a <SoupHSTSPolicy>.

the new <SoupHSTSPolicy> value

Virtual methods

Virtual method: hstsenforcer:do-changed implementor self old-policy new-policy

The class closure for the "changed" signal.

To override it in a new class, give register-type #:vfuncs `((changed . ,procedure)). The procedure is called as (procedure self old-policy new-policy).

implementor

Passed: the class whose implementation to call: <SoupHSTSEnforcer>, or a class that derives from it, or its GType number.

self

Passed: a <SoupHSTSEnforcer>.

old-policy

Passed: a <SoupHSTSPolicy>.

new-policy

Passed: a <SoupHSTSPolicy>.

Virtual method: hstsenforcer:do-has-valid-policy implementor self domain ⇒ %return

Gets whether self has a currently valid policy for domain.

To override it in a new class, give register-type #:vfuncs `((has-valid-policy . ,procedure)). The procedure is called as (procedure self domain) ⇒ %return.

implementor

Passed: the class whose implementation to call: <SoupHSTSEnforcer>, or a class that derives from it, or its GType number.

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

domain

Passed: a string.

a domain.

%return

Returned: a boolean.

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

Virtual method: hstsenforcer:do-is-persistent implementor self ⇒ %return

Gets whether self stores policies persistenly.

To override it in a new class, give register-type #:vfuncs `((is-persistent . ,procedure)). The procedure is called as (procedure self) ⇒ %return.

implementor

Passed: the class whose implementation to call: <SoupHSTSEnforcer>, or a class that derives from it, or its GType number.

self

Passed: a <SoupHSTSEnforcer>.

a <SoupHSTSEnforcer>

%return

Returned: a boolean.

#t if self storage is persistent or #f otherwise.