@@ -42,6 +42,7 @@ import (
42
42
"github.com/coder/coder/coderd/audit"
43
43
"github.com/coder/coder/coderd/awsidentity"
44
44
"github.com/coder/coder/coderd/database"
45
+ "github.com/coder/coder/coderd/database/dbauthz"
45
46
"github.com/coder/coder/coderd/database/dbtype"
46
47
"github.com/coder/coder/coderd/gitauth"
47
48
"github.com/coder/coder/coderd/gitsshkey"
@@ -157,13 +158,6 @@ func New(options *Options) *API {
157
158
options = & Options {}
158
159
}
159
160
experiments := initExperiments (options .Logger , options .DeploymentConfig .Experiments .Value , options .DeploymentConfig .Experimental .Value )
160
- // TODO: remove this once we promote authz_querier out of experiments.
161
- if experiments .Enabled (codersdk .ExperimentAuthzQuerier ) {
162
- panic ("Coming soon!" )
163
- // if _, ok := (options.Database).(*authzquery.AuthzQuerier); !ok {
164
- // options.Database = authzquery.NewAuthzQuerier(options.Database, options.Authorizer)
165
- // }
166
- }
167
161
if options .AppHostname != "" && options .AppHostnameRegex == nil || options .AppHostname == "" && options .AppHostnameRegex != nil {
168
162
panic ("coderd: both AppHostname and AppHostnameRegex must be set or unset" )
169
163
}
@@ -204,6 +198,14 @@ func New(options *Options) *API {
204
198
if options .Auditor == nil {
205
199
options .Auditor = audit .NewNop ()
206
200
}
201
+ // TODO: remove this once we promote authz_querier out of experiments.
202
+ if experiments .Enabled (codersdk .ExperimentAuthzQuerier ) {
203
+ options .Database = dbauthz .New (
204
+ options .Database ,
205
+ options .Authorizer ,
206
+ options .Logger .Named ("authz_querier" ),
207
+ )
208
+ }
207
209
if options .SetUserGroups == nil {
208
210
options .SetUserGroups = func (context.Context , database.Store , uuid.UUID , []string ) error { return nil }
209
211
}
@@ -304,8 +306,10 @@ func New(options *Options) *API {
304
306
DisableSessionExpiryRefresh : options .DeploymentConfig .DisableSessionExpiryRefresh .Value ,
305
307
Optional : true ,
306
308
}),
307
- httpmw .ExtractUserParam (api .Database , false ),
308
- httpmw .ExtractWorkspaceAndAgentParam (api .Database ),
309
+ httpmw .AsAuthzSystem (
310
+ httpmw .ExtractUserParam (api .Database , false ),
311
+ httpmw .ExtractWorkspaceAndAgentParam (api .Database ),
312
+ ),
309
313
),
310
314
// Build-Version is helpful for debugging.
311
315
func (next http.Handler ) http.Handler {
@@ -332,11 +336,13 @@ func New(options *Options) *API {
332
336
DisableSessionExpiryRefresh : options .DeploymentConfig .DisableSessionExpiryRefresh .Value ,
333
337
Optional : true ,
334
338
}),
335
- // Redirect to the login page if the user tries to open an app with
336
- // "me" as the username and they are not logged in.
337
- httpmw .ExtractUserParam (api .Database , true ),
338
- // Extracts the <workspace.agent> from the url
339
- httpmw .ExtractWorkspaceAndAgentParam (api .Database ),
339
+ httpmw .AsAuthzSystem (
340
+ // Redirect to the login page if the user tries to open an app with
341
+ // "me" as the username and they are not logged in.
342
+ httpmw .ExtractUserParam (api .Database , true ),
343
+ // Extracts the <workspace.agent> from the url
344
+ httpmw .ExtractWorkspaceAndAgentParam (api .Database ),
345
+ ),
340
346
)
341
347
r .HandleFunc ("/*" , api .workspaceAppsProxyPath )
342
348
}
0 commit comments