@@ -51,8 +51,27 @@ type HTTPAuthorizer struct {
51
51
// return
52
52
// }
53
53
func (api * API ) Authorize (r * http.Request , action rbac.Action , object rbac.Objecter ) bool {
54
+ // The experiment does not replace ALL rbac checks, but does replace most.
55
+ // This statement aborts early on the checks that will be removed in the
56
+ // future when this experiment is default.
54
57
if api .Experiments .Enabled (codersdk .ExperimentAuthzQuerier ) {
55
- return true
58
+ // Some resource types do not interact with the persistent layer and
59
+ // we need to keep these checks happening in the API layer.
60
+ switch object .RBACObject ().Type {
61
+ case rbac .ResourceWorkspaceExecution .Type :
62
+ // This is not a db resource, always in API layer
63
+ case rbac .ResourceDeploymentConfig .Type :
64
+ // For metric cache items like DAU, we do not hit the DB.
65
+ // Some db actions are in asserted in the authz layer.
66
+ case rbac .ResourceReplicas .Type :
67
+ // Replica rbac is checked for adding and removing replicas.
68
+ case rbac .ResourceProvisionerDaemon .Type :
69
+ // Provisioner rbac is checked for adding and removing provisioners.
70
+ case rbac .ResourceDebugInfo .Type :
71
+ // This is not a db resource, always in API layer.
72
+ default :
73
+ return true
74
+ }
56
75
}
57
76
return api .HTTPAuth .Authorize (r , action , object )
58
77
}
0 commit comments