Skip to content

Commit 5a63de2

Browse files
committed
s/session/interception
1 parent 4d90e48 commit 5a63de2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,18 @@ func (q *querier) authorizePrebuiltWorkspace(ctx context.Context, action policy.
177177

178178
// authorizeAIBridgeInterceptionUpdate validates that the context's actor matches the initiator of the AIBridgeInterception.
179179
// This is used by all of the sub-resources which fall under the [ResourceAibridgeInterception] umbrella.
180-
func (q *querier) authorizeAIBridgeInterceptionUpdate(ctx context.Context, sessID uuid.UUID) error {
180+
func (q *querier) authorizeAIBridgeInterceptionUpdate(ctx context.Context, interceptionID uuid.UUID) error {
181181
act, ok := ActorFromContext(ctx)
182182
if !ok {
183183
return ErrNoActor
184184
}
185185

186-
sess, err := q.db.GetAIBridgeInterceptionByID(ctx, sessID)
186+
inter, err := q.db.GetAIBridgeInterceptionByID(ctx, interceptionID)
187187
if err != nil {
188-
return xerrors.Errorf("fetch aibridge session %q: %w", sessID, err)
188+
return xerrors.Errorf("fetch aibridge interception %q: %w", interceptionID, err)
189189
}
190190

191-
err = q.auth.Authorize(ctx, act, policy.ActionUpdate, sess.RBACObject())
191+
err = q.auth.Authorize(ctx, act, policy.ActionUpdate, inter.RBACObject())
192192
if err != nil {
193193
return logNotAuthorizedError(ctx, q.log, err)
194194
}
@@ -3816,23 +3816,23 @@ func (q *querier) InsertAIBridgeInterception(ctx context.Context, arg database.I
38163816
}
38173817

38183818
func (q *querier) InsertAIBridgeTokenUsage(ctx context.Context, arg database.InsertAIBridgeTokenUsageParams) error {
3819-
// All aibridge_token_usages records belong to the initiator of their associated session.
3819+
// All aibridge_token_usages records belong to the initiator of their associated interception.
38203820
if err := q.authorizeAIBridgeInterceptionUpdate(ctx, arg.InterceptionID); err != nil {
38213821
return err
38223822
}
38233823
return q.db.InsertAIBridgeTokenUsage(ctx, arg)
38243824
}
38253825

38263826
func (q *querier) InsertAIBridgeToolUsage(ctx context.Context, arg database.InsertAIBridgeToolUsageParams) error {
3827-
// All aibridge_tool_usages records belong to the initiator of their associated session.
3827+
// All aibridge_tool_usages records belong to the initiator of their associated interception.
38283828
if err := q.authorizeAIBridgeInterceptionUpdate(ctx, arg.InterceptionID); err != nil {
38293829
return err
38303830
}
38313831
return q.db.InsertAIBridgeToolUsage(ctx, arg)
38323832
}
38333833

38343834
func (q *querier) InsertAIBridgeUserPrompt(ctx context.Context, arg database.InsertAIBridgeUserPromptParams) error {
3835-
// All aibridge_user_prompts records belong to the initiator of their associated session.
3835+
// All aibridge_user_prompts records belong to the initiator of their associated interception.
38363836
if err := q.authorizeAIBridgeInterceptionUpdate(ctx, arg.InterceptionID); err != nil {
38373837
return err
38383838
}

coderd/rbac/roles_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,8 @@ func TestRolePermissions(t *testing.T) {
893893
Actions: []policy.Action{policy.ActionCreate, policy.ActionRead, policy.ActionUpdate},
894894
Resource: rbac.ResourceAibridgeInterception,
895895
AuthorizeMap: map[bool][]hasAuthSubjects{
896-
true: {},
896+
true: {owner},
897897
false: {
898-
owner,
899898
memberMe, orgMemberMe, otherOrgMember,
900899
orgAdmin, otherOrgAdmin,
901900
orgAuditor, otherOrgAuditor,

0 commit comments

Comments
 (0)