@@ -441,9 +441,9 @@ func As(ctx context.Context, actor rbac.Subject) context.Context {
441
441
// running the insertFunc. The insertFunc is expected to return the object that
442
442
// was inserted.
443
443
func insert [
444
- ObjectType any ,
445
- ArgumentType any ,
446
- Insert func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
444
+ ObjectType any ,
445
+ ArgumentType any ,
446
+ Insert func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
447
447
](
448
448
logger slog.Logger ,
449
449
authorizer rbac.Authorizer ,
@@ -454,9 +454,9 @@ func insert[
454
454
}
455
455
456
456
func insertWithAction [
457
- ObjectType any ,
458
- ArgumentType any ,
459
- Insert func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
457
+ ObjectType any ,
458
+ ArgumentType any ,
459
+ Insert func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
460
460
](
461
461
logger slog.Logger ,
462
462
authorizer rbac.Authorizer ,
@@ -483,10 +483,10 @@ func insertWithAction[
483
483
}
484
484
485
485
func deleteQ [
486
- ObjectType rbac.Objecter ,
487
- ArgumentType any ,
488
- Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
489
- Delete func (ctx context.Context ,arg ArgumentType )error ,
486
+ ObjectType rbac.Objecter ,
487
+ ArgumentType any ,
488
+ Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
489
+ Delete func (ctx context.Context ,arg ArgumentType )error ,
490
490
](
491
491
logger slog.Logger ,
492
492
authorizer rbac.Authorizer ,
@@ -498,10 +498,10 @@ func deleteQ[
498
498
}
499
499
500
500
func updateWithReturn [
501
- ObjectType rbac.Objecter ,
502
- ArgumentType any ,
503
- Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
504
- UpdateQuery func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
501
+ ObjectType rbac.Objecter ,
502
+ ArgumentType any ,
503
+ Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
504
+ UpdateQuery func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
505
505
](
506
506
logger slog.Logger ,
507
507
authorizer rbac.Authorizer ,
@@ -512,10 +512,10 @@ func updateWithReturn[
512
512
}
513
513
514
514
func update [
515
- ObjectType rbac.Objecter ,
516
- ArgumentType any ,
517
- Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
518
- Exec func (ctx context.Context ,arg ArgumentType )error ,
515
+ ObjectType rbac.Objecter ,
516
+ ArgumentType any ,
517
+ Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
518
+ Exec func (ctx context.Context ,arg ArgumentType )error ,
519
519
](
520
520
logger slog.Logger ,
521
521
authorizer rbac.Authorizer ,
@@ -533,9 +533,9 @@ func update[
533
533
// user cannot read the resource. This is because the resource details are
534
534
// required to run a proper authorization check.
535
535
func fetchWithAction [
536
- ArgumentType any ,
537
- ObjectType rbac.Objecter ,
538
- DatabaseFunc func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
536
+ ArgumentType any ,
537
+ ObjectType rbac.Objecter ,
538
+ DatabaseFunc func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
539
539
](
540
540
logger slog.Logger ,
541
541
authorizer rbac.Authorizer ,
@@ -566,9 +566,9 @@ func fetchWithAction[
566
566
}
567
567
568
568
func fetch [
569
- ArgumentType any ,
570
- ObjectType rbac.Objecter ,
571
- DatabaseFunc func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
569
+ ArgumentType any ,
570
+ ObjectType rbac.Objecter ,
571
+ DatabaseFunc func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
572
572
](
573
573
logger slog.Logger ,
574
574
authorizer rbac.Authorizer ,
@@ -581,10 +581,10 @@ func fetch[
581
581
// from SQL 'exec' functions which only return an error.
582
582
// See fetchAndQuery for more information.
583
583
func fetchAndExec [
584
- ObjectType rbac.Objecter ,
585
- ArgumentType any ,
586
- Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
587
- Exec func (ctx context.Context ,arg ArgumentType )error ,
584
+ ObjectType rbac.Objecter ,
585
+ ArgumentType any ,
586
+ Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
587
+ Exec func (ctx context.Context ,arg ArgumentType )error ,
588
588
](
589
589
logger slog.Logger ,
590
590
authorizer rbac.Authorizer ,
@@ -607,10 +607,10 @@ func fetchAndExec[
607
607
// **before** the query runs. The returns from the fetch are only used to
608
608
// assert rbac. The final return of this function comes from the Query function.
609
609
func fetchAndQuery [
610
- ObjectType rbac.Objecter ,
611
- ArgumentType any ,
612
- Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
613
- Query func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
610
+ ObjectType rbac.Objecter ,
611
+ ArgumentType any ,
612
+ Fetch func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
613
+ Query func (ctx context.Context ,arg ArgumentType ) (ObjectType ,error ),
614
614
](
615
615
logger slog.Logger ,
616
616
authorizer rbac.Authorizer ,
@@ -644,9 +644,9 @@ func fetchAndQuery[
644
644
// fetchWithPostFilter is like fetch, but works with lists of objects.
645
645
// SQL filters are much more optimal.
646
646
func fetchWithPostFilter [
647
- ArgumentType any ,
648
- ObjectType rbac.Objecter ,
649
- DatabaseFunc func (ctx context.Context ,arg ArgumentType ) ([]ObjectType ,error ),
647
+ ArgumentType any ,
648
+ ObjectType rbac.Objecter ,
649
+ DatabaseFunc func (ctx context.Context ,arg ArgumentType ) ([]ObjectType ,error ),
650
650
](
651
651
authorizer rbac.Authorizer ,
652
652
action policy.Action ,
@@ -1405,6 +1405,10 @@ func (q *querier) DeleteWebpushSubscriptions(ctx context.Context, ids []uuid.UUI
1405
1405
}
1406
1406
1407
1407
func (q * querier )DeleteWorkspaceAgentPortShare (ctx context.Context ,arg database.DeleteWorkspaceAgentPortShareParams )error {
1408
+ if err := q .authorizeContext (ctx ,policy .ActionDelete ,rbac .ResourceSystem );err != nil {
1409
+ return err
1410
+ }
1411
+
1408
1412
w ,err := q .db .GetWorkspaceByID (ctx ,arg .WorkspaceID )
1409
1413
if err != nil {
1410
1414
return err