Permissions

Three Microsoft apps in your own tenant (A1-A3), plus one optional one: the filing app for mail filing, copies and moves. All are single tenant ("accounts in this organizational directory only") and use certificates instead of client secrets. The server generates the private keys of A1-A3 and the filing app and keeps them; you upload only the public certificate to each app. With the tenant-wide roles BJOERN reads all SharePoint sites, including subsites and sites created later, and the mailboxes an administrator released; directory reads support the permission checks.

A1 BJOERN sign-in

Upload the sign-in public certificate to this app as well.

Item Value
Redirect URIs (Web) https://<host>/console/callback, https://<host>/oidc/callback and https://<host>/console/microsoft/callback
Microsoft Graph, delegated openid (37f7f235-527c-4136-accd-4a02d197296e) and profile (14dad69e-099b-42c9-810b-d002981feec1), admin consent; profile carries the user's object ID (oid) into the ID token
Optional ID token claims auth_time and amr
App roles value BJOERN.Admin (display "BJOERN admin") and value BJOERN.User (display "BJOERN user"), both member type User
Enterprise app Assignment required = Yes. Assign each admin to BJOERN.Admin and each person who connects an AI to BJOERN.User, directly or through a group. Never use default access: it does not supply the role BJOERN requires
MFA A Conditional Access policy "require multifactor authentication" for the enterprise app BJOERN sign-in, assigned to the BJOERN admin and user groups (Entra ID P1); BJOERN checks that the signed token's amr contains mfa. Security Defaults alone is not enough because ordinary-user MFA is risk-dependent

A2 BJOERN reading

A2 reads the files of every SharePoint site with the application permission Sites.Read.All; BJOERN finds new sites every 15 minutes. The required-grants table in chapter 9 matches the console and the Entra script and says what BJOERN does with each permission. Before you grant the tenant-wide roles, run the checks of What BJOERN mirrors. Personal OneDrives are listed explicitly.

Mail: Exchange RBAC for Applications

Status: (available after qualification). An Exchange Administrator with Organization Management membership or delegated application-role assignment authority configures both apps in Exchange Online PowerShell:

  1. Connect-ExchangeOnline. For a new group, run New-DistributionGroup -Name "BJOERN released mailboxes" -Type Security once. Add each intended user mailbox directly with Add-DistributionGroupMember -Identity "BJOERN released mailboxes" -Member <primary mailbox address>. Obtain the group's distinguished name with Get-DistributionGroup -Identity "BJOERN released mailboxes" | Select-Object DistinguishedName.
  2. New-ManagementScope -Name "BJOERN released mailboxes" -RecipientRestrictionFilter "MemberOfGroup -eq '<group DN>'"
  3. New-ServicePrincipal -AppId <A2 app id> -ObjectId <A2 enterprise-app object id> -DisplayName "BJOERN reading"
  4. New-ManagementRoleAssignment -App <A2 app id> -Role "Application Mail.Read" -CustomResourceScope "BJOERN released mailboxes"
  5. New-ServicePrincipal -AppId <A3 app id> -ObjectId <A3 enterprise-app object id> -DisplayName "BJOERN rights mirror"
  6. New-ManagementRoleAssignment -App <A3 app id> -Role "Application MailboxSettings.Read" -CustomResourceScope "BJOERN released mailboxes"
  7. Run Test-ServicePrincipalAuthorization -Identity <A2 app id> -Resource <mailbox> for a group member and an unreleased mailbox; repeat with A3's app ID. Expect InScope = True for each app's assigned role on the member and False outside the group. Review Get-ManagementRoleAssignment -RoleAssignee <enterprise-app object id> for each app to confirm the roles and custom resource scope above.
  8. Allow up to two hours for application access to reflect the grants. Enter the user mailbox's primary SMTP address in the wizard and choose Test connection.

Take -ObjectId from Entra > Enterprise applications > the app > Object ID; take -AppId from its Application (client) ID. Keep the mail roles in Exchange and retain the Entra grants of the required-grants table. Exchange and Entra grants are additive; the authorization command checks Exchange assignments only. Review Entra's API permissions and existing admin-consent grants separately. For upgrades, remove A3's previous Exchange.ManageAsApp API permission and admin-consent grant and retire its old View-Only Recipients role-group membership.

BJOERN uses A3's User.Read.All to resolve exactly one account with the matching primary address, then reads GET /users/{id}/mailboxSettings/userPurpose with A3's scoped Application MailboxSettings.Read. The test accepts user only. Missing access, unresolved addresses and other mailbox types show "Mailbox ... is refused and not saved: only a user mailbox, released by its primary address and in the mirror's MailboxSettings.Read scope, can be read." Correct the scope or address and test again. Saving requires a successful test of the same configuration. A metadata-only A2 request checks effective Exchange reading access as well. Full steps: Microsoft 365 handbook.

A3 BJOERN rights mirror

Reads the rights structure only, no content; own certificate and schedule. Status: available for released SharePoint sites through the installed rights controller. Site access and complete, current rights evidence are required; serving stays closed while that evidence is missing or stale. Mailbox rights are a separate capability.

Use the required-grants table. A3 uses its certificate and GET-only transports for permission reads. Per-user rights checks at search remain the access gate.

Filing app (optional)

Only with a mail kit and only when you use mail filing, copies to folders or moving files. It writes with the signed-in person's own rights, only after that person confirms each job; nothing is deleted. Full steps: Mail filing.

Item Value
Redirect URI (Web) https://<host>/console/mail-filing/callback
Microsoft Graph, delegated openid, profile (carries the person's object ID oid), offline_access, Files.ReadWrite.All
Application permissions none
Not used Mail.*, Sites.FullControl.All (a grant with them is refused)
Credential its own certificate, written by admin.sh mail-filing

Groups

Groups are optional. Assign people directly to BJOERN.Admin or BJOERN.User, or assign a group to the role (group assignment needs Entra ID P1 for each member). Only people holding a role can sign in.