Roles
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(ornull) 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.
"*": trueopens the object to every user, including anonymous users, while object roles still merge for their users.
"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 asnegatedRolesby the admin-only/api/workspace/testendpoint, but composition does not treat it as a negation./api/workspace/rolesresponds410 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.
{
"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"] } } } }
}
}
}
}
}