feat(invitations): provision guests directly into the directory (ldap backend)#12469
Draft
dj4oC wants to merge 1 commit into
Draft
feat(invitations): provision guests directly into the directory (ldap backend)#12469dj4oC wants to merge 1 commit into
dj4oC wants to merge 1 commit into
Conversation
…ctory Adds an `ldap` invitation backend (selected via INVITATIONS_BACKEND) that provisions invited guests directly into the oCIS identity backend, so a guest is immediately resolvable via the Graph API and usable as a share recipient right after the invitation -- closing the provisioning-delay gap of the Keycloak backend. - new services/invitations/pkg/backends/idm backend (DirectoryProvisioner backed by identity.LDAP), unit-tested - INVITATIONS_BACKEND selector + INVITATIONS_LDAP_* config in service.New, reusing the graph LDAP schema defaults - ocis init provisions the invitations LDAP bind password with the shared idm service password, so the backend works out of the box - ocis_full enables LDAP write + the ldap backend and runs the invitations service Verified end-to-end against a running oCIS: POST /invitations -> guest (userType=Guest) -> immediately resolvable -> graph invite succeeds, relying solely on the init-provisioned bind password. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: David Walter <david.walter@kiteworks.com>
156a9f9 to
4b6945d
Compare
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
Author
|
Out of scope: add LDAP to the ocis_full example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The invitations service (
POST /graph/v1.0/invitations) provisions invited guests inan external Keycloak IdP. Such a guest is not immediately present in the directory
oCIS reads for share-recipient resolution (the documented "provisioning delay" in
services/invitations/README.md), so it cannot be used as a share recipient until ithas been synced/logged in. The graph invite handler validates the recipient via
identityCache.GetUser(services/graph/.../api_driveitem_permissions.go) and rejectsunknown ids, so "invite an external by email, then share with them" cannot work right
after the invitation.
Solution
Add a second invitation backend that provisions the guest directly into the oCIS
identity backend (LDAP), selected with a new
INVITATIONS_BACKENDenv var:keycloak(default) — unchanged behaviour.ldap— creates the guest (userType=Guest) in the same directory oCIS reads, viathe existing
identity.LDAPbackend. The guest is therefore immediately resolvablethrough the Graph API and usable as a share recipient. Requires
OCIS_LDAP_SERVER_WRITE_ENABLED=true.The invitation response also returns the created user as
invitedUser(id, email,userType), which a client needs to then share with the guest.
Changes
services/invitations/pkg/backends/idm/— new backend provisioning guests via aDirectoryProvisioner(satisfied by*identity.LDAP); unit-tested.services/invitations/pkg/service/v0/service.go—INVITATIONS_BACKENDselector;the
ldapbackend reuses the graph LDAP schema defaults and only overrides theconnection/write settings from the invitations config.
services/invitations/pkg/config—INVITATIONS_BACKEND+INVITATIONS_LDAP_*.ocis/pkg/init—ocis initnow provisions the invitations LDAP bind password withthe same idm service password the graph identity backend uses, so the
ldapbackendworks out of the box.
deployments/examples/ocis_full— enables LDAP write + theldapinvitation backendand runs the invitations service, so an invited guest is shareable out of the box.
Testing
go test ./services/invitations/... -race— passes (newidmbackend unit tests +existing keycloak tests).
INVITATIONS_BACKEND=ldap,OCIS_LDAP_SERVER_WRITE_ENABLED=true):POST /graph/v1.0/invitations→201,invitedUserreturned withuserType=Guest.GET /graph/v1.0/users/{id}→200immediately (resolvable).200(share succeeds).Verified relying solely on the
ocis init-provisioned bind password (no manual secret).Notes / limitations
ldapbackend provisions the guest but does not send a credential-setup email(that remains a Keycloak feature). It fits IDM-managed deployments; for a guest
login/email flow, combine with Keycloak.
ldapbackend reusesservices/graph/pkg/identity+ its configdefaults. A cleaner long-term home would be a shared identity package.
Risk
Low.
INVITATIONS_BACKENDdefaults tokeycloak(unchanged behaviour); the new path isopt-in. The
ocis_fullchange is confined to the example deployment.🤖 Generated with Claude Code