Driver contract#
What a driver must declare and satisfy.
To write one, follow How to write a driver. This page is the checklist.
The interface#
Attributes#
Attribute |
Purpose |
|---|---|
|
Unique id, such as |
|
Shown in the control panel. |
|
The schema the configuration form is generated from. |
|
Tuple of scopes requested when the provider names none. |
|
Claim keys tried, in order, to find the subject. |
|
Claim path → Plone property, seeded into a new provider. |
|
The claim groups arrive in, or empty for a provider with none. |
|
Provider group → local group. Empty for every shipped driver. |
|
Whether this provider's verification counts by default. |
|
Whether an identity may be linked from the account page. |
Base class defaults (core/drivers/base.py): settings_schema is
IOAuth2Settings, default_scope is (), subject_keys is ('sub',),
default_group_claim is '', default_trust_email_verification is False.
Methods#
Method |
Contract |
|---|---|
|
Turn the provider's payload into this package's claim names. |
|
The stable identifier. Raises when no key in |
BaseDriver also provides enrichment_endpoint, merge_enrichment,
reported_addresses and _email_verified for drivers that need a second call to
the provider.
The rules#
Each is a rule a driver must satisfy, and what catches a violation.
# |
Rule |
Enforced by |
|---|---|---|
1 |
A field marked secret stays secret: masked on the way out of every API surface, omitted from GenericSetup export. Do not invent your own credential storage. |
the serializers and the export tests |
2 |
Every field has an |
the driver contract test—a tie fails it rather than falling back to the alphabet |
3 |
|
the contract test |
4 |
|
the contract test; |
5 |
|
the contract test |
6 |
|
convention; every shipped driver is empty |
7 |
|
the contract test and |
8 |
|
review; only |
Why order is a number#
A configuration schema travels as a JSON object, and plone.restapi serializes
those with sorted keys, so the order fields are declared in is gone by the time
the control panel builds a form. The number is what survives.
The inherited fields are spaced by ten, so a new field can be slotted between two of them.
Why only True counts#
Several providers send the string "true", and several send 1. Everything that
reads the flag refuses anything that is not literally True, because a forged
unverified address that reads as truthy is an account takeover.
A provider that really does send a string is handled by the per-provider
accept_string_booleans switch, not by a driver being lenient.
Why an empty group claim is not neutral#
Leaving default_group_claim empty switches the feature off for that driver: no
group_claim field appears in the configuration form, and nobody is asked to map
the groups of a provider that has none.
A map stored against such a provider grants nothing rather than guessing at a claim name.
Operators can override the claim with a dotted path, so a provider nesting groups
under realm_access.roles needs no driver of its own.
Registration#
A driver is a named utility providing IDriver, registered under its
driver_id. The control panel lists whatever is registered, and the form comes
from settings_schema, so a third-party driver needs no frontend change.