Skip to content

Commit b1c7df4

Browse files
committed
Rename package to rbac
1 parent 0e7f9fa commit b1c7df4

File tree

11 files changed

+644
-645
lines changed

11 files changed

+644
-645
lines changed

coderd/authz/authz_test.go

Lines changed: 0 additions & 629 deletions
This file was deleted.
File renamed without changes.

coderd/authz/action.go renamed to coderd/rbac/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package authz
1+
package rbac
22

33
// Action represents the allowed actions to be done on an object.
44
type Action string

coderd/authz/authz.go renamed to coderd/rbac/authz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package authz
1+
package rbac
22

33
import (
44
"context"

coderd/rbac/authz_test.go

Lines changed: 628 additions & 0 deletions
Large diffs are not rendered by default.

coderd/authz/error.go renamed to coderd/rbac/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package authz
1+
package rbac
22

33
const (
44
// UnauthorizedErrorMessage is the error message that should be returned to
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package authz_test
1+
package rbac_test
22

33
import (
44
"context"
55
"testing"
66

7-
"github.com/coder/coder/coderd/authz"
7+
"github.com/coder/coder/coderd/rbac"
88
"github.com/stretchr/testify/require"
99
)
1010

@@ -14,16 +14,16 @@ func TestExample(t *testing.T) {
1414
t.Skip("TODO: unskip when rego is done")
1515
t.Parallel()
1616
ctx := context.Background()
17-
authorizer, err := authz.NewAuthorizer()
17+
authorizer, err := rbac.NewAuthorizer()
1818
require.NoError(t, err)
1919

2020
// user will become an authn object, and can even be a database.User if it
2121
// fulfills the interface. Until then, use a placeholder.
2222
user := subject{
2323
UserID: "alice",
24-
Roles: []authz.Role{
25-
authz.RoleOrgAdmin("default"),
26-
authz.RoleMember,
24+
Roles: []rbac.Role{
25+
rbac.RoleOrgAdmin("default"),
26+
rbac.RoleMember,
2727
},
2828
}
2929

@@ -32,25 +32,25 @@ func TestExample(t *testing.T) {
3232
//nolint:paralleltest
3333
t.Run("ReadAllWorkspaces", func(t *testing.T) {
3434
// To read all workspaces on the site
35-
err := authorizer.Authorize(ctx, user.UserID, user.Roles, authz.ResourceWorkspace.All(), authz.ActionRead)
35+
err := authorizer.Authorize(ctx, user.UserID, user.Roles, rbac.ResourceWorkspace.All(), rbac.ActionRead)
3636
var _ = err
3737
// require.Error(t, err, "this user cannot read all workspaces")
3838
})
3939

4040
//nolint:paralleltest
4141
t.Run("ReadOrgWorkspaces", func(t *testing.T) {
4242
// To read all workspaces on the org 'default'
43-
err := authorizer.Authorize(ctx, user.UserID, user.Roles, authz.ResourceWorkspace.InOrg("default"), authz.ActionRead)
43+
err := authorizer.Authorize(ctx, user.UserID, user.Roles, rbac.ResourceWorkspace.InOrg("default"), rbac.ActionRead)
4444
require.NoError(t, err, "this user can read all org workspaces in 'default'")
4545
})
4646

4747
//nolint:paralleltest
4848
t.Run("ReadMyWorkspace", func(t *testing.T) {
4949
// Note 'database.Workspace' could fulfill the object interface and be passed in directly
50-
err := authorizer.Authorize(ctx, user.UserID, user.Roles, authz.ResourceWorkspace.InOrg("default").WithOwner(user.UserID), authz.ActionRead)
50+
err := authorizer.Authorize(ctx, user.UserID, user.Roles, rbac.ResourceWorkspace.InOrg("default").WithOwner(user.UserID), rbac.ActionRead)
5151
require.NoError(t, err, "this user can their workspace")
5252

53-
err = authorizer.Authorize(ctx, user.UserID, user.Roles, authz.ResourceWorkspace.InOrg("default").WithOwner(user.UserID).WithID("1234"), authz.ActionRead)
53+
err = authorizer.Authorize(ctx, user.UserID, user.Roles, rbac.ResourceWorkspace.InOrg("default").WithOwner(user.UserID).WithID("1234"), rbac.ActionRead)
5454
require.NoError(t, err, "this user can read workspace '1234'")
5555
})
5656
}

coderd/authz/object.go renamed to coderd/rbac/object.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package authz
1+
package rbac
22

33
// Object is used to create objects for authz checks when you have none in
44
// hand to run the check on.
File renamed without changes.

coderd/authz/resources.go renamed to coderd/rbac/resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package authz
1+
package rbac
22

33
const WildcardSymbol = "*"
44

0 commit comments

Comments
 (0)