s365b.setup.provision

Create or update the app registrations with a delegated admin token.

Idempotent: apps are found again by their s365b:<purpose> tag and updated in place, so the wizard can be re-run (to add permissions for a newly enabled module, renew certificates, or repair a half-finished run).

Entra replicates new objects between regions for a few seconds; calls that depend on a just-created object are retried.

Attributes

Exceptions

ProvisionError

Provisioning cannot continue. The message is safe to show.

Classes

AppPlan

What one app registration should look like.

AppResult

An app registration after provisioning.

ProvisionResult

Everything the wizard needs to store.

Provisioner

Creates and updates app registrations in one tenant.

Functions

role_id(value) → str

Stable ID for one of the sign-in app's roles (same in every tenant).

Module Contents

s365b.setup.provision.GRAPH_APP_ID = '00000003-0000-0000-c000-000000000000'[source]
s365b.setup.provision.SIGNIN_SCOPES = ('openid', 'profile', 'email', 'User.Read')[source]
s365b.setup.provision.DISPLAY_NAMES[source]
s365b.setup.provision.StepStatus[source]
s365b.setup.provision.Report[source]
exception s365b.setup.provision.ProvisionError[source]

Bases: Exception

Provisioning cannot continue. The message is safe to show.

s365b.setup.provision.role_id(value: str) → str[source]

Stable ID for one of the sign-in app’s roles (same in every tenant).

Parameters:

value – App role value such as S365B.Admin.

Returns:

The role’s GUID.

class s365b.setup.provision.AppPlan[source]

What one app registration should look like.

Variables:
  • purpose – Which app.

  • app_permissions – Microsoft Graph application permissions to grant.

  • delegated_scopes – Graph delegated scopes to consent for all users.

  • redirect_uri – Web redirect URI (sign-in app only).

  • previous_certificate – Base64 DER of the certificate in use now. It stays registered next to the new one, so running jobs and not-yet-replicated Entra servers keep working during rotation; the next rotation drops it.

purpose: s365b.db.models.AppPurpose[source]
app_permissions: frozenset[str][source]
delegated_scopes: tuple[str, ...] = ()[source]
redirect_uri: str | None = None[source]
previous_certificate: str | None = None[source]
class s365b.setup.provision.AppResult[source]

An app registration after provisioning.

Variables:
  • purpose – Which app.

  • client_id – Application (client) ID.

  • object_id – Application object ID.

  • service_principal_id – Enterprise application object ID.

  • certificate – New credential (private key to be stored encrypted).

  • permissions – Graph application permissions now granted.

purpose: s365b.db.models.AppPurpose[source]
client_id: str[source]
object_id: str[source]
service_principal_id: str[source]
certificate: s365b.setup.certs.AppCertificate[source]
permissions: list[str][source]
class s365b.setup.provision.ProvisionResult[source]

Everything the wizard needs to store.

Variables:
  • tenant_id – Directory ID.

  • tenant_name – Organisation display name.

  • default_domain – Default verified domain.

  • admin_upn – The admin who signed in.

  • apps – Provisioned apps by purpose.

tenant_id: str[source]
tenant_name: str[source]
default_domain: str[source]
admin_upn: str[source]
apps: dict[s365b.db.models.AppPurpose, AppResult][source]
class s365b.setup.provision.Provisioner(graph: s365b.graph.client.GraphClient, report: Report, *, sleep: collections.abc.Callable[[float], collections.abc.Awaitable[None]] = asyncio.sleep)[source]

Creates and updates app registrations in one tenant.

Parameters:
  • graph – Graph client authenticated with the admin’s delegated token.

  • report – Async callback (step, status, detail) for progress.

  • sleep – Sleep function (replaced in tests).

graph[source]
report[source]
sleep[source]
async run(plans: collections.abc.Iterable[AppPlan]) → ProvisionResult[source]

Provision every planned app.

Parameters:

plans – The apps to create or update.

Returns:

Tenant details and the provisioned apps.

Raises: