Skip to content

feat(permissions): add credential access permission system#128

Merged
Josie123-Dev merged 1 commit into
GuardZero144:mainfrom
balisdev:feat/credential-access-permission-system
Jul 23, 2026
Merged

feat(permissions): add credential access permission system#128
Josie123-Dev merged 1 commit into
GuardZero144:mainfrom
balisdev:feat/credential-access-permission-system

Conversation

@balisdev

@balisdev balisdev commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #51

Summary

Implements a granular, role-based credential access permission system for the backend (backend/src/permissions/).

  • Permission model (permission.model.ts) — granular CredentialPermission levels (credential:read/verify/issue/revoke/share, permission:manage, audit:read) and named CredentialRoles (viewer, verifier, issuer, admin) with a static ROLE_PERMISSIONS mapping as the single source of truth.
  • Role-based grants (role-assignment.entity.ts) — assign a role to a wallet, globally (*) or scoped to a single credential resource, with optional expiry. A (grantee, resource, role) triple is unique: re-granting reactivates/refreshes rather than duplicating, and revocation deactivates to preserve history.
  • Permission checks (permissions.service.ts) — getEffectiveRoles, getEffectivePermissions and hasPermission(wallet, permission, resourceId?), honouring scope (global grants satisfy any resource) and expiry.
  • Declarative enforcement@RequirePermission(...) decorator + PermissionsGuard so other feature modules can protect their credential routes with a one-liner.
  • Auditing — every grant/revocation is written to the existing tamper-evident audit trail via AuditService, using two new role_assigned / role_revoked operation types.
  • REST surface (permissions.controller.ts) — admin-only role management, plus self-inspection (GET /permissions/me) and permission checks (POST /permissions/check).

Acceptance criteria

  • ✅ Permissions are enforced — PermissionsGuard + @RequirePermission
  • ✅ Checks work correctly — hasPermission with scope/expiry resolution
  • ✅ Roles are supported — role → permission model with grants
  • ✅ Grants are managed — assign/revoke/list endpoints, reactivation semantics
  • ✅ Changes are audited — hash-chained role_assigned / role_revoked entries

Testing

  • Added unit tests for the service and guard: permissions.service.spec.ts, permissions.guard.spec.ts (16 tests, all passing).
  • New code type-checks cleanly with no errors originating from src/permissions/.

Documentation added in backend/docs/PERMISSIONS.md.

Implement a granular, role-based access control system for credential
operations, addressing issue GuardZero144#51.

- Define a permission model: granular CredentialPermission levels and
  named CredentialRole roles with a static role -> permission mapping.
- Add a RoleAssignment entity for role grants, scoped globally or to a
  single credential resource, with optional expiry. Re-granting reactivates
  rather than duplicating; revocation deactivates to preserve history.
- Implement permission checks in PermissionsService (getEffectiveRoles,
  getEffectivePermissions, hasPermission) honouring scope and expiry.
- Add a RequirePermission decorator and PermissionsGuard so other feature
  modules can protect credential routes declaratively.
- Audit every role grant and revocation via the tamper-evident AuditService
  using new role_assigned / role_revoked operation types.
- Expose a REST surface for role management (admin-only), self-inspection
  and permission checks.
- Cover the service and guard with unit tests, and document the system in
  docs/PERMISSIONS.md.
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@balisdev is attempting to deploy a commit to the Josie's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sure-data Ready Ready Preview, Comment Jul 23, 2026 4:25pm

@Josie123-Dev
Josie123-Dev merged commit 612d9f9 into GuardZero144:main Jul 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hard] Add credential access permission system

2 participants