Access Control API
@idiomark/api-access-control is a Fastify-based API server providing granular permissions, team management, profile ACLs, selective disclosure, and enterprise SSO integration for Idiomark.
Tech Stack
- Fastify — High-performance Node.js framework
- PostgreSQL — Persistent storage
- Casbin — RBAC + ABAC authorization
- JWT — Token authentication
- Swagger — Auto-generated API docs at
/docs
Installation
cd packages/api-access-control
pnpm install
Configuration
# Server
PORT=3001
HOST=0.0.0.0
LOG_LEVEL=info
# Database
DATABASE_URL=postgres://postgres:postgres@localhost:5432/idiomark_access_control
# Authentication
JWT_SECRET=your-secret-key-here
# CORS (comma-separated origins)
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001
Running
# Development
pnpm dev
# Production
pnpm build && pnpm start
API available at http://localhost:3001 — Swagger docs at http://localhost:3001/docs
API Endpoints
Permissions
POST /api/v1/permissions Create permission
GET /api/v1/permissions List user permissions
GET /api/v1/permissions/user Current user's permissions
GET /api/v1/permissions/:id Get by ID
PUT /api/v1/permissions/:id Update
DELETE /api/v1/permissions/:id Delete
POST /api/v1/permissions/check Check permission
Teams
POST /api/v1/teams Create team
GET /api/v1/teams List user teams
GET /api/v1/teams/:id Get team
PUT /api/v1/teams/:id Update team
DELETE /api/v1/teams/:id Delete team
POST /api/v1/teams/:id/members Add member
GET /api/v1/teams/:id/members List members
PUT /api/v1/teams/:id/members/:userId Update member
DELETE /api/v1/teams/:id/members/:userId Remove member
Profile ACLs
POST /api/v1/profiles/:id/acl Set ACL
GET /api/v1/profiles/:id/acl Get ACL
PUT /api/v1/profiles/acl/:aclId Update ACL entry
DELETE /api/v1/profiles/:id/acl Clear ACL
DELETE /api/v1/profiles/acl/:aclId Delete entry
GET /api/v1/profiles/:id/check Check access
POST /api/v1/profiles/:id/disclosure Set selective disclosure
GET /api/v1/profiles/:id/disclosure Get disclosures
DELETE /api/v1/profiles/:id/disclosure Delete disclosure
GET /api/v1/profiles/:id/fields Visible fields
GET /api/v1/profiles/:id/fields/:path/check Check field visibility
Enterprise SSO
GET /api/v1/enterprise/sso/config List configs
POST /api/v1/enterprise/sso/config Create config
GET /api/v1/enterprise/sso/config/:id Get config
PUT /api/v1/enterprise/sso/config/:id Update config
DELETE /api/v1/enterprise/sso/config/:id Delete config
GET /api/v1/enterprise/sso/:id/login Get auth URL
GET /api/v1/enterprise/sso/:id/callback SSO callback
GET /api/v1/enterprise/sso/config/:id/users User mappings
GET /api/v1/enterprise/sso/user Current user SSO
POST /api/v1/enterprise/sso/config/:id/disconnect/:externalUserId Disconnect
Permission Levels
| Level | Description |
|---|---|
read | View the resource |
write | Modify the resource |
admin | Manage permissions |
owner | Full control including deletion |
Visibility Levels
| Level | Description |
|---|---|
public | Visible to everyone |
shared | Visible to specific grantees |
private | Visible only to owner |
Selective Disclosure
Share specific fields with specific users:
curl -X POST http://localhost:3001/api/v1/profiles/PROFILE_ID/disclosure \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{
"fieldPath": "personality.traits.openness",
"visibility": "shared",
"allowedGrantees": ["user-uuid-1", "user-uuid-2"]
}'
SSO Providers
| Provider | Description |
|---|---|
| Okta | Enterprise identity provider |
| Auth0 | Identity and access management |
| Azure AD | Microsoft cloud identity |
| Google Workspace | Google enterprise suite |
Architecture
packages/api-access-control/
├── src/
│ ├── routes/ # API route handlers
│ ├── services/ # Business logic
│ ├── middleware/ # Auth and RBAC middleware
│ ├── casbin/ # Authorization models and policies
│ ├── database/ # Schema and migrations
│ └── index.ts # Main server entry
├── test/ # Test suite
└── package.json
Related
- Teams — Team collaboration SDK
- Identity — Cryptographic identity verification
- API Reference — Core Idiomark API