@checkstack/auth-backend 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -0
- package/drizzle/0002_lowly_squirrel_girl.sql +43 -0
- package/drizzle/0003_tranquil_sally_floyd.sql +8 -0
- package/drizzle/meta/0002_snapshot.json +1017 -0
- package/drizzle/meta/0003_snapshot.json +1050 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +1 -1
- package/src/index.ts +13 -5
- package/src/router.ts +435 -0
- package/src/schema.ts +107 -0
- package/src/teams.test.ts +1230 -0
- package/src/utils/auth-error-redirect.ts +2 -3
- package/src/utils/user.test.ts +60 -41
- package/src/utils/user.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,97 @@
|
|
|
1
1
|
# @checkstack/auth-backend
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8e43507: # Teams and Resource-Level Access Control
|
|
8
|
+
|
|
9
|
+
This release introduces a comprehensive Teams system for organizing users and controlling access to resources at a granular level.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
### Team Management
|
|
14
|
+
|
|
15
|
+
- Create, update, and delete teams with name and description
|
|
16
|
+
- Add/remove users from teams
|
|
17
|
+
- Designate team managers with elevated privileges
|
|
18
|
+
- View team membership and manager status
|
|
19
|
+
|
|
20
|
+
### Resource-Level Access Control
|
|
21
|
+
|
|
22
|
+
- Grant teams access to specific resources (systems, health checks, incidents, maintenances)
|
|
23
|
+
- Configure read-only or manage permissions per team
|
|
24
|
+
- Resource-level "Team Only" mode that restricts access exclusively to team members
|
|
25
|
+
- Separate `resourceAccessSettings` table for resource-level settings (not per-grant)
|
|
26
|
+
- Automatic cleanup of grants when teams are deleted (database cascade)
|
|
27
|
+
|
|
28
|
+
### Middleware Integration
|
|
29
|
+
|
|
30
|
+
- Extended `autoAuthMiddleware` to support resource access checks
|
|
31
|
+
- Single-resource pre-handler validation for detail endpoints
|
|
32
|
+
- Automatic list filtering for collection endpoints
|
|
33
|
+
- S2S endpoints for access verification
|
|
34
|
+
|
|
35
|
+
### Frontend Components
|
|
36
|
+
|
|
37
|
+
- `TeamsTab` component for managing teams in Auth Settings
|
|
38
|
+
- `TeamAccessEditor` component for assigning team access to resources
|
|
39
|
+
- Resource-level "Team Only" toggle in `TeamAccessEditor`
|
|
40
|
+
- Integration into System, Health Check, Incident, and Maintenance editors
|
|
41
|
+
|
|
42
|
+
## Breaking Changes
|
|
43
|
+
|
|
44
|
+
### API Response Format Changes
|
|
45
|
+
|
|
46
|
+
List endpoints now return objects with named keys instead of arrays directly:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// Before
|
|
50
|
+
const systems = await catalogApi.getSystems();
|
|
51
|
+
|
|
52
|
+
// After
|
|
53
|
+
const { systems } = await catalogApi.getSystems();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Affected endpoints:
|
|
57
|
+
|
|
58
|
+
- `catalog.getSystems` → `{ systems: [...] }`
|
|
59
|
+
- `healthcheck.getConfigurations` → `{ configurations: [...] }`
|
|
60
|
+
- `incident.listIncidents` → `{ incidents: [...] }`
|
|
61
|
+
- `maintenance.listMaintenances` → `{ maintenances: [...] }`
|
|
62
|
+
|
|
63
|
+
### User Identity Enrichment
|
|
64
|
+
|
|
65
|
+
`RealUser` and `ApplicationUser` types now include `teamIds: string[]` field with team memberships.
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
See `docs/backend/teams.md` for complete API reference and integration guide.
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [97c5a6b]
|
|
74
|
+
- Updated dependencies [8e43507]
|
|
75
|
+
- @checkstack/backend-api@0.2.0
|
|
76
|
+
- @checkstack/auth-common@0.1.0
|
|
77
|
+
- @checkstack/common@0.1.0
|
|
78
|
+
- @checkstack/command-backend@0.0.4
|
|
79
|
+
- @checkstack/notification-common@0.0.4
|
|
80
|
+
|
|
81
|
+
## 0.0.3
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- f5b1f49: Improved BASE_URL handling with fallback defaults for local development.
|
|
86
|
+
- Updated dependencies [f5b1f49]
|
|
87
|
+
- Updated dependencies [f5b1f49]
|
|
88
|
+
- Updated dependencies [f5b1f49]
|
|
89
|
+
- @checkstack/backend-api@0.1.0
|
|
90
|
+
- @checkstack/common@0.0.3
|
|
91
|
+
- @checkstack/command-backend@0.0.3
|
|
92
|
+
- @checkstack/auth-common@0.0.3
|
|
93
|
+
- @checkstack/notification-common@0.0.3
|
|
94
|
+
|
|
3
95
|
## 0.0.2
|
|
4
96
|
|
|
5
97
|
### Patch Changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
CREATE TABLE "application_team" (
|
|
2
|
+
"application_id" text NOT NULL,
|
|
3
|
+
"team_id" text NOT NULL,
|
|
4
|
+
CONSTRAINT "application_team_application_id_team_id_pk" PRIMARY KEY("application_id","team_id")
|
|
5
|
+
);
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
CREATE TABLE "resource_team_access" (
|
|
8
|
+
"resource_type" text NOT NULL,
|
|
9
|
+
"resource_id" text NOT NULL,
|
|
10
|
+
"team_id" text NOT NULL,
|
|
11
|
+
"team_only" boolean DEFAULT false NOT NULL,
|
|
12
|
+
"can_read" boolean DEFAULT true NOT NULL,
|
|
13
|
+
"can_manage" boolean DEFAULT false NOT NULL,
|
|
14
|
+
CONSTRAINT "resource_team_access_resource_type_resource_id_team_id_pk" PRIMARY KEY("resource_type","resource_id","team_id")
|
|
15
|
+
);
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
CREATE TABLE "team" (
|
|
18
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
19
|
+
"name" text NOT NULL,
|
|
20
|
+
"description" text,
|
|
21
|
+
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
22
|
+
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
23
|
+
);
|
|
24
|
+
--> statement-breakpoint
|
|
25
|
+
CREATE TABLE "team_manager" (
|
|
26
|
+
"team_id" text NOT NULL,
|
|
27
|
+
"user_id" text NOT NULL,
|
|
28
|
+
CONSTRAINT "team_manager_team_id_user_id_pk" PRIMARY KEY("team_id","user_id")
|
|
29
|
+
);
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
CREATE TABLE "user_team" (
|
|
32
|
+
"user_id" text NOT NULL,
|
|
33
|
+
"team_id" text NOT NULL,
|
|
34
|
+
CONSTRAINT "user_team_user_id_team_id_pk" PRIMARY KEY("user_id","team_id")
|
|
35
|
+
);
|
|
36
|
+
--> statement-breakpoint
|
|
37
|
+
ALTER TABLE "application_team" ADD CONSTRAINT "application_team_application_id_application_id_fk" FOREIGN KEY ("application_id") REFERENCES "application"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
38
|
+
ALTER TABLE "application_team" ADD CONSTRAINT "application_team_team_id_team_id_fk" FOREIGN KEY ("team_id") REFERENCES "team"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
39
|
+
ALTER TABLE "resource_team_access" ADD CONSTRAINT "resource_team_access_team_id_team_id_fk" FOREIGN KEY ("team_id") REFERENCES "team"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
40
|
+
ALTER TABLE "team_manager" ADD CONSTRAINT "team_manager_team_id_team_id_fk" FOREIGN KEY ("team_id") REFERENCES "team"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
41
|
+
ALTER TABLE "team_manager" ADD CONSTRAINT "team_manager_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
42
|
+
ALTER TABLE "user_team" ADD CONSTRAINT "user_team_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
43
|
+
ALTER TABLE "user_team" ADD CONSTRAINT "user_team_team_id_team_id_fk" FOREIGN KEY ("team_id") REFERENCES "team"("id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
CREATE TABLE "resource_access_settings" (
|
|
2
|
+
"resource_type" text NOT NULL,
|
|
3
|
+
"resource_id" text NOT NULL,
|
|
4
|
+
"team_only" boolean DEFAULT false NOT NULL,
|
|
5
|
+
CONSTRAINT "resource_access_settings_resource_type_resource_id_pk" PRIMARY KEY("resource_type","resource_id")
|
|
6
|
+
);
|
|
7
|
+
--> statement-breakpoint
|
|
8
|
+
ALTER TABLE "resource_team_access" DROP COLUMN "team_only";
|