Roles and Permissions
Signing in proves who you are. Roles and permissions decide which features you can use. Every account has exactly one role; a role is a named list of permissions.
The detection, CO₂ interpolation, and flood replay features these permissions guard call services that run on Jetstream2 at Indiana University through NSF ACCESS allocation CIS251126. See the Acknowledgments.
Roles
| Role | Gets |
|---|---|
admin | Everything, including the user admin page |
member | All standard features and worlds, except restricted extensions and user admin |
co2 | CO₂ sensors only |
emergency | Emergency Management only |
codetr | Everything that uses Co-DETR: Florida camera vehicle scans and detection, plus Emergency Management |
viewer | The base map only. Default for every new account. |
Add more roles in the SQL editor (insert into roles and role_permissions); the admin page lists whatever exists.
Permissions
| Permission | Unlocks |
|---|---|
feature.co2 | CO₂ sensors, sensor history, CO₂ interpolation |
ext.* | A restricted extension (see below). Held by admin and by roles you grant it to by hand. |
feature.flood_replay | Hurricane Ian simulation |
feature.emergency | Emergency Management events |
feature.power_outage | Duke Energy Florida outages |
feature.detection | Co-DETR detection, Florida camera vehicle scans |
planet.mars, planet.moon | The Mars and Moon worlds |
admin.users | /admin (assign roles, invite users) |
Restricted extensions
Some features are not just hidden for other accounts; they do not exist for them. Each lives in a server-side folder (server/protected/<id>/, or the folder named by EXTENSIONS_DIR) that is never served as a static file. Its ext.json names the permission that unlocks it. After sign-in the browser asks GET /ext/manifest for the extensions its account may use and fetches only those; the code, data and images of any other extension are never sent, and requesting them returns a plain 404. Accounts with no extensions see no trace of them.
The person icon in the sidebar header opens a small profile dialog with the signed-in email, the role, and a Special access list naming the restricted extensions the account holds (names come from each extension's ext.json label, and only entitled accounts receive them).
Because extension code can build on data the account already has (for example CO₂ sensors), an extension's permission controls access to the extension itself, not to the underlying standard data.
Everything not listed (land use, traffic, weather, AQI, cameras, tilesets) is available to any signed-in user.
How it works
supabase/access-control.sqlcreates the tables and a Custom Access Token Hook. When Supabase issues a token it addsuser_roleandpermissionsto the JWT.- Express (
server/access.js) verifies the token on every request withsupabase.auth.getClaims()and checks the permission (requireFeature). Missing token is401; missing permission is403. This is the enforcement. js/core/access.jsadds the token to same-originfetchcalls and hides any element withdata-requires="<permission>". This only keeps the interface tidy.
To gate a new feature: add the permission to the SQL seed and to the roles that get it, put requireFeature(PERM.X) on its route, and put data-requires="..." on its button.
Changing someone's role
Open /admin (visible to admins as Users in the sidebar header), or run SQL:
update public.user_roles set role = 'member'
where user_id = (select id from auth.users where email = 'someone@ucf.edu');
The change reaches that person when their token refreshes (up to an hour) or when they sign in again.
Configuration
| Variable | Purpose |
|---|---|
SUPABASE_SERVICE_ROLE_KEY | Lets /admin list users and set roles. Server only; never put it in the browser or commit it. Without it /admin/api answers 501. |
SITE_URL | Base URL for invite emails (https://geo-lens.net). |
ACCESS_CONTROL=off | Disables all checks for local development. Never in production. |
GATEWAY_SHARED_SECRET | Also set on the Jetstream2 CO₂ and Flood services so they only answer this server. |
CESIUM_ION_TOKEN_MARS, CESIUM_ION_TOKEN_MOON | Optional ion tokens restricted to that world's assets. |
Known limits
/tomtom-trafficstays open to the public: it serves map tiles that the browser requests as images, which cannot carry the token.- Mars and Moon use the same Cesium ion token as Earth unless
CESIUM_ION_TOKEN_MARS/_MOONare set to asset-restricted tokens, so a user without access who extracts the Earth token could still load those ion assets. - Role changes are not instant (see above).