Repository navigation
Expand file tree
/
Copy pathinstall.sql
More file actions
3953 lines (3615 loc) · 321 KB
/
Copy pathinstall.sql
File metadata and controls
3953 lines (3615 loc) · 321 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- SandIAM installation lifecycle for the release package.
-- Admin controller permission inventory; validated against migration 021 during generation.
-- Fail before the first menu write when this is not a fresh SandIAM target.
DO $sand_iam_fresh_install$
BEGIN
IF EXISTS (
SELECT 1
FROM pg_class relation
JOIN pg_namespace namespace ON namespace.oid = relation.relnamespace
WHERE namespace.nspname = current_schema()
AND (
relation.relname LIKE 'sand\_iam\_%' ESCAPE '\'
OR relation.relname LIKE 'idx\_sand\_iam\_%' ESCAPE '\'
OR relation.relname LIKE 'uk\_sand\_iam\_%' ESCAPE '\'
OR relation.relname LIKE 'uq\_sand\_iam\_%' ESCAPE '\'
OR relation.relname LIKE 'ux\_sand\_iam\_%' ESCAPE '\'
)
) OR EXISTS (
SELECT 1
FROM pg_type type_entry
JOIN pg_namespace namespace ON namespace.oid = type_entry.typnamespace
WHERE namespace.nspname = current_schema()
AND type_entry.typname LIKE 'sand\_iam\_%' ESCAPE '\'
) THEN
RAISE EXCEPTION 'SandIAM fresh install refuses existing sand_iam_* objects in schema %', current_schema();
END IF;
IF to_regclass(format('%I.sand_system_menu', current_schema())) IS NULL
OR to_regclass(format('%I.sand_system_role_menu', current_schema())) IS NULL THEN
RAISE EXCEPTION 'SandIAM fresh install requires the SandAdmin menu and role-menu tables';
END IF;
IF EXISTS (
SELECT 1 FROM sand_system_menu
WHERE code = 'SandIAM'
OR code LIKE 'SandIAM%'
OR code LIKE 'sand\_iam:%' ESCAPE '\'
OR slug LIKE 'sand\_iam:%' ESCAPE '\'
OR path = '/sand-iam'
OR path LIKE '/sand-iam/%'
) THEN
RAISE EXCEPTION 'SandIAM fresh install refuses existing menu codes, permission slugs, or routes';
END IF;
END
$sand_iam_fresh_install$;
-- 'sand_iam:acceptance_fixture:cleanup'
-- 'sand_iam:acceptance_fixture:read'
-- 'sand_iam:admin_application_grant:disable'
-- 'sand_iam:admin_application_grant:index'
-- 'sand_iam:admin_application_grant:read'
-- 'sand_iam:admin_application_grant:save'
-- 'sand_iam:admin_application_grant:update'
-- 'sand_iam:admin_organization_grant:disable'
-- 'sand_iam:admin_organization_grant:index'
-- 'sand_iam:admin_organization_grant:read'
-- 'sand_iam:admin_organization_grant:save'
-- 'sand_iam:admin_organization_grant:update'
-- 'sand_iam:api_resource:disable'
-- 'sand_iam:api_resource:index'
-- 'sand_iam:api_resource:read'
-- 'sand_iam:api_resource:save'
-- 'sand_iam:api_resource:update'
-- 'sand_iam:api_route_binding:disable'
-- 'sand_iam:api_route_binding:index'
-- 'sand_iam:api_route_binding:read'
-- 'sand_iam:api_route_binding:save'
-- 'sand_iam:api_route_binding:update'
-- 'sand_iam:application:disable'
-- 'sand_iam:application:index'
-- 'sand_iam:application:read'
-- 'sand_iam:application:save'
-- 'sand_iam:application:update'
-- 'sand_iam:application_capability:index'
-- 'sand_iam:application_capability:save'
-- 'sand_iam:application_experience:disable'
-- 'sand_iam:application_experience:index'
-- 'sand_iam:application_experience:read'
-- 'sand_iam:application_experience:save'
-- 'sand_iam:application_experience:update'
-- 'sand_iam:application_network_policy:disable'
-- 'sand_iam:application_network_policy:index'
-- 'sand_iam:application_network_policy:read'
-- 'sand_iam:application_network_policy:save'
-- 'sand_iam:application_network_policy:update'
-- 'sand_iam:audit:export'
-- 'sand_iam:audit:index'
-- 'sand_iam:audit:read'
-- 'sand_iam:audit_retention_policy:disable'
-- 'sand_iam:audit_retention_policy:index'
-- 'sand_iam:audit_retention_policy:read'
-- 'sand_iam:audit_retention_policy:save'
-- 'sand_iam:audit_retention_policy:update'
-- 'sand_iam:auth_policy:disable'
-- 'sand_iam:auth_policy:index'
-- 'sand_iam:auth_policy:read'
-- 'sand_iam:auth_policy:save'
-- 'sand_iam:auth_policy:update'
-- 'sand_iam:cas_service:disable'
-- 'sand_iam:cas_service:index'
-- 'sand_iam:cas_service:read'
-- 'sand_iam:cas_service:save'
-- 'sand_iam:cas_service:update'
-- 'sand_iam:client:disable'
-- 'sand_iam:client:index'
-- 'sand_iam:client:read'
-- 'sand_iam:client:save'
-- 'sand_iam:client:update'
-- 'sand_iam:credential:index'
-- 'sand_iam:credential:issue'
-- 'sand_iam:credential:read'
-- 'sand_iam:credential:revoke'
-- 'sand_iam:credential:rotate'
-- 'sand_iam:developer:events'
-- 'sand_iam:developer:openapi'
-- 'sand_iam:environment:disable'
-- 'sand_iam:environment:index'
-- 'sand_iam:environment:read'
-- 'sand_iam:environment:save'
-- 'sand_iam:environment:update'
-- 'sand_iam:federation:configure'
-- 'sand_iam:federation:create'
-- 'sand_iam:federation:mount'
-- 'sand_iam:federation:sync'
-- 'sand_iam:grant:index'
-- 'sand_iam:grant:read'
-- 'sand_iam:grant:revoke'
-- 'sand_iam:grant:save'
-- 'sand_iam:grant:update'
-- 'sand_iam:identity:delete'
-- 'sand_iam:identity:disable'
-- 'sand_iam:identity:enable'
-- 'sand_iam:identity:index'
-- 'sand_iam:identity:read'
-- 'sand_iam:identity:restore'
-- 'sand_iam:identity:save'
-- 'sand_iam:identity:update'
-- 'sand_iam:identity_binding:disable'
-- 'sand_iam:identity_binding:index'
-- 'sand_iam:identity_binding:read'
-- 'sand_iam:identity_binding:save'
-- 'sand_iam:identity_binding:update'
-- 'sand_iam:identity_export:masked'
-- 'sand_iam:identity_export:sensitive'
-- 'sand_iam:identity_group:disable'
-- 'sand_iam:identity_group:index'
-- 'sand_iam:identity_group:read'
-- 'sand_iam:identity_group:save'
-- 'sand_iam:identity_group:update'
-- 'sand_iam:identity_group_member:add'
-- 'sand_iam:identity_group_member:index'
-- 'sand_iam:identity_group_member:remove'
-- 'sand_iam:identity_group_role:grant'
-- 'sand_iam:identity_group_role:index'
-- 'sand_iam:identity_group_role:revoke'
-- 'sand_iam:identity_import:confirm'
-- 'sand_iam:identity_import:index'
-- 'sand_iam:identity_import:preview'
-- 'sand_iam:identity_import:read'
-- 'sand_iam:identity_invitation:index'
-- 'sand_iam:identity_invitation:read'
-- 'sand_iam:identity_invitation:resend'
-- 'sand_iam:identity_invitation:revoke'
-- 'sand_iam:identity_invitation:send'
-- 'sand_iam:identity_provider:disable'
-- 'sand_iam:identity_provider:index'
-- 'sand_iam:identity_provider:read'
-- 'sand_iam:identity_provider:save'
-- 'sand_iam:identity_provider:update'
-- 'sand_iam:identity_role:grant'
-- 'sand_iam:identity_role:index'
-- 'sand_iam:identity_role:revoke'
-- 'sand_iam:identity_user_type:grant'
-- 'sand_iam:identity_user_type:index'
-- 'sand_iam:identity_user_type:revoke'
-- 'sand_iam:initialization:apply'
-- 'sand_iam:initialization:disable'
-- 'sand_iam:initialization:export'
-- 'sand_iam:initialization:index'
-- 'sand_iam:initialization:preview'
-- 'sand_iam:initialization:read'
-- 'sand_iam:initialization:rollback'
-- 'sand_iam:initialization:save'
-- 'sand_iam:initialization:update'
-- 'sand_iam:message_provider:configure'
-- 'sand_iam:message_provider:disable'
-- 'sand_iam:message_provider:index'
-- 'sand_iam:message_provider:read'
-- 'sand_iam:message_provider:save'
-- 'sand_iam:message_provider:test'
-- 'sand_iam:message_provider:update'
-- 'sand_iam:message_provider_mount:disable'
-- 'sand_iam:message_provider_mount:index'
-- 'sand_iam:message_provider_mount:save'
-- 'sand_iam:oauth_client:disable'
-- 'sand_iam:oauth_client:index'
-- 'sand_iam:oauth_client:read'
-- 'sand_iam:oauth_client:rotate'
-- 'sand_iam:oauth_client:save'
-- 'sand_iam:oauth_client:update'
-- 'sand_iam:oauth_registration_token:index'
-- 'sand_iam:oauth_registration_token:issue'
-- 'sand_iam:oauth_registration_token:revoke'
-- 'sand_iam:onboarding:apply'
-- 'sand_iam:onboarding:preview'
-- 'sand_iam:organization:disable'
-- 'sand_iam:organization:index'
-- 'sand_iam:organization:read'
-- 'sand_iam:organization:save'
-- 'sand_iam:organization:update'
-- 'sand_iam:policy:disable'
-- 'sand_iam:policy:index'
-- 'sand_iam:policy:publish'
-- 'sand_iam:policy:read'
-- 'sand_iam:policy:revoke'
-- 'sand_iam:policy:save'
-- 'sand_iam:policy:update'
-- 'sand_iam:radius_nas:configure'
-- 'sand_iam:radius_nas:disable'
-- 'sand_iam:radius_nas:index'
-- 'sand_iam:radius_nas:read'
-- 'sand_iam:radius_nas:save'
-- 'sand_iam:radius_nas:update'
-- 'sand_iam:resource:disable'
-- 'sand_iam:resource:index'
-- 'sand_iam:resource:read'
-- 'sand_iam:resource:save'
-- 'sand_iam:resource:update'
-- 'sand_iam:role:disable'
-- 'sand_iam:role:index'
-- 'sand_iam:role:read'
-- 'sand_iam:role:save'
-- 'sand_iam:role:update'
-- 'sand_iam:security_alert:index'
-- 'sand_iam:security_alert:read'
-- 'sand_iam:security_alert:resolve'
-- 'sand_iam:service:disable'
-- 'sand_iam:service:index'
-- 'sand_iam:service:read'
-- 'sand_iam:service:save'
-- 'sand_iam:service:update'
-- 'sand_iam:service_action:disable'
-- 'sand_iam:service_action:index'
-- 'sand_iam:service_action:read'
-- 'sand_iam:service_action:save'
-- 'sand_iam:service_action:update'
-- 'sand_iam:sync_connector:configure'
-- 'sand_iam:sync_connector:disable'
-- 'sand_iam:sync_connector:index'
-- 'sand_iam:sync_connector:read'
-- 'sand_iam:sync_connector:save'
-- 'sand_iam:sync_connector:test'
-- 'sand_iam:sync_connector:update'
-- 'sand_iam:sync_run:index'
-- 'sand_iam:sync_run:run'
-- 'sand_iam:user_type:disable'
-- 'sand_iam:user_type:index'
-- 'sand_iam:user_type:read'
-- 'sand_iam:user_type:save'
-- 'sand_iam:user_type:update'
-- 'sand_iam:webhook:disable'
-- 'sand_iam:webhook:index'
-- 'sand_iam:webhook:read'
-- 'sand_iam:webhook:save'
-- 'sand_iam:webhook:update'
-- 'sand_iam:webhook_delivery:index'
-- 'sand_iam:webhook_delivery:read'
-- 'sand_iam:webhook_delivery:retry'
-- SandIAM current PostgreSQL installation base. Migration source range is 001–033;
-- this generated menu payload is rebuilt from the authoritative lifecycle sources.
-- SandIAM 管理入口与既有权限码。按 code / slug 幂等更新,保留已存在的菜单 ID 与角色绑定。
INSERT INTO "sand_system_menu"
("parent_id","name","code","slug","type","path","component","icon","sort","status","create_time","update_time")
SELECT 0,'身份与权限(SandIAM)','SandIAM','',1,'/sand-iam','','ri:shield-user-line',98,1,NOW(),NOW()
WHERE NOT EXISTS (SELECT 1 FROM "sand_system_menu" WHERE "code" = 'SandIAM');
UPDATE "sand_system_menu"
SET "name" = '身份与权限(SandIAM)',
"path" = '/sand-iam',
"icon" = 'ri:shield-user-line',
"sort" = 98,
"status" = 1,
"update_time" = NOW()
WHERE "code" = 'SandIAM';
WITH menu_def("code","name","path","component","sort","is_hidden") AS (
VALUES
('SandIAMOverview','首页','overview','/plugin/sand-iam/index/index',100,2),
('SandIAMConnection','客户与应用接入','connection','/plugin/sand-iam/connection/index',99,2),
('SandIAMPeopleAccess','应用用户与权限','people-access','/plugin/sand-iam/people-access/index',98,2),
('SandIAMAuditTroubleshooting','审计与排错','audit-troubleshooting','/plugin/sand-iam/audit-troubleshooting/index',97,2),
('SandIAMApiGovernance','接口与访问控制','api-governance','/plugin/sand-iam/api-governance/index',96,2),
('SandIAMAuthSession','认证与会话','auth-session','/plugin/sand-iam/auth-session/index',95,2),
('SandIAMEventNotification','事件通知','event-notification','/plugin/sand-iam/event-notification/index',94,2),
('SandIAMGettingStarted','第一次使用','getting-started','/plugin/sand-iam/getting-started/index',93,1),
('SandIAMOrganization','客户主体(组织)','organization','/plugin/sand-iam/organization/index',89,1),
('SandIAMApplication','接入应用','application','/plugin/sand-iam/application/index',88,1),
('SandIAMEnvironment','应用环境','environment','/plugin/sand-iam/environment/index',87,1),
('SandIAMWorkload','服务调用身份','workload-client','/plugin/sand-iam/workload-client/index',86,1),
('SandIAMGrant','服务授权','service-grant','/plugin/sand-iam/service-grant/index',85,1),
('SandIAMCredential','调用凭证','credential','/plugin/sand-iam/credential/index',84,1),
('SandIAMService','平台服务','service','/plugin/sand-iam/service/index',83,1),
('SandIAMServiceAction','服务动作','action','/plugin/sand-iam/action/index',82,1),
('SandIAMIdentityProvider','身份源','identity-provider','/plugin/sand-iam/identity-provider/index',81,1),
('SandIAMIdentity','应用用户身份','identity','/plugin/sand-iam/identity/index',80,1),
('SandIAMIdentityBinding','身份绑定','identity-binding','/plugin/sand-iam/identity-binding/index',79,1),
('SandIAMUserType','用户类型','user-type','/plugin/sand-iam/user-type/index',78,1),
('SandIAMRole','角色','role','/plugin/sand-iam/role/index',77,1),
('SandIAMIdentityUserType','身份用户类型','identity-user-type','/plugin/sand-iam/identity-user-type/index',76,1),
('SandIAMIdentityRole','身份角色','identity-role','/plugin/sand-iam/identity-role/index',75,1),
('SandIAMResource','业务资源','resource','/plugin/sand-iam/resource/index',74,1),
('SandIAMPolicy','授权策略','policy','/plugin/sand-iam/policy/index',73,1),
('SandIAMAdminScope','管理范围','admin-scope','/plugin/sand-iam/admin-scope/index',72,1),
('SandIAMAdminOrganizationGrant','客户主体管理委派','admin-organization-grant','/plugin/sand-iam/admin-organization-grant/index',72,1),
('SandIAMAudit','访问审计','audit','/plugin/sand-iam/audit/index',71,1),
('SandIAMApplicationBusinessAction','应用业务动作','application-business-action','/plugin/sand-iam/application-business-action/index',70,2),
('SandIAMApiResource','接口目录','api-resource','/plugin/sand-iam/api-resource/index',69,2),
('SandIAMApiRouteBinding','路由绑定','api-route-binding','/plugin/sand-iam/api-route-binding/index',68,2),
('SandIAMRouteManifest','路由清单','route-manifest','/plugin/sand-iam/route-manifest/index',67,2),
('SandIAMPolicySimulate','策略模拟','policy-simulate','/plugin/sand-iam/policy-simulate/index',66,2),
('SandIAMAuthPolicy','认证设置','auth-policy','/plugin/sand-iam/auth-policy/index',65,1),
('SandIAMApplicationExperience','登录外观','application-experience','/plugin/sand-iam/application-experience/index',64,1),
('SandIAMMessageProvider','消息服务','message-provider','/plugin/sand-iam/message-provider/index',63,1),
('SandIAMFederationConfig','联合配置','federation-config','/plugin/sand-iam/federation-config/index',62,1),
('SandIAMScimTokens','自动同步用户(SCIM)','scim-tokens','/plugin/sand-iam/scim-tokens/index',61,1),
('SandIAMRadiusNas','网络设备登录认证(RADIUS)','radius-nas','/plugin/sand-iam/radius-nas/index',60,1),
('SandIAMOAuthClient','OAuth 授权接入','oauth-client','/plugin/sand-iam/oauth-client/index',59,1),
('SandIAMOAuthRegistrationToken','OAuth 动态注册令牌','oauth-registration-token','/plugin/sand-iam/oauth-registration-token/index',58,1),
('SandIAMCasService','CAS 单点接入','cas-service','/plugin/sand-iam/cas-service/index',57,1),
('SandIAMDeveloperDocs','开发者接入','developer-docs','/plugin/sand-iam/developer-docs/index',56,1),
('SandIAMAdminApplicationGrant','应用管理员委派','admin-application-grant','/plugin/sand-iam/admin-application-grant/index',55,1),
('SandIAMIdentityGroup','用户组','identity-group','/plugin/sand-iam/identity-group/index',54,1),
('SandIAMIdentityInvitation','用户邀请','identity-invitation','/plugin/sand-iam/identity-invitation/index',53,1),
('SandIAMIdentityImport','用户导入导出','identity-import','/plugin/sand-iam/identity-import/index',52,1),
('SandIAMSyncConnector','用户同步','sync-connector','/plugin/sand-iam/sync-connector/index',51,1),
('SandIAMWebhook','事件通知地址','webhook','/plugin/sand-iam/webhook/index',50,1),
('SandIAMWebhookDelivery','投递记录','webhook-delivery','/plugin/sand-iam/webhook-delivery/index',49,1),
('SandIAMApplicationNetworkPolicy','应用网络规则','application-network-policy','/plugin/sand-iam/application-network-policy/index',48,1),
('SandIAMSecurityAlert','安全告警','security-alert','/plugin/sand-iam/security-alert/index',47,1),
('SandIAMAuditRetentionPolicy','审计保留策略','audit-retention-policy','/plugin/sand-iam/audit-retention-policy/index',46,1),
('SandIAMInitialization','初始化配置','initialization','/plugin/sand-iam/initialization/index',45,1)
), route_menu("code") AS (
VALUES
('SandIAMConnection'),
('SandIAMPeopleAccess'),
('SandIAMAuthSession'),
('SandIAMAuditTroubleshooting'),
('SandIAMApiGovernance'),
('SandIAMAdminScope'),
('SandIAMEventNotification'),
('SandIAMGettingStarted'),
('SandIAMApplicationBusinessAction'),
('SandIAMApiResource'),
('SandIAMApiRouteBinding'),
('SandIAMRouteManifest'),
('SandIAMPolicySimulate'),
('SandIAMAuthPolicy'),
('SandIAMApplicationExperience'),
('SandIAMMessageProvider'),
('SandIAMFederationConfig'),
('SandIAMScimTokens'),
('SandIAMRadiusNas'),
('SandIAMOAuthClient'),
('SandIAMOAuthRegistrationToken'),
('SandIAMCasService'),
('SandIAMDeveloperDocs'),
('SandIAMAdminApplicationGrant'),
('SandIAMIdentityGroup'),
('SandIAMIdentityInvitation'),
('SandIAMIdentityImport'),
('SandIAMSyncConnector'),
('SandIAMWebhook'),
('SandIAMWebhookDelivery'),
('SandIAMApplicationNetworkPolicy'),
('SandIAMSecurityAlert'),
('SandIAMAuditRetentionPolicy'),
('SandIAMInitialization')
), canonical_route("id","code") AS (
SELECT DISTINCT ON (candidate."code") candidate."id", candidate."code"
FROM "sand_system_menu" candidate
JOIN route_menu ON route_menu."code" = candidate."code"
CROSS JOIN LATERAL (
SELECT "id" FROM "sand_system_menu" WHERE "code" = 'SandIAM' ORDER BY "id" LIMIT 1
) root
ORDER BY candidate."code",
CASE WHEN candidate."parent_id" = root."id" AND candidate."type" = 2 THEN 0 ELSE 1 END,
candidate."id"
)
UPDATE "sand_system_menu" menu
SET "parent_id" = CASE WHEN route_menu."code" IS NULL THEN menu."parent_id" ELSE root."id" END,
"type" = CASE WHEN route_menu."code" IS NULL THEN menu."type" ELSE 2 END,
"name" = menu_def."name",
"path" = menu_def."path",
"component" = menu_def."component",
"sort" = menu_def."sort",
"is_hidden" = menu_def."is_hidden",
"status" = 1,
"update_time" = NOW()
FROM menu_def
LEFT JOIN route_menu ON route_menu."code" = menu_def."code"
CROSS JOIN LATERAL (
SELECT "id" FROM "sand_system_menu" WHERE "code" = 'SandIAM' ORDER BY "id" LIMIT 1
) root
LEFT JOIN canonical_route ON canonical_route."code" = menu_def."code"
WHERE menu."code" = menu_def."code"
AND (route_menu."code" IS NULL OR menu."id" = canonical_route."id");
WITH menu_def("code","name","path","component","sort","is_hidden") AS (
VALUES
('SandIAMOverview','首页','overview','/plugin/sand-iam/index/index',100,2),
('SandIAMConnection','客户与应用接入','connection','/plugin/sand-iam/connection/index',99,2),
('SandIAMPeopleAccess','应用用户与权限','people-access','/plugin/sand-iam/people-access/index',98,2),
('SandIAMAuditTroubleshooting','审计与排错','audit-troubleshooting','/plugin/sand-iam/audit-troubleshooting/index',97,2),
('SandIAMApiGovernance','接口与访问控制','api-governance','/plugin/sand-iam/api-governance/index',96,2),
('SandIAMAuthSession','认证与会话','auth-session','/plugin/sand-iam/auth-session/index',95,2),
('SandIAMEventNotification','事件通知','event-notification','/plugin/sand-iam/event-notification/index',94,2),
('SandIAMGettingStarted','第一次使用','getting-started','/plugin/sand-iam/getting-started/index',93,1),
('SandIAMOrganization','客户主体(组织)','organization','/plugin/sand-iam/organization/index',89,1),
('SandIAMApplication','接入应用','application','/plugin/sand-iam/application/index',88,1),
('SandIAMEnvironment','应用环境','environment','/plugin/sand-iam/environment/index',87,1),
('SandIAMWorkload','服务调用身份','workload-client','/plugin/sand-iam/workload-client/index',86,1),
('SandIAMGrant','服务授权','service-grant','/plugin/sand-iam/service-grant/index',85,1),
('SandIAMCredential','调用凭证','credential','/plugin/sand-iam/credential/index',84,1),
('SandIAMService','平台服务','service','/plugin/sand-iam/service/index',83,1),
('SandIAMServiceAction','服务动作','action','/plugin/sand-iam/action/index',82,1),
('SandIAMIdentityProvider','身份源','identity-provider','/plugin/sand-iam/identity-provider/index',81,1),
('SandIAMIdentity','应用用户身份','identity','/plugin/sand-iam/identity/index',80,1),
('SandIAMIdentityBinding','身份绑定','identity-binding','/plugin/sand-iam/identity-binding/index',79,1),
('SandIAMUserType','用户类型','user-type','/plugin/sand-iam/user-type/index',78,1),
('SandIAMRole','角色','role','/plugin/sand-iam/role/index',77,1),
('SandIAMIdentityUserType','身份用户类型','identity-user-type','/plugin/sand-iam/identity-user-type/index',76,1),
('SandIAMIdentityRole','身份角色','identity-role','/plugin/sand-iam/identity-role/index',75,1),
('SandIAMResource','业务资源','resource','/plugin/sand-iam/resource/index',74,1),
('SandIAMPolicy','授权策略','policy','/plugin/sand-iam/policy/index',73,1),
('SandIAMAdminScope','管理范围','admin-scope','/plugin/sand-iam/admin-scope/index',72,1),
('SandIAMAdminOrganizationGrant','客户主体管理委派','admin-organization-grant','/plugin/sand-iam/admin-organization-grant/index',72,1),
('SandIAMAudit','访问审计','audit','/plugin/sand-iam/audit/index',71,1),
('SandIAMApplicationBusinessAction','应用业务动作','application-business-action','/plugin/sand-iam/application-business-action/index',70,2),
('SandIAMApiResource','接口目录','api-resource','/plugin/sand-iam/api-resource/index',69,2),
('SandIAMApiRouteBinding','路由绑定','api-route-binding','/plugin/sand-iam/api-route-binding/index',68,2),
('SandIAMRouteManifest','路由清单','route-manifest','/plugin/sand-iam/route-manifest/index',67,2),
('SandIAMPolicySimulate','策略模拟','policy-simulate','/plugin/sand-iam/policy-simulate/index',66,2),
('SandIAMAuthPolicy','认证设置','auth-policy','/plugin/sand-iam/auth-policy/index',65,1),
('SandIAMApplicationExperience','登录外观','application-experience','/plugin/sand-iam/application-experience/index',64,1),
('SandIAMMessageProvider','消息服务','message-provider','/plugin/sand-iam/message-provider/index',63,1),
('SandIAMFederationConfig','联合配置','federation-config','/plugin/sand-iam/federation-config/index',62,1),
('SandIAMScimTokens','自动同步用户(SCIM)','scim-tokens','/plugin/sand-iam/scim-tokens/index',61,1),
('SandIAMRadiusNas','网络设备登录认证(RADIUS)','radius-nas','/plugin/sand-iam/radius-nas/index',60,1),
('SandIAMOAuthClient','OAuth 授权接入','oauth-client','/plugin/sand-iam/oauth-client/index',59,1),
('SandIAMOAuthRegistrationToken','OAuth 动态注册令牌','oauth-registration-token','/plugin/sand-iam/oauth-registration-token/index',58,1),
('SandIAMCasService','CAS 单点接入','cas-service','/plugin/sand-iam/cas-service/index',57,1),
('SandIAMDeveloperDocs','开发者接入','developer-docs','/plugin/sand-iam/developer-docs/index',56,1),
('SandIAMAdminApplicationGrant','应用管理员委派','admin-application-grant','/plugin/sand-iam/admin-application-grant/index',55,1),
('SandIAMIdentityGroup','用户组','identity-group','/plugin/sand-iam/identity-group/index',54,1),
('SandIAMIdentityInvitation','用户邀请','identity-invitation','/plugin/sand-iam/identity-invitation/index',53,1),
('SandIAMIdentityImport','用户导入导出','identity-import','/plugin/sand-iam/identity-import/index',52,1),
('SandIAMSyncConnector','用户同步','sync-connector','/plugin/sand-iam/sync-connector/index',51,1),
('SandIAMWebhook','事件通知地址','webhook','/plugin/sand-iam/webhook/index',50,1),
('SandIAMWebhookDelivery','投递记录','webhook-delivery','/plugin/sand-iam/webhook-delivery/index',49,1),
('SandIAMApplicationNetworkPolicy','应用网络规则','application-network-policy','/plugin/sand-iam/application-network-policy/index',48,1),
('SandIAMSecurityAlert','安全告警','security-alert','/plugin/sand-iam/security-alert/index',47,1),
('SandIAMAuditRetentionPolicy','审计保留策略','audit-retention-policy','/plugin/sand-iam/audit-retention-policy/index',46,1),
('SandIAMInitialization','初始化配置','initialization','/plugin/sand-iam/initialization/index',45,1)
)
INSERT INTO "sand_system_menu"
("parent_id","name","code","slug","type","path","component","icon","sort","is_hidden","status","create_time","update_time")
SELECT root."id", menu_def."name", menu_def."code", '', 2, menu_def."path", menu_def."component", '', menu_def."sort", menu_def."is_hidden", 1, NOW(), NOW()
FROM menu_def
JOIN LATERAL (
SELECT "id" FROM "sand_system_menu" WHERE "code" = 'SandIAM' ORDER BY "id" LIMIT 1
) root ON TRUE
WHERE NOT EXISTS (
SELECT 1 FROM "sand_system_menu" existing WHERE existing."code" = menu_def."code"
);
-- 已有受限角色保留原实体权限时,同时补上新的任务路径入口;这里只补导航,不授予接口权限。
WITH path_entity("path_code","entity_code") AS (
VALUES
('SandIAMConnection','SandIAMOrganization'),
('SandIAMConnection','SandIAMApplication'),
('SandIAMConnection','SandIAMEnvironment'),
('SandIAMConnection','SandIAMWorkload'),
('SandIAMConnection','SandIAMGrant'),
('SandIAMConnection','SandIAMCredential'),
('SandIAMConnection','SandIAMService'),
('SandIAMConnection','SandIAMServiceAction'),
('SandIAMPeopleAccess','SandIAMIdentityProvider'),
('SandIAMPeopleAccess','SandIAMIdentity'),
('SandIAMPeopleAccess','SandIAMIdentityBinding'),
('SandIAMPeopleAccess','SandIAMUserType'),
('SandIAMPeopleAccess','SandIAMRole'),
('SandIAMPeopleAccess','SandIAMIdentityUserType'),
('SandIAMPeopleAccess','SandIAMIdentityRole'),
('SandIAMPeopleAccess','SandIAMResource'),
('SandIAMPeopleAccess','SandIAMPolicy'),
('SandIAMPeopleAccess','SandIAMAdminScope'),
('SandIAMPeopleAccess','SandIAMAdminOrganizationGrant'),
('SandIAMAuditTroubleshooting','SandIAMAudit'),
('SandIAMAuditTroubleshooting','SandIAMGrant'),
('SandIAMAuditTroubleshooting','SandIAMCredential'),
('SandIAMApiGovernance','SandIAMApiResource'),
('SandIAMApiGovernance','SandIAMApiRouteBinding'),
('SandIAMApiGovernance','SandIAMPolicy'),
('SandIAMApiGovernance','SandIAMConnection'),
('SandIAMApplicationBusinessAction','SandIAMApiResource'),
('SandIAMApiResource','SandIAMApiResource'),
('SandIAMApiRouteBinding','SandIAMApiRouteBinding'),
('SandIAMRouteManifest','SandIAMConnection'),
('SandIAMPolicySimulate','SandIAMPolicy')
), route_menu("code") AS (
SELECT menu."code"
FROM "sand_system_menu" menu
JOIN "sand_system_menu" root ON root."id" = menu."parent_id"
WHERE root."code" = 'SandIAM'
AND menu."type" = 2
), sandiam_role("role_id","entity_code") AS (
SELECT DISTINCT role_menu."role_id", entity."code"
FROM "sand_system_role_menu" role_menu
JOIN "sand_system_menu" assigned ON assigned."id" = role_menu."menu_id"
JOIN "sand_system_menu" entity
ON entity."id" = assigned."id" OR entity."id" = assigned."parent_id"
JOIN "sand_system_menu" root
ON root."id" = entity."parent_id" AND root."code" = 'SandIAM'
WHERE entity."code" <> 'SandIAMOverview'
AND NOT EXISTS (
SELECT 1 FROM route_menu WHERE route_menu."code" = entity."code"
)
), route_menu_anchor("anchor_code","route_code") AS (
VALUES
('SandIAMConnection','SandIAMApiGovernance'),
('SandIAMConnection','SandIAMRouteManifest'),
('SandIAMPolicy','SandIAMApiGovernance'),
('SandIAMPolicy','SandIAMPolicySimulate')
), route_permission_anchor("anchor_slug","route_code") AS (
VALUES
('sand_iam:organization:index','SandIAMConnection'),
('sand_iam:identity:index','SandIAMPeopleAccess'),
('sand_iam:auth_policy:index','SandIAMAuthSession'),
('sand_iam:audit:index','SandIAMAuditTroubleshooting'),
('sand_iam:api_resource:index','SandIAMApiGovernance'),
('sand_iam:api_resource:index','SandIAMApplicationBusinessAction'),
('sand_iam:api_resource:index','SandIAMApiResource'),
('sand_iam:api_route_binding:index','SandIAMApiGovernance'),
('sand_iam:api_route_binding:index','SandIAMApiRouteBinding'),
('sand_iam:onboarding:preview','SandIAMRouteManifest'),
('sand_iam:policy:index','SandIAMPolicySimulate'),
('sand_iam:auth_policy:index','SandIAMAuthPolicy'),
('sand_iam:application_experience:index','SandIAMApplicationExperience'),
('sand_iam:message_provider:index','SandIAMMessageProvider'),
('sand_iam:federation:configure','SandIAMFederationConfig'),
('sand_iam:scim:token_index','SandIAMScimTokens'),
('sand_iam:radius_nas:index','SandIAMRadiusNas'),
('sand_iam:oauth_client:index','SandIAMOAuthClient'),
('sand_iam:oauth_registration_token:index','SandIAMOAuthRegistrationToken'),
('sand_iam:cas_service:index','SandIAMCasService'),
('sand_iam:developer:openapi','SandIAMDeveloperDocs'),
('sand_iam:admin_organization_grant:index','SandIAMAdminScope'),
('sand_iam:admin_application_grant:index','SandIAMAdminScope'),
('sand_iam:admin_application_grant:index','SandIAMAdminApplicationGrant'),
('sand_iam:identity_group:index','SandIAMIdentityGroup'),
('sand_iam:identity_invitation:index','SandIAMIdentityInvitation'),
('sand_iam:identity_import:index','SandIAMIdentityImport'),
('sand_iam:sync_connector:index','SandIAMSyncConnector'),
('sand_iam:webhook:index','SandIAMEventNotification'),
('sand_iam:webhook:index','SandIAMWebhook'),
('sand_iam:webhook_delivery:index','SandIAMWebhookDelivery'),
('sand_iam:application_network_policy:index','SandIAMApplicationNetworkPolicy'),
('sand_iam:security_alert:index','SandIAMSecurityAlert'),
('sand_iam:audit_retention_policy:index','SandIAMAuditRetentionPolicy'),
('sand_iam:initialization:index','SandIAMInitialization')
), sandiam_root("id") AS (
SELECT "id"
FROM "sand_system_menu"
WHERE "code" = 'SandIAM'
ORDER BY "id"
LIMIT 1
), route_target("code","menu_id") AS (
SELECT menu."code", menu."id"
FROM "sand_system_menu" menu
JOIN sandiam_root ON menu."parent_id" = sandiam_root."id"
JOIN route_menu ON route_menu."code" = menu."code"
WHERE menu."type" = 2
AND NOT EXISTS (
SELECT 1
FROM "sand_system_menu" duplicate_route
WHERE duplicate_route."code" = menu."code"
AND duplicate_route."parent_id" = menu."parent_id"
AND duplicate_route."type" = 2
AND duplicate_route."id" <> menu."id"
)
), route_anchor_required("role_id","menu_id") AS (
-- Keep route inheritance exact: navigation/entity menu anchors use code,
-- while hidden machine-action leaves use their stable permission slug.
SELECT DISTINCT role_menu."role_id", route_target."menu_id"
FROM "sand_system_role_menu" role_menu
JOIN "sand_system_menu" anchor ON anchor."id" = role_menu."menu_id"
JOIN route_menu_anchor ON route_menu_anchor."anchor_code" = anchor."code"
JOIN route_target ON route_target."code" = route_menu_anchor."route_code"
UNION
SELECT DISTINCT role_menu."role_id", route_target."menu_id"
FROM "sand_system_role_menu" role_menu
JOIN "sand_system_menu" permission ON permission."id" = role_menu."menu_id"
JOIN route_permission_anchor ON route_permission_anchor."anchor_slug" = permission."slug"
JOIN route_target ON route_target."code" = route_permission_anchor."route_code"
), route_role("role_id") AS (
SELECT DISTINCT "role_id" FROM route_anchor_required
), overview_access_role("role_id") AS (
SELECT "role_id" FROM sandiam_role
UNION
SELECT "role_id" FROM route_role
UNION
SELECT role_menu."role_id"
FROM "sand_system_role_menu" role_menu
JOIN "sand_system_menu" overview ON overview."id" = role_menu."menu_id"
WHERE overview."code" = 'SandIAMOverview'
), required_menu("role_id","menu_id") AS (
SELECT DISTINCT sandiam_role."role_id", menu."id"
FROM sandiam_role
JOIN "sand_system_menu" menu ON menu."code" IN ('SandIAM','SandIAMOverview')
UNION
SELECT DISTINCT route_role."role_id", menu."id"
FROM route_role
JOIN "sand_system_menu" menu ON menu."code" IN ('SandIAM','SandIAMOverview')
UNION
SELECT DISTINCT overview_access_role."role_id", menu."id"
FROM overview_access_role
JOIN "sand_system_menu" menu ON menu."code" = 'SandIAMGettingStarted'
UNION
SELECT DISTINCT sandiam_role."role_id", menu."id"
FROM sandiam_role
JOIN path_entity ON path_entity."entity_code" = sandiam_role."entity_code"
JOIN "sand_system_menu" menu ON menu."code" = path_entity."path_code"
LEFT JOIN route_menu ON route_menu."code" = path_entity."path_code"
WHERE route_menu."code" IS NULL
UNION
SELECT "role_id", "menu_id"
FROM route_anchor_required
)
INSERT INTO "sand_system_role_menu" ("role_id","menu_id")
SELECT required_menu."role_id", required_menu."menu_id"
FROM required_menu
WHERE NOT EXISTS (
SELECT 1 FROM "sand_system_role_menu" existing
WHERE existing."role_id" = required_menu."role_id"
AND existing."menu_id" = required_menu."menu_id"
);
-- The host does not enforce this pair as a unique constraint. Keep one row
-- per relationship so a previous lifecycle run cannot retain true duplicates.
DELETE FROM "sand_system_role_menu" duplicate
USING "sand_system_role_menu" retained, "sand_system_menu" menu
WHERE duplicate."role_id" = retained."role_id"
AND duplicate."menu_id" = retained."menu_id"
AND menu."id" = duplicate."menu_id"
AND (
menu."code" = 'SandIAM'
OR menu."code" LIKE 'SandIAM%'
OR menu."code" LIKE 'sand\_iam:%' ESCAPE '\'
)
AND duplicate.ctid > retained.ctid;
WITH permission_def("parent_code","name","slug","sort") AS (
VALUES
('SandIAMOrganization','列表','sand_iam:organization:index',100),
('SandIAMOrganization','读取','sand_iam:organization:read',99),
('SandIAMOrganization','保存','sand_iam:organization:save',98),
('SandIAMOrganization','更新','sand_iam:organization:update',97),
('SandIAMOrganization','停用','sand_iam:organization:disable',96),
('SandIAMApplication','列表','sand_iam:application:index',100),
('SandIAMApplication','读取','sand_iam:application:read',99),
('SandIAMApplication','保存','sand_iam:application:save',98),
('SandIAMApplication','更新','sand_iam:application:update',97),
('SandIAMApplication','停用','sand_iam:application:disable',96),
('SandIAMEnvironment','列表','sand_iam:environment:index',100),
('SandIAMEnvironment','读取','sand_iam:environment:read',99),
('SandIAMEnvironment','保存','sand_iam:environment:save',98),
('SandIAMEnvironment','更新','sand_iam:environment:update',97),
('SandIAMEnvironment','停用','sand_iam:environment:disable',96),
('SandIAMWorkload','列表','sand_iam:client:index',100),
('SandIAMWorkload','读取','sand_iam:client:read',99),
('SandIAMWorkload','保存','sand_iam:client:save',98),
('SandIAMWorkload','更新','sand_iam:client:update',97),
('SandIAMWorkload','停用','sand_iam:client:disable',96),
('SandIAMGrant','列表','sand_iam:grant:index',100),
('SandIAMGrant','读取','sand_iam:grant:read',99),
('SandIAMGrant','保存','sand_iam:grant:save',98),
('SandIAMGrant','更新','sand_iam:grant:update',97),
('SandIAMGrant','撤销','sand_iam:grant:revoke',96),
('SandIAMCredential','列表','sand_iam:credential:index',100),
('SandIAMCredential','读取','sand_iam:credential:read',99),
('SandIAMCredential','签发','sand_iam:credential:issue',98),
('SandIAMCredential','轮换','sand_iam:credential:rotate',97),
('SandIAMCredential','撤销','sand_iam:credential:revoke',96),
('SandIAMService','列表','sand_iam:service:index',100),
('SandIAMService','读取','sand_iam:service:read',99),
('SandIAMService','保存','sand_iam:service:save',98),
('SandIAMService','更新','sand_iam:service:update',97),
('SandIAMService','停用','sand_iam:service:disable',96),
('SandIAMServiceAction','列表','sand_iam:service_action:index',100),
('SandIAMServiceAction','读取','sand_iam:service_action:read',99),
('SandIAMServiceAction','保存','sand_iam:service_action:save',98),
('SandIAMServiceAction','更新','sand_iam:service_action:update',97),
('SandIAMServiceAction','停用','sand_iam:service_action:disable',96),
('SandIAMIdentityProvider','列表','sand_iam:identity_provider:index',100),
('SandIAMIdentityProvider','读取','sand_iam:identity_provider:read',99),
('SandIAMIdentityProvider','保存','sand_iam:identity_provider:save',98),
('SandIAMIdentityProvider','更新','sand_iam:identity_provider:update',97),
('SandIAMIdentityProvider','停用','sand_iam:identity_provider:disable',96),
('SandIAMIdentity','列表','sand_iam:identity:index',100),
('SandIAMIdentity','读取','sand_iam:identity:read',99),
('SandIAMIdentity','保存','sand_iam:identity:save',98),
('SandIAMIdentity','更新','sand_iam:identity:update',97),
('SandIAMIdentity','停用','sand_iam:identity:disable',96),
('SandIAMIdentityBinding','列表','sand_iam:identity_binding:index',100),
('SandIAMIdentityBinding','读取','sand_iam:identity_binding:read',99),
('SandIAMIdentityBinding','保存','sand_iam:identity_binding:save',98),
('SandIAMIdentityBinding','更新','sand_iam:identity_binding:update',97),
('SandIAMIdentityBinding','停用','sand_iam:identity_binding:disable',96),
('SandIAMUserType','列表','sand_iam:user_type:index',100),
('SandIAMUserType','读取','sand_iam:user_type:read',99),
('SandIAMUserType','保存','sand_iam:user_type:save',98),
('SandIAMUserType','更新','sand_iam:user_type:update',97),
('SandIAMUserType','停用','sand_iam:user_type:disable',96),
('SandIAMRole','列表','sand_iam:role:index',100),
('SandIAMRole','读取','sand_iam:role:read',99),
('SandIAMRole','保存','sand_iam:role:save',98),
('SandIAMRole','更新','sand_iam:role:update',97),
('SandIAMRole','停用','sand_iam:role:disable',96),
('SandIAMIdentityUserType','列表','sand_iam:identity_user_type:index',100),
('SandIAMIdentityUserType','授予','sand_iam:identity_user_type:grant',99),
('SandIAMIdentityUserType','撤销','sand_iam:identity_user_type:revoke',98),
('SandIAMIdentityRole','列表','sand_iam:identity_role:index',100),
('SandIAMIdentityRole','授予','sand_iam:identity_role:grant',99),
('SandIAMIdentityRole','撤销','sand_iam:identity_role:revoke',98),
('SandIAMResource','列表','sand_iam:resource:index',100),
('SandIAMResource','读取','sand_iam:resource:read',99),
('SandIAMResource','保存','sand_iam:resource:save',98),
('SandIAMResource','更新','sand_iam:resource:update',97),
('SandIAMResource','停用','sand_iam:resource:disable',96),
('SandIAMPolicy','列表','sand_iam:policy:index',100),
('SandIAMPolicy','读取','sand_iam:policy:read',99),
('SandIAMPolicy','保存','sand_iam:policy:save',98),
('SandIAMPolicy','更新','sand_iam:policy:update',97),
('SandIAMPolicy','停用','sand_iam:policy:disable',96),
('SandIAMPolicy','发布','sand_iam:policy:publish',95),
('SandIAMPolicy','撤销','sand_iam:policy:revoke',94),
('SandIAMAdminOrganizationGrant','列表','sand_iam:admin_organization_grant:index',100),
('SandIAMAdminOrganizationGrant','读取','sand_iam:admin_organization_grant:read',99),
('SandIAMAdminOrganizationGrant','保存','sand_iam:admin_organization_grant:save',98),
('SandIAMAdminOrganizationGrant','更新','sand_iam:admin_organization_grant:update',97),
('SandIAMAdminOrganizationGrant','停用','sand_iam:admin_organization_grant:disable',96),
('SandIAMAudit','列表','sand_iam:audit:index',100),
('SandIAMIdentity','认证策略列表','sand_iam:auth_policy:index',95),
('SandIAMIdentity','认证策略读取','sand_iam:auth_policy:read',94),
('SandIAMIdentity','认证策略保存','sand_iam:auth_policy:save',93),
('SandIAMIdentity','认证策略更新','sand_iam:auth_policy:update',92),
('SandIAMIdentity','认证策略停用','sand_iam:auth_policy:disable',91),
('SandIAMAudit','读取','sand_iam:audit:read',99)
)
INSERT INTO "sand_system_menu"
("parent_id","name","code","slug","type","path","component","icon","sort","status","create_time","update_time")
SELECT parent."id", permission_def."name", '', permission_def."slug", 3, '', '', '', permission_def."sort", 1, NOW(), NOW()
FROM permission_def
JOIN "sand_system_menu" parent ON parent."code" = permission_def."parent_code"
WHERE NOT EXISTS (
SELECT 1 FROM "sand_system_menu" existing WHERE existing."slug" = permission_def."slug"
);
-- Authoritative source for a fresh package installation.
-- This script owns only sand_iam_* objects.
BEGIN;
CREATE TABLE IF NOT EXISTS sand_iam_organization (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_organization_code UNIQUE (code)
);
CREATE TABLE IF NOT EXISTS sand_iam_application (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
organization_id bigint NOT NULL REFERENCES sand_iam_organization(id) ON DELETE RESTRICT,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_application_organization_code UNIQUE (organization_id, code)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_application_organization_id ON sand_iam_application (organization_id);
CREATE TABLE IF NOT EXISTS sand_iam_environment (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
application_id bigint NOT NULL REFERENCES sand_iam_application(id) ON DELETE RESTRICT,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_environment_application_code UNIQUE (application_id, code)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_environment_application_id ON sand_iam_environment (application_id);
CREATE TABLE IF NOT EXISTS sand_iam_workload_client (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
environment_id bigint NOT NULL REFERENCES sand_iam_environment(id) ON DELETE RESTRICT,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
audience varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_workload_client_environment_code UNIQUE (environment_id, code)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_workload_client_environment_id ON sand_iam_workload_client (environment_id);
CREATE TABLE IF NOT EXISTS sand_iam_credential (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
workload_client_id bigint NOT NULL REFERENCES sand_iam_workload_client(id) ON DELETE RESTRICT,
name varchar(128) NOT NULL,
key_prefix varchar(32) NOT NULL,
secret_hash varchar(255) NOT NULL,
expire_time timestamp(0) without time zone NULL,
revoked_time timestamp(0) without time zone NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_credential_key_prefix UNIQUE (key_prefix),
CONSTRAINT uk_sand_iam_credential_secret_hash UNIQUE (secret_hash)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_credential_client_active ON sand_iam_credential (workload_client_id, status, expire_time);
CREATE TABLE IF NOT EXISTS sand_iam_service (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_service_code UNIQUE (code)
);
CREATE TABLE IF NOT EXISTS sand_iam_service_action (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
service_id bigint NOT NULL REFERENCES sand_iam_service(id) ON DELETE RESTRICT,
code varchar(96) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_service_action_service_code UNIQUE (service_id, code)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_service_action_service_id ON sand_iam_service_action (service_id);
CREATE TABLE IF NOT EXISTS sand_iam_service_grant (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
workload_client_id bigint NOT NULL REFERENCES sand_iam_workload_client(id) ON DELETE RESTRICT,
service_action_id bigint NOT NULL REFERENCES sand_iam_service_action(id) ON DELETE RESTRICT,
audience varchar(128) NOT NULL,
quota_policy jsonb NOT NULL DEFAULT '{}'::jsonb,
data_class varchar(32) NULL DEFAULT 'internal',
network_policy jsonb NOT NULL DEFAULT '{}'::jsonb,
expire_time timestamp(0) without time zone NULL,
revoked_time timestamp(0) without time zone NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_service_grant_client_action_audience UNIQUE (workload_client_id, service_action_id, audience)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_service_grant_action_active ON sand_iam_service_grant (service_action_id, status, expire_time);
CREATE TABLE IF NOT EXISTS sand_iam_identity (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
application_id bigint NOT NULL REFERENCES sand_iam_application(id) ON DELETE RESTRICT,
code varchar(64) NOT NULL,
display_name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_identity_application_code UNIQUE (application_id, code),
CONSTRAINT uk_sand_iam_identity_id_application UNIQUE (id, application_id)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_identity_application_id ON sand_iam_identity (application_id);
CREATE TABLE IF NOT EXISTS sand_iam_identity_provider (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
application_id bigint NOT NULL REFERENCES sand_iam_application(id) ON DELETE RESTRICT,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_identity_provider_application_code UNIQUE (application_id, code),
CONSTRAINT uk_sand_iam_identity_provider_id_application UNIQUE (id, application_id)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_identity_provider_application_id ON sand_iam_identity_provider (application_id);
CREATE TABLE IF NOT EXISTS sand_iam_identity_binding (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
application_id bigint NOT NULL,
identity_id bigint NOT NULL,
identity_provider_id bigint NOT NULL,
subject varchar(191) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_identity_binding_provider_subject UNIQUE (identity_provider_id, subject),
CONSTRAINT fk_sand_iam_identity_binding_identity_application FOREIGN KEY (identity_id, application_id) REFERENCES sand_iam_identity(id, application_id) ON DELETE RESTRICT,
CONSTRAINT fk_sand_iam_identity_binding_provider_application FOREIGN KEY (identity_provider_id, application_id) REFERENCES sand_iam_identity_provider(id, application_id) ON DELETE RESTRICT
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_identity_binding_identity_id ON sand_iam_identity_binding (identity_id);
CREATE INDEX IF NOT EXISTS idx_sand_iam_identity_binding_provider_id ON sand_iam_identity_binding (identity_provider_id);
CREATE INDEX IF NOT EXISTS idx_sand_iam_identity_binding_application_id ON sand_iam_identity_binding (application_id);
CREATE TABLE IF NOT EXISTS sand_iam_user_type (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
application_id bigint NOT NULL REFERENCES sand_iam_application(id) ON DELETE RESTRICT,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_user_type_application_code UNIQUE (application_id, code)
);
CREATE TABLE IF NOT EXISTS sand_iam_identity_user_type (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
identity_id bigint NOT NULL REFERENCES sand_iam_identity(id) ON DELETE RESTRICT,
user_type_id bigint NOT NULL REFERENCES sand_iam_user_type(id) ON DELETE RESTRICT,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_identity_user_type_identity_type UNIQUE (identity_id, user_type_id)
);
CREATE INDEX IF NOT EXISTS idx_sand_iam_identity_user_type_type_id ON sand_iam_identity_user_type (user_type_id);
CREATE TABLE IF NOT EXISTS sand_iam_role (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
application_id bigint NOT NULL REFERENCES sand_iam_application(id) ON DELETE RESTRICT,
code varchar(64) NOT NULL,
name varchar(128) NOT NULL,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
delete_time timestamp(0) without time zone NULL,
CONSTRAINT uk_sand_iam_role_application_code UNIQUE (application_id, code)
);
CREATE TABLE IF NOT EXISTS sand_iam_identity_role (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
identity_id bigint NOT NULL REFERENCES sand_iam_identity(id) ON DELETE RESTRICT,
role_id bigint NOT NULL REFERENCES sand_iam_role(id) ON DELETE RESTRICT,
status smallint NOT NULL DEFAULT 1 CHECK (status IN (1, 2)),
created_by bigint NULL,
updated_by bigint NULL,
create_time timestamp(0) without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,