Skip to content

Roles ​

Workspace Key draft workspace roles security xyz

roles and role restrict locales, layers, templates and entries to user roles, and merge role-specific configuration; use to control who sees and does what.

Resource and sources

Fine-grained authorization explains how roles and scopes control access across the workspace.

A user's roles are strings in user.roles. The XYZ API composes every locale and layer for the requesting user, so a user only receives what their roles allow. All role handling happens on the server.[1]

The roles object ​

roles maps role names to a value:

  • true (or null) gates the object: on a locale or layer, the user needs one of the gating roles; on a nested object, eg. an infoj entry, the object is removed for users without one.
  • An object is merged into the locale, layer or entry for users with that role only. On a locale or layer it also counts as a gating role.
  • "*": true opens the object to every user, including anonymous users, while object roles still merge for their users.
json
"roles": {
  "*": true,
  "analyst": { "infoj": [{ "field": "pqi", "title": "PQI" }] },
  "fascia_filter": { "filter": { "default": { "fascia": { "in": ["Budgens"] } } } }
}

A role filter must set filter.default: only the default filter is applied to queries; see layer filter. A filter expression merged directly into filter has no effect.

Scopes ​

A template or locale with role adds that role to the scope of everything merged into it. Nested scopes join with dots: a user with the role europe.france may access objects scoped europe and europe.france. A template whose scope the user lacks is not merged.[2] An authorization provider can replace these checks; see the security concepts.

Pitfalls ​

  • A role name starting with ! is listed as negatedRoles by the admin-only /api/workspace/test endpoint, but composition does not treat it as a negation. /api/workspace/roles responds 410 Gone. Do not rely on negated roles.
  • Without "*", every object role also gates the layer, so users without any of the roles lose the whole layer.

Examples ​

An open layer whose filter and extra entry merge for two roles. The test requests are anonymous and receive the unfiltered layer.

json
{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "retail_points": {
        "display": true,
        "format": "wkt",
        "table": "geodata.uk_glx_open_retail_points",
        "geom": "geom_p_4326",
        "srid": "4326",
        "qID": "id",
        "infoj": [{ "field": "store_name", "title": "Name" }],
        "roles": {
          "*": true,
          "analyst": { "infoj": [{ "field": "size_band", "title": "Size" }] },
          "tesco_only": { "filter": { "default": { "retailer": { "in": ["Tesco"] } } } }
        }
      }
    }
  }
}

  1. workspace/composeObj.js rolesTemplates ↩︎

  2. workspace/scopes.js checkScope ↩︎

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.