Access roles and GitLab access
Keycloak's groups (realm klok) are the only record of who may do what on the Klok platform. Many tools read them:
klok.dev, the agent service, klok-cli, the documentation portal, and the access synchronisation (solution KLK019), which
sets GitLab memberships from them. dev.klok.framework.common.access holds the one written version of the rules, and
access-cases.json in the wire contract pins them as data, so every implementation in every
language can prove that it gives the same answer.
Which group gives which role
KlokAccessRoles.grantsOfGroupPath(path) returns the roles one group gives, as KlokAccessGrant (role, tenant,
domain):
| Group |
Roles |
/klok/owners |
KlokOwner, KlokAdmin |
/klok/admins |
KlokAdmin |
/klok/developers |
KlokDeveloper |
/tenants/<t>/owners |
TenantOwner, TenantAdmin |
/tenants/<t>/admins |
TenantAdmin |
/tenants/<t>/developers |
TenantDeveloper |
/tenants/<t>/domains/<d>/owners |
DomainOwner, DomainAdmin |
/tenants/<t>/domains/<d>/admins |
DomainAdmin |
/tenants/<t>/domains/<d>/developers |
DomainDeveloper |
Rules the cases pin:
- An owners group gives two roles: the owner role and the admin role of the same scope
(
KlokAccessRole.adminOfOwner).
- Only the exact group carries a role. A group below a role group (
/tenants/acme/admins/x) gives nothing.
- Tenant and domain slugs are lower case letters, digits and
-, starting with a letter or digit. A group whose slug
breaks that rule gives nothing.
- The leading
/ is optional.
KlokAccessRoles.groupPathOf(grant) is the inverse, and KlokAccessGrant.parse reads the text form KlokAdmin,
TenantDeveloper@acme, DomainAdmin@acme/hr that the cases, status pages and logs use.
What the roles give in GitLab
KlokGitLabAccess states klok.dev's GitLab rules (decided in klok.dev's
klok-docs/decisions/people-are-managed-in-klok-dev.md):
managedPaths(tenant, existing, guides): the groups and projects of a tenant whose membership the platform manages.
These are the root group, every group and project directly in it except documentation, each domain's
datamodel/domain/<d> and integration/domain/<d>, the shared groups (common and public, under domain/ or
directly below datamodel and integration), and the hand-written guide projects directly in <tenant>/documentation.
A membership anywhere else is never touched.
desiredAccess(tenant, grants, managed): the person's direct access level in each managed path.
| Role |
GitLab |
| TenantOwner, TenantAdmin |
Owner (50) of the root group |
| TenantDeveloper |
Developer (30) in every managed path directly in the root group, and in the guide projects |
| DomainOwner, DomainAdmin |
Maintainer (40) in the domain's two groups |
| DomainDeveloper |
Developer (30) in the domain's two groups |
| any domain role |
Reporter (20) in the shared groups |
| KlokOwner, KlokAdmin |
GitLab instance administrator (isInstanceAdmin) |
- A tenant developer is no member of the root group, so the generated documentation projects under
<tenant>/documentation stay the owners' and admins'.
- GitLab inherits a membership into everything below it, so a path gets a direct membership only where it gives more
than a managed path above it. A tenant admin is therefore a direct member of the root group only.
- Platform roles give no tenant membership. KlokOwner and KlokAdmin reach every tenant as GitLab administrators
instead, which also keeps platform staff out of customers' member lists.
Using the cases in another language
Read dev/klok/wire-contract/access-cases.json (inside the jar, or in the wire-contract zip) and run every case
against your implementation, as KlokAccessFixtureTest does in Java: grantsOfGroupPath, tenantOfGroupPath,
managedPaths, desiredAccess and isInstanceAdmin. A rule changes in this repository first, cases included, and
every implementation follows.