Access Services Design - edmozley/freeitsm GitHub Wiki

Access through directory groups - design (#505)

Status: STAGE 1 BUILT (3 December 2026, for 5.19.0) - stages 2 and 3 to come. How it works now: Access services and its Developer Guide. @bigtrodat answered the questions in section 9; where the honest answer was "it depends", the design makes it a choice on each access service - see Decided. Two small checks are still open (section 11). Anyone else who manages access through directory groups is welcome to join in on issue #505.

The request, from @bigtrodat on issue #505:

"This service item could be something like 'Access to Service XYZ'. This service has an owner (and probably a substitute) defined. Also there is an Entra-ID or LDAP group assigned to this service. All members of that group have access. Once the service article request have been approved, requester is added as a member to the group."

Add-on 1: "User can see his assigned services and request cancellation / de-provisioning. Once cancellation / de-provisioning have been approved (to be defined by whom), user is removed from group."

Add-on 2: "Service Owner (what is not necessarily a member of IT department) can see services he/she is responsible for and can see members when a group is assigned. Adding or Removing a member should be possible for the service owner as well."

"This would reduce work load, because maintaining group membership is ~20% of our workload."

In plain words

Today somebody asks for access, the request is approved, and then an analyst opens Entra or Active Directory and adds the person to a group by hand. This design makes FreeITSM do the last step itself, and keeps a record of who has which access and why.

It is built from five parts. Each one is useful on its own, and each reuses something FreeITSM already has.

Part What it does Reuses Size
A. Access services A list of things people can have access to. Each has an owner, a deputy and a directory group The owner and deputy of cost centres; the groups the Entra import already brings in Medium
B. Changing the group Add a person to a group, or take them out - in Entra ID, Active Directory, any other system through a workflow, or by hand The Entra and LDAP connections, the workflow engine's send_webhook, and tasks Medium
C. Who has what One record per person per service: granted when, by which request, removed when and why The way licence seats keep their history Small
D. The owner approves A catalogue item's approval step can be the service's owner, with the deputy standing in The approval steps and the portal Approvals page from #160 Small
E. The portal People see the access they have and ask for it to be removed (add-on 1); owners see who has their services and add or remove people (add-on 2) The portal's Your requests and Approvals pages Medium

Five rules run through all of it:

  1. Nothing changes on upgrade, and nothing is written to a directory until an administrator switches it on. Directory writes are off by default, per directory connection.
  2. Nobody is added or removed without a reason on record: an approved request, or the owner's own action. FreeITSM never adds a person because a sync or a guess says so.
  3. A write that fails is never silent. It is logged, the request says so, and the service owner and the service desk are told, the same way every other failure in FreeITSM is surfaced (Email send log, failed workflow runs on Watchtower).
  4. The directory stays the truth about membership. FreeITSM records why it made each change, and compares that with the group after every import. Someone added in Entra directly is shown as added in the directory, not hidden and not removed.
  5. Choosing, not typing. The group is picked from a list, the owner from the people directory. There are no group ids or LDAP paths to type.

1. What FreeITSM has today

Piece Where State
Entra groups and their members directory_groups, directory_group_members, filled by the Entra import (includes/entra_sync.php) โœ… Read every import. Read-only - the app registration has User.Read.All and GroupMember.Read.All
A person's Entra object id user_sso_identities.source_ref โœ… What a Graph add-member call needs. The OIDC subject must not be used - it is a different value (identity rules)
LDAP / Active Directory includes/ldap.php, includes/directory_sync.php โš ๏ธ People are imported; groups are not - they are read only at sign-in, to decide who may log in. A person's DN is in source_ref
Catalogue item approval forms.approval_steps, catalogueFinishDecision() โœ… Ordered steps; deciders can be a person, a team, the requester's manager or the cost centre owner
Portal approvals self-service/approvals.php โœ… Portal people decide there, with deputy and away handling
Owner + deputy cost_centres.owner_user_id / owner_group_id / deputy_user_id โœ… The pattern to copy
Writing to Entra or AD - โŒ None anywhere. The Starters & leavers module even refuses to change directory-managed people ("disable the account there")
A "service" with an owner - โŒ Neither the CMDB nor Service Status has an owner
Who has which access - โŒ A request is one-way; only a pending request can be cancelled

2. Part A - access services

A new list, Forms -> Access services (beside the catalogue). Each row:

Field Notes
Name and description "Access to the finance share", "SAP - read only"
Owner A person from the people directory (the default), or a people group - the same picker as a cost centre's owner. Need not be IT staff: owners act from the portal
Deputy A person. Stands in for the owner the same way as on cost centres (any time, or only when the owner is away)
Groups One or more, each picked from a list, each with how it is changed (section 3). Most services have one; a service can also mean an application group and a VPN group, or groups in two directories
Removing access Who approves a removal - see the removal choices below. Default: the owner (or deputy)
Keep at least A number of members, blank by default. A removal that would take the service below it is never automatic - it goes to the owner, whatever Removing access says. For a shared directory or a system that must never be left with nobody able to reach it
Owner changes When the owner adds or removes someone: take effect straight away (default) or need a second approval (the owner's manager, or a chosen approver)
Company On a multi-company install, the service belongs to one company; its owner, deputy and members must be in it
Active A retired service keeps its history; nobody can request it

Removing access - one of:

Choice Fits
Nobody needs to approve Giving something up is always allowed - an unused subscription, say
The owner approves (default) The deputy stands in as everywhere else
Use a catalogue item's approval steps Pick a removal item; its ordered approval steps decide, with all the machinery that has (manager, cost centre owner, team, person)

Keep at least overrides the first choice: a removal below the minimum always goes to the owner.

A service with no valid owner (the owner has left or been disabled, and there is no deputy) is shown as needs an owner on the list and on Watchtower, rather than its approvals silently going nowhere.

A catalogue item grants a service: a new choice in the item's settings, When approved, give access to: [service]. The item keeps everything it has today - its questions, its approval steps, its ticket. Granting access is one more thing that happens on approval. One service can be granted by more than one item (an English and a German form, say).

The service's page shows its members (part C), its open requests, and the history of every change.

3. Part B - changing the group

Each group on a service says how membership is changed. Four choices, so the feature works whatever an organisation runs - and so an organisation that will never give FreeITSM write access still gets the request, the approval and the record of who has what:

How it is changed For What happens on an approved add or remove
Entra ID Cloud-only groups Microsoft Graph, below
Active Directory / LDAP On-premises groups, including those synced to Entra The LDAP connection's service account, below
Workflow Any other system - Okta, Google Workspace, an in-house script Fires the trigger Access change approved with merge codes (person, their email and directory ids, service, group, add or remove). A workflow sends it on with the existing send_webhook action and its retries. The far end reports back through the REST API (done or failed with a reason); until then the grant shows Waiting for the other system
By hand No directory, or not automated yet Creates a task for a chosen team: "Add Jane Smith to SG-Finance-Share". Ticking it done completes the grant

A service can move a group from By hand to Entra ID (or from one directory to another) at any time; the people using the portal see no difference.

Entra ID

Two Microsoft Graph calls:

What Call
Add POST /groups/{group-id}/members/$ref with {"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{user-object-id}"}
Remove DELETE /groups/{group-id}/members/{user-object-id}/$ref

They need the application permission GroupMember.ReadWrite.All. That is a much stronger permission than today's read-only ones: it lets the app change the membership of almost any group in the tenant. So:

  • It goes on a separate app registration, used only for writes - Directory writes on the Entra connection, with its own client id and secret. The import keeps its read-only registration. If the write secret ever leaked, the import's would not be the one at risk, and the other way round.
  • Test on that screen asks Microsoft for a token and reads the permissions it carries (the token's roles), without changing anything, and says plainly when GroupMember.ReadWrite.All is missing or has not been granted admin consent.
  • FreeITSM only ever writes to groups that are chosen on an access service. It never offers a write to any other group, whatever the permission would allow.

โš ๏ธ Microsoft refuses two kinds of group, and the design has to say so rather than fail mysteriously:

  • Groups synced from on-premises Active Directory (onPremisesSyncEnabled). Their membership can only be changed in AD; Entra rejects the write. The group picker marks these, and they need the Active Directory path.
  • Role-assignable groups (isAssignableToRole) need a far stronger permission. They are marked and not offered.

Which kind MHB's access groups are decides whether Entra alone is enough (question 1).

Active Directory (LDAP)

  1. Import groups first. Today an LDAP connection brings in people only. It gains Import groups (a base DN and a filter, like the existing ones), filling the same directory_groups table, so the picker works the same for both.
  2. Writes use the service account, with ldap_mod_add / ldap_mod_del on the group's member attribute and the person's DN from source_ref. The account needs Write Members on the groups (or the OU that holds them) - delegated in AD, and nothing more.
  3. Plain LDAP (ldap://) sends the change unencrypted. Directory writes require LDAPS or StartTLS.

Every change, whichever way

  • Runs after the approval is committed, never inside it - a slow or failing directory cannot undo a decision.
  • Is recorded in a directory change log (who, which group, add or remove, which request or which owner, the result and Microsoft's or AD's own error text) - like the Email send log.
  • On failure: the grant shows Failed - not added, with the reason and a Try again button; the service owner and the service desk get a bell notification; it counts on Watchtower. The request stays approved - the decision was right, the directory said no.
  • Updates directory_group_members straight away, so the screens do not wait for the next import to show the change.

4. Part C - who has what

One row per person per service:

State Being added -> Has access -> Being removed -> Removed, or Failed at either step
Why The approved request (linked), the owner who added them, or found in the directory
When and by whom Granted, removed, and the reason for a removal

Removed rows are kept, so a service always has its history ("who had access to the finance share in March?").

After every import FreeITSM compares each service's rows with the group's real members:

  • In the group, no row -> a row found in the directory. Shown to the owner; never removed by FreeITSM on its own.
  • A row says Has access, but they are no longer in the group -> marked removed in the directory.

5. Part D - the owner approves

A catalogue item's approval steps gain one more kind of decider: The access service's owner. It works exactly like The cost centre's owner: the owner (or anyone in the owning group) decides on the portal Approvals page, the deputy stands in, and an owner with no portal sign-in falls back as other steps do.

So "the manager says they need it, then the service owner agrees" is two steps on the item, and no new approval machinery.

6. Part E - the portal

Add-on 1 - My access. A new portal page lists the services the signed-in person has, with when and why. Each has Ask to remove. Removal follows the service's removal choice and its Keep at least number: straight away, the owner, or a catalogue item's steps. Once approved, they are taken out of the group, and the row shows it.

Add-on 2 - Services I own. The owner and deputy see their services, and for each one:

  • the members - from FreeITSM's rows and from the group itself, with found in the directory marked;
  • Add a person (picked from the people directory) and Remove, with a reason. By default the owner's action is the approval and nothing waits on anyone else; a service set to need a second approval sends it on first. Keep at least applies here too;
  • the history.

People who are not IT staff never need an analyst account for any of this - the same reason the #160 approvals were put on the portal.

7. Worked example

Access to the finance share - owner: the head of finance; deputy: the finance office manager; group: SG-Finance-Share in Entra.

  1. A member of staff orders Finance share access from the catalogue. Steps: their manager, then the access service's owner.
  2. The manager approves on the portal; then the head of finance approves.
  3. FreeITSM adds them to SG-Finance-Share. Their My access page shows Finance share - since 3 December, request #1234.
  4. Six months later they move team and press Ask to remove. The owner approves; they are taken out of the group.
  5. The head of finance opens Services I own, sees eleven members - one marked found in the directory, added by IT in Entra last year - and removes them with the reason "left the department".

8. Not in this design (yet)

  • Time-limited access ("for 90 days") and access reviews (the owner confirms every member each quarter). Wanted later (answer 6). The grant record gets an empty expires column from the start, so both bolt on without a migration.
  • Leavers. Later, the Starters & leavers case lists a leaver's access services, with an option to remove them all (a removal for a leaver skips Keep at least and goes to the owner as a warning instead).
  • Creating groups in Entra or AD. FreeITSM only changes the membership of groups that already exist.
  • Licences, mailboxes, application roles. Only group membership. Most of those are granted through groups anyway.

9. Questions for @bigtrodat - and the answers (2 December 2026)

# Question Answer What the design does
1 Where do your access groups live? Both: Entra and on-premises AD. Entra first, AD later Each group says how it is changed (section 3); Entra and By hand in stage 1, AD in stage 2
2 GroupMember.ReadWrite.All on a separate app registration (or an AD account with Write Members)? Yes As designed
3 Removing access: who approves? It depends: free for a subscription, checked for shared directory access so someone can still reach it A per-service removal choice, plus Keep at least N members
4 The owner adding or removing people: anyone else's approval? No - the owner's action is enough The default; need a second approval is a setting for others
5 One group per service? Yes, 1:1 Stored as a list from day one (other organisations will need two); MHB's services have one
6 Time-limited access and access reviews? Later Not built; the grant record leaves room for them
7 Owner: a person or a team? Always a person A person by default; a team is allowed because the cost-centre picker already does it

10. Build order

Stage Parts Why first
1 A (services, groups, removal choices), B for Entra ID and By hand, C, D The core: approve a request, the person is in the group, and it is on record
2 B for Active Directory (with LDAP group import) and Workflow MHB's on-premises groups, and every other system
3 E - My access and Services I own Removal and owner management on the portal, on top of the records
Later Leavers, time-limited access, access reviews When wanted

11. Still open

  1. For shared directory access: does the owner approves + keep at least N members cover it, or must someone other than the owner confirm? (A catalogue item's steps would also do it.)
  2. MHB's on-premises groups: synced to Entra (they show in the Entra import today, marked synced), or in AD only?

Decided

  • 2026-12-02 - @bigtrodat's answers to section 9 (table above).
  • 2026-12-03 - Where an answer is "it depends", it becomes a choice on each access service, with today's answer as the default: how each group is changed (Entra / AD / Workflow / By hand), who approves a removal, Keep at least N members, and whether owner changes need a second approval. Groups are stored as a list per service; the owner may be a person or a team.
  • 2026-12-03 - Workflow and By hand are first-class ways to change a group, so organisations with any other directory, or none, get the same requests, approvals and records.
  • 2026-12-03 - A service with no valid owner is shown as needs an owner, never left with approvals going nowhere.
  • 2026-12-03 - Stage 1 built: services and groups (Entra ID and By hand), grants and the change log, "The access service's owner" step, Directory writes, the comparison after each import, failures on the bell and Watchtower. An item that asks for no approval gives the service at once only when the service has Give it without approval (off by default) - Ed: some will want it one way, some the other, so it is a setting.

For developers

Schema (proposed): access_services (name, description, owner_user_id / owner_group_id, deputy_user_id, removal_mode none / owner / form, removal_form_id, min_members, owner_change_mode immediate / second_approval, tenant_id, is_active); access_service_groups (service_id, directory_group_id, change_method entra / ldap / workflow / manual, manual_team_id); access_grants (service_id, user_id, state, source request / owner / directory, submission_id, granted_*, removed_*, expires_at (unused until time limits), last_error); one row per grant per group in access_grant_groups so a two-group service can be half done; directory_change_log; forms.access_service_id - which must be carried by createVersion() or saving an item drops it. Directory write credentials as new encrypted columns on auth_providers, apart from the import's.

Reuse: entraConfig() / entraToken() / GraphHttpError for Graph; ldapOpen() / ldapBindService() for AD; catalogueStepPeople() + catalogueNormaliseStepPolicy() for the owner step (as cc_owner); catalogueAfterDecision() (after commit) for the grant; the portal Approvals page for owners.

Traps to carry into the build:

  • The object id is source_ref, never subject - the identity TRAP.
  • Every write sits inside the sync's $preview guards if it ever runs from a sync (Extending directory sync ยง4).
  • A first comparison after an import would mark every existing member found in the directory - correct, but the owner should see it as "already in the group when the service was set up", not as something to act on.
  • The catalogue_request.approved payload has no requester user_id today; the grant needs the submission's submitted_by_user_id, not an email answer.

See also