[CXH-1572] - Add license management via workspace roles - Notion Connector#21
Open
mateoHernandez123 wants to merge 2 commits into
Open
[CXH-1572] - Add license management via workspace roles - Notion Connector#21mateoHernandez123 wants to merge 2 commits into
mateoHernandez123 wants to merge 2 commits into
Conversation
Contributor
Connector PR Review: [CXH-1572] - Add license management via workspace roles - Notion ConnectorBlocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryThe incremental commit regenerates Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. |
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Description
Adds Notion workspace roles as a first-class C1
Roleresource with grant / revoke provisioning, plus an in-process SCIM mock server so local dev and CI can run without an Enterprise Notion tenant. Closes CXH-1572 — baton-notion: add license management.Notion's SCIM API does not expose a
/Licensesendpoint — "license" in Notion product terminology means "paid seat" and is binary (member vs. guest), not tiered. The connector therefore models the workspace role itself as the license tier: eachRoleresource carriesTRAIT_LICENSE_PROFILEalongsideTRAIT_ROLE(Adobe-style hybrid, mirroring baton-adobe #34), so every role doubles as a seat tier in C1 App Utilization.Sync:
user) — unchanged surface. Internally the SCIM extension'srolevalue is stashed on the user profile duringListso role grants can be emitted principal-side fromuserBuilder.Grants(one grant per user) without re-paginating users per role. Keeps sync atO(users)instead ofO(users × roles).group) — unchanged surface.role, NEW) — static set of four (owner,membership_admin,member,restricted_member) matching the enum on theurn:ietf:params:scim:schemas:extension:notion:2.0:User.roleextension. Per-resourceEntitlements(notStaticEntitlements) because each role's display name and description vary — matches the canonicalTRAIT_ROLEpattern. DeclaresTRAIT_LICENSE_PROFILEwithWithLicenseEntitlementIDsso seat-holders correlate to their grants for App Utilization. Seat counts (WithLicenseSeats) intentionally omitted — Notion's SCIM API does not expose a per-role purchased / consumed endpoint.Provisioning:
PATCH /scim/v2/Users/{id}on the Notion role extension. Idempotent via a single pre-flightGET /Users/{id}:GrantAlreadyExistswhen the user already holds the target role (no PATCH issued).GrantAlreadyRevokedon three short-circuits: (a) the user is gone (404), (b) the user no longer holds the role, (c) the role being revoked isrestricted_member— Notion users must always carry a role, so revoke is modelled as a downgrade torestricted_memberand the floor tier has nothing to downgrade to (account must be deprovisioned to remove the user from the workspace).Auth:
Unchanged. Existing
--scim-tokenflag, no new credentials, no breaking changes for existing deployments.Architecture highlights:
TRAIT_ROLE+TRAIT_LICENSE_PROFILE). Lets the same resource power both UAR / JIT flows and App Utilization without inventing a second/Licensesresource for an API that doesn't have one.roletype —roleBuilder.Grantsreturnsnilintentionally; the actual grants come fromuserBuilder.Grants, which reads the stashedworkspace_roleprofile field. Avoids the classicO(N × M)Grants scan.Revokeshort-circuit. Revokingrestricted_memberis a no-op (warn-logged) withGrantAlreadyRevoked— there is no lower tier to downgrade to.pkg/client/helpers.gocentralizing API error classification (IsNotFoundErroragainst the gRPCNotFoundstatus thatuhttp.BaseHttpClientmaps from HTTP 404).test-server/(HTTP server + Postman collection + README), since Notion's SCIM API is Enterprise-only. The mock implementsGET/POST/PATCH/DELETE /Users,GET /Groups,ServiceProviderConfig, andResourceTypes, with stable seed IDs for CI assertions and both SCIM PATCH spellings (value-as-object and path) accepted onPATCH /Users/{id}.README.md(developer),docs/connector.mdx(customer-facing, withAUTO-GENERATEDmarkers for Generate Baton Metadata),docs/docs-info.md(internal engineering),test-server/README.md(mock).Useful links:
TRAIT_ROLE+TRAIT_LICENSE_PROFILEhybrid