Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8735f51

Browse files
authored
feat(coder): add authz_querier experiment (coder#5858)
* feat(coderd): add authz_querier experiment * coderdtest: wire up authz_querier * wire up AuthzQuerier in coderd * remove things that do not yet exist in this timeline * add newline * comment unreachable code
1 parent 1cd5f38 commit 8735f51

File tree

8 files changed

+66
-11
lines changed

8 files changed

+66
-11
lines changed

coderd/apidoc/docs.go

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ func New(options *Options) *API {
154154
if options == nil {
155155
options = &Options{}
156156
}
157+
experiments := initExperiments(options.Logger, options.DeploymentConfig.Experiments.Value, options.DeploymentConfig.Experimental.Value)
158+
// TODO: remove this once we promote authz_querier out of experiments.
159+
if experiments.Enabled(codersdk.ExperimentAuthzQuerier) {
160+
panic("Coming soon!")
161+
// if _, ok := (options.Database).(*authzquery.AuthzQuerier); !ok {
162+
// options.Database = authzquery.NewAuthzQuerier(options.Database, options.Authorizer)
163+
// }
164+
}
157165
if options.AppHostname != "" && options.AppHostnameRegex == nil || options.AppHostname == "" && options.AppHostnameRegex != nil {
158166
panic("coderd: both AppHostname and AppHostnameRegex must be set or unset")
159167
}
@@ -222,7 +230,7 @@ func New(options *Options) *API {
222230
},
223231
metricsCache: metricsCache,
224232
Auditor: atomic.Pointer[audit.Auditor]{},
225-
Experiments: initExperiments(options.Logger, options.DeploymentConfig.Experiments.Value, options.DeploymentConfig.Experimental.Value),
233+
Experiments: experiments,
226234
}
227235
if options.UpdateCheckOptions != nil {
228236
api.updateChecker = updatecheck.New(

coderd/coderdtest/coderdtest.go

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"net/http"
2222
"net/http/httptest"
2323
"net/url"
24+
"os"
2425
"regexp"
2526
"strconv"
2627
"strings"
@@ -176,6 +177,14 @@ func NewOptions(t *testing.T, options *Options) (func(http.Handler), context.Can
176177
if options.Database == nil {
177178
options.Database, options.Pubsub = dbtestutil.NewDB(t)
178179
}
180+
// TODO: remove this once we're ready to enable authz querier by default.
181+
if strings.Contains(os.Getenv("CODER_EXPERIMENTS_TEST"), "authz_querier") {
182+
panic("Coming soon!")
183+
// if options.Authorizer != nil {
184+
// options.Authorizer = &RecordingAuthorizer{}
185+
// }
186+
// options.Database = authzquery.NewAuthzQuerier(options.Database, options.Authorizer)
187+
}
179188
if options.DeploymentConfig == nil {
180189
options.DeploymentConfig = DeploymentConfig(t)
181190
}

codersdk/experiments.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ import (
99
type Experiment string
1010

1111
const (
12-
// Add new experiments here!
13-
// ExperimentExample Experiment = "example"
12+
// ExperimentAuthzQuerier is an internal experiment that enables the ExperimentAuthzQuerier
13+
// interface for all RBAC operations. NOT READY FOR PRODUCTION USE.
14+
ExperimentAuthzQuerier Experiment = "authz_querier"
15+
16+
// Add new experiments here!
17+
// ExperimentExample Experiment = "example"
1418
)
1519

1620
var (

docs/api/general.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -1072,17 +1072,23 @@ curl -X GET http://coder-server:8080/api/v2/experiments \
10721072
> 200 Response
10731073
10741074
```json
1075-
["string"]
1075+
["authz_querier"]
10761076
```
10771077

10781078
### Responses
10791079

1080-
| Status | Meaning | Description | Schema |
1081-
| ------ | ------------------------------------------------------- | ----------- | --------------- |
1082-
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of string |
1080+
| Status | Meaning | Description | Schema |
1081+
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------- |
1082+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.Experiment](schemas.md#codersdkexperiment) |
10831083

10841084
<h3 id="get-experiments-responseschema">Response Schema</h3>
10851085

1086+
Status Code **200**
1087+
1088+
| Name | Type | Required | Restrictions | Description |
1089+
| -------------- | ----- | -------- | ------------ | ----------- |
1090+
| `[array item]` | array | false | | |
1091+
10861092
To perform this operation, you must be authenticated. [Learn more](authentication.md).
10871093

10881094
## Update check

docs/api/schemas.md

+14
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,20 @@ CreateParameterRequest is a structure used to create a new parameter value for a
24392439
| `trial` | boolean | false | | |
24402440
| `warnings` | array of string | false | | |
24412441

2442+
## codersdk.Experiment
2443+
2444+
```json
2445+
"authz_querier"
2446+
```
2447+
2448+
### Properties
2449+
2450+
#### Enumerated Values
2451+
2452+
| Value |
2453+
| --------------- |
2454+
| `authz_querier` |
2455+
24422456
## codersdk.Feature
24432457

24442458
```json

site/src/api/typesGenerated.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,8 @@ export const Entitlements: Entitlement[] = [
10971097
]
10981098

10991099
// From codersdk/experiments.go
1100-
export type Experiment = never
1101-
export const Experiments: Experiment[] = []
1100+
export type Experiment = "authz_querier"
1101+
export const Experiments: Experiment[] = ["authz_querier"]
11021102

11031103
// From codersdk/features.go
11041104
export type FeatureName =

0 commit comments

Comments
 (0)