Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e6b43f

Browse files
committed
Merge branch 'cj/dbauthz' into authzquerier_layer
2 parentsd4e1124 +ad6ad36 commit4e6b43f

File tree

47 files changed

+94
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+94
-98
lines changed

‎coderd/autobuild/executor/lifecycle_executor.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"golang.org/x/xerrors"
1111

1212
"cdr.dev/slog"
13-
"github.com/coder/coder/coderd/authzquery"
1413
"github.com/coder/coder/coderd/autobuild/schedule"
1514
"github.com/coder/coder/coderd/database"
15+
"github.com/coder/coder/coderd/database/dbauthz"
1616
"github.com/coder/coder/coderd/rbac"
1717
)
1818

@@ -36,7 +36,7 @@ type Stats struct {
3636
funcNew(ctx context.Context,db database.Store,log slog.Logger,tick<-chan time.Time)*Executor {
3737
le:=&Executor{
3838
// Use an authorized context with an autostart system actor.
39-
ctx:authzquery.WithAuthorizeSystemContext(ctx,rbac.RolesAutostartSystem()),
39+
ctx:dbauthz.WithAuthorizeSystemContext(ctx,rbac.RolesAutostartSystem()),
4040
db:db,
4141
tick:tick,
4242
log:log,

‎coderd/coderd.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ import (
3636

3737
"cdr.dev/slog"
3838
"github.com/coder/coder/buildinfo"
39-
"github.com/coder/coder/coderd/authzquery"
4039

4140
// Used to serve the Swagger endpoint
4241
_"github.com/coder/coder/coderd/apidoc"
4342
"github.com/coder/coder/coderd/audit"
4443
"github.com/coder/coder/coderd/awsidentity"
4544
"github.com/coder/coder/coderd/database"
45+
"github.com/coder/coder/coderd/database/dbauthz"
4646
"github.com/coder/coder/coderd/database/dbtype"
4747
"github.com/coder/coder/coderd/gitauth"
4848
"github.com/coder/coder/coderd/gitsshkey"
@@ -159,8 +159,8 @@ func New(options *Options) *API {
159159
experiments:=initExperiments(options.Logger,options.DeploymentConfig.Experiments.Value,options.DeploymentConfig.Experimental.Value)
160160
// TODO: remove this once we promote authz_querier out of experiments.
161161
ifexperiments.Enabled(codersdk.ExperimentAuthzQuerier) {
162-
if_,ok:= (options.Database).(*authzquery.AuthzQuerier);!ok {
163-
options.Database=authzquery.New(
162+
if_,ok:= (options.Database).(*dbauthz.AuthzQuerier);!ok {
163+
options.Database=dbauthz.New(
164164
options.Database,
165165
options.Authorizer,
166166
options.Logger.Named("authz_query"),
@@ -209,8 +209,8 @@ func New(options *Options) *API {
209209
}
210210
// TODO: remove this once we promote authz_querier out of experiments.
211211
ifexperiments.Enabled(codersdk.ExperimentAuthzQuerier) {
212-
if_,ok:= (options.Database).(*authzquery.AuthzQuerier);!ok {
213-
options.Database=authzquery.New(options.Database,options.Authorizer,options.Logger.Named("authz_querier"))
212+
if_,ok:= (options.Database).(*dbauthz.AuthzQuerier);!ok {
213+
options.Database=dbauthz.New(options.Database,options.Authorizer,options.Logger.Named("authz_querier"))
214214
}
215215
}
216216
ifoptions.SetUserGroups==nil {

‎coderd/coderdtest/coderdtest.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ import (
5656
"github.com/coder/coder/cli/deployment"
5757
"github.com/coder/coder/coderd"
5858
"github.com/coder/coder/coderd/audit"
59-
"github.com/coder/coder/coderd/authzquery"
6059
"github.com/coder/coder/coderd/autobuild/executor"
6160
"github.com/coder/coder/coderd/awsidentity"
6261
"github.com/coder/coder/coderd/database"
62+
"github.com/coder/coder/coderd/database/dbauthz"
6363
"github.com/coder/coder/coderd/database/dbtestutil"
6464
"github.com/coder/coder/coderd/gitauth"
6565
"github.com/coder/coder/coderd/gitsshkey"
@@ -187,7 +187,7 @@ func NewOptions(t *testing.T, options *Options) (func(http.Handler), context.Can
187187
Wrapped:rbac.NewAuthorizer(prometheus.NewRegistry()),
188188
}
189189
}
190-
options.Database=authzquery.New(options.Database,options.Authorizer,slogtest.Make(t,nil).Leveled(slog.LevelDebug))
190+
options.Database=dbauthz.New(options.Database,options.Authorizer,slogtest.Make(t,nil).Leveled(slog.LevelDebug))
191191
}
192192
ifoptions.DeploymentConfig==nil {
193193
options.DeploymentConfig=DeploymentConfig(t)

‎coderd/authzquery/apikey.go‎renamed to ‎coderd/database/dbauthz/apikey.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packageauthzquery
1+
packagedbauthz
22

33
import (
44
"context"

‎coderd/authzquery/apikey_test.go‎renamed to ‎coderd/database/dbauthz/apikey_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packageauthzquery_test
1+
packagedbauthz_test
22

33
import (
44
"time"

‎coderd/authzquery/audit.go‎renamed to ‎coderd/database/dbauthz/audit.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packageauthzquery
1+
packagedbauthz
22

33
import (
44
"context"

‎coderd/authzquery/audit_test.go‎renamed to ‎coderd/database/dbauthz/audit_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packageauthzquery_test
1+
packagedbauthz_test
22

33
import (
44
"github.com/coder/coder/coderd/database"

‎coderd/authzquery/authz.go‎renamed to ‎coderd/database/dbauthz/authz.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packageauthzquery
1+
packagedbauthz
22

33
import (
44
"context"

‎coderd/authzquery/authz_test.go‎renamed to ‎coderd/database/dbauthz/authz_test.go‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packageauthzquery_test
1+
packagedbauthz_test
22

33
import (
44
"context"
@@ -12,9 +12,9 @@ import (
1212

1313
"cdr.dev/slog"
1414
"cdr.dev/slog/sloggers/slogtest"
15-
"github.com/coder/coder/coderd/authzquery"
1615
"github.com/coder/coder/coderd/coderdtest"
1716
"github.com/coder/coder/coderd/database"
17+
"github.com/coder/coder/coderd/database/dbauthz"
1818
"github.com/coder/coder/coderd/database/dbfake"
1919
"github.com/coder/coder/coderd/database/dbgen"
2020
"github.com/coder/coder/coderd/rbac"
@@ -28,31 +28,31 @@ func TestNotAuthorizedError(t *testing.T) {
2828

2929
testErr:=xerrors.New("custom error")
3030

31-
err:=authzquery.LogNotAuthorizedError(context.Background(),slogtest.Make(t,nil),testErr)
31+
err:=dbauthz.LogNotAuthorizedError(context.Background(),slogtest.Make(t,nil),testErr)
3232
require.ErrorIs(t,err,sql.ErrNoRows,"must be a sql.ErrNoRows")
3333

34-
varauthErrauthzquery.NotAuthorizedError
34+
varauthErrdbauthz.NotAuthorizedError
3535
require.ErrorAs(t,err,&authErr,"must be a NotAuthorizedError")
3636
require.ErrorIs(t,authErr.Err,testErr,"internal error must match")
3737
})
3838

3939
t.Run("MissingActor",func(t*testing.T) {
4040
t.Parallel()
41-
q:=authzquery.New(dbfake.New(),&coderdtest.RecordingAuthorizer{
41+
q:=dbauthz.New(dbfake.New(),&coderdtest.RecordingAuthorizer{
4242
Wrapped:&coderdtest.FakeAuthorizer{AlwaysReturn:nil},
4343
},slog.Make())
4444
// This should fail because the actor is missing.
4545
_,err:=q.GetWorkspaceByID(context.Background(),uuid.New())
46-
require.ErrorIs(t,err,authzquery.NoActorError,"must be a NoActorError")
46+
require.ErrorIs(t,err,dbauthz.NoActorError,"must be a NoActorError")
4747
})
4848
}
4949

50-
//TestAuthzQueryRecursive is a simple test to search for infinite recursion
50+
//TestdbauthzRecursive is a simple test to search for infinite recursion
5151
// bugs. It isn't perfect, and only catches a subset of the possible bugs
5252
// as only the first db call will be made. But it is better than nothing.
53-
funcTestAuthzQueryRecursive(t*testing.T) {
53+
funcTestdbauthzRecursive(t*testing.T) {
5454
t.Parallel()
55-
q:=authzquery.New(dbfake.New(),&coderdtest.RecordingAuthorizer{
55+
q:=dbauthz.New(dbfake.New(),&coderdtest.RecordingAuthorizer{
5656
Wrapped:&coderdtest.FakeAuthorizer{AlwaysReturn:nil},
5757
},slog.Make())
5858
actor:= rbac.Subject{
@@ -63,7 +63,7 @@ func TestAuthzQueryRecursive(t *testing.T) {
6363
}
6464
fori:=0;i<reflect.TypeOf(q).NumMethod();i++ {
6565
varins []reflect.Value
66-
ctx:=authzquery.WithAuthorizeContext(context.Background(),actor)
66+
ctx:=dbauthz.WithAuthorizeContext(context.Background(),actor)
6767

6868
ins=append(ins,reflect.ValueOf(ctx))
6969
method:=reflect.TypeOf(q).Method(i)
@@ -84,7 +84,7 @@ func TestAuthzQueryRecursive(t *testing.T) {
8484
funcTestPing(t*testing.T) {
8585
t.Parallel()
8686

87-
q:=authzquery.New(dbfake.New(),&coderdtest.RecordingAuthorizer{},slog.Make())
87+
q:=dbauthz.New(dbfake.New(),&coderdtest.RecordingAuthorizer{},slog.Make())
8888
_,err:=q.Ping(context.Background())
8989
require.NoError(t,err,"must not error")
9090
}
@@ -94,7 +94,7 @@ func TestInTX(t *testing.T) {
9494
t.Parallel()
9595

9696
db:=dbfake.New()
97-
q:=authzquery.New(db,&coderdtest.RecordingAuthorizer{
97+
q:=dbauthz.New(db,&coderdtest.RecordingAuthorizer{
9898
Wrapped:&coderdtest.FakeAuthorizer{AlwaysReturn:xerrors.New("custom error")},
9999
},slog.Make())
100100
actor:= rbac.Subject{
@@ -105,14 +105,14 @@ func TestInTX(t *testing.T) {
105105
}
106106

107107
w:=dbgen.Workspace(t,db, database.Workspace{})
108-
ctx:=authzquery.WithAuthorizeContext(context.Background(),actor)
108+
ctx:=dbauthz.WithAuthorizeContext(context.Background(),actor)
109109
err:=q.InTx(func(tx database.Store)error {
110110
// The inner tx should use the parent's authz
111111
_,err:=tx.GetWorkspaceByID(ctx,w.ID)
112112
returnerr
113113
},nil)
114114
require.Error(t,err,"must error")
115-
require.ErrorAs(t,err,&authzquery.NotAuthorizedError{},"must be an authorized error")
115+
require.ErrorAs(t,err,&dbauthz.NotAuthorizedError{},"must be an authorized error")
116116
}
117117

118118
funcmust[Tany](valueT,errerror)T {

‎coderd/authzquery/authzquerier.go‎renamed to ‎coderd/database/dbauthz/authzquerier.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packageauthzquery
1+
packagedbauthz
22

33
import (
44
"context"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp