MCPcopy Index your code
hub / github.com/coder/coder / authorizeContext

Method authorizeContext

coderd/database/dbauthz/dbauthz.go:138–149  ·  view source on GitHub ↗

authorizeContext is a helper function to authorize an action on an object.

(ctx context.Context, action policy.Action, object rbac.Objecter)

Source from the content-addressed store, hash-verified

136
137// authorizeContext is a helper function to authorize an action on an object.
138func (q *querier) authorizeContext(ctx context.Context, action policy.Action, object rbac.Objecter) error {
139 act, ok := ActorFromContext(ctx)
140 if !ok {
141 return ErrNoActor
142 }
143
144 err := q.auth.Authorize(ctx, act, action, object.RBACObject())
145 if err != nil {
146 return logNotAuthorizedError(ctx, q.log, err)
147 }
148 return nil
149}
150
151// authorizePrebuiltWorkspace handles authorization for workspace resource types.
152// prebuilt_workspaces are a subset of workspaces, currently limited to

Callers 15

canAssignRolesMethod · 0.95
customRoleCheckMethod · 0.95
AcquireChatsMethod · 0.95
AcquireProvisionerJobMethod · 0.95
AllUserIDsMethod · 0.95
ArchiveChatByIDMethod · 0.95

Calls 4

logNotAuthorizedErrorFunction · 0.85
ActorFromContextFunction · 0.70
AuthorizeMethod · 0.65
RBACObjectMethod · 0.65

Tested by

no test coverage detected