agentsclimarketplace

Api authorization

Skill undp/carbon-footprint-program/.claude/skills/api-authorization

Authentication and authorization for apps/api endpoints. Use when adding or changing access control on an API route — picking the right auth/role hook and wiring it in route.ts.From its SKILL.md

Install
npx -y skills add undp/carbon-footprint-program --skill api-authorization

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.1 KB, as published. Nobody here has run it

Authentication & Authorization

Two-dimension role model. Apply the correct decorator in route.ts:

  • fastify.requireAuth — onRequest hook; checks the user is authenticated. Use on all protected routes.
  • fastify.requireRoles([SystemRole.ADMIN, ...]) — onRequest hook; restricts by system-level roles (USER, ADMIN, SUPERADMIN).
  • fastify.requireOrganizationRole(extractor, { allowedRoles, canAdminsBypass }) — preHandler hook; restricts by organization-scoped roles (VIEWER, CONTRIBUTOR, ADMIN). Requires an extractor that pulls the organization ID from the request (params/body/query).
  • fastify.requireCarbonInventoryAccess(extractor, { requiredOrganizationRoles, canAdminsBypass }) — preHandler hook; checks access to a specific carbon inventory. Supports anonymous access via the x-carbon-inventory-uuid header, creator-only access for standalone inventories, and organization membership checks. Requires an extractor (e.g., idRequestExtractor).
  • fastify.requireReductionProjectAccess({ requiredOrganizationRoles, canAdminsBypass }) — preHandler hook; checks access to a reduction project via organization membership. Extracts the project ID from request.params.id. Supports admin bypass when canAdminsBypass is set.

Domain-specific access hooks (requireCarbonInventoryAccess, requireReductionProjectAccess) are only for endpoints within their own domain (carbon inventory endpoints, reduction project endpoints). Endpoints in other domains that reference these entities indirectly should rely on requireOrganizationRole.

Access the current user via request.currentUser (set by the user-resolve-plugin in preHandler).

Source: apps/api/src/plugins/app/authorizationPlugin.ts, organizationAuthorizationPlugin.ts, carbonInventoryAuthorizationPlugin.ts, reductionProjectAuthorizationPlugin.ts.

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.