Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/controlplane/pkg/authz/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ const (
RoleProductViewer Role = "role:product:viewer"
RoleProductAdmin Role = "role:product:admin"

// BillingAccount roles
RoleBillingAccountOwner Role = "role:billing_account:owner"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed here? in this codebase? cc/ @jiparis

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as RoleProductAdmin/RoleProductViewer - defined here because the membership schema lives here

RoleBillingAccountAdmin Role = "role:billing_account:admin"

// Scope for instance admin tokens
ScopeInstanceAdmin = "INSTANCE_ADMIN"
)
Expand Down Expand Up @@ -356,6 +360,10 @@ var RolesMap = map[Role][]*Policy{
PolicyGroupRemoveMemberships,
PolicyGroupUpdateMemberships,
},

// BillingAccount roles
RoleBillingAccountOwner: {},
RoleBillingAccountAdmin: {},
}

// ServerOperationsMap is a map of server operations to their authorization requirements.
Expand Down Expand Up @@ -484,6 +492,8 @@ func (Role) Values() (roles []string) {
RoleGroupMaintainer,
RoleProductAdmin,
RoleProductViewer,
RoleBillingAccountOwner,
RoleBillingAccountAdmin,
} {
roles = append(roles, string(s))
}
Expand Down
12 changes: 7 additions & 5 deletions app/controlplane/pkg/authz/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ const (
MembershipTypeUser MembershipType = "user"
MembershipTypeGroup MembershipType = "group"

ResourceTypeInstance ResourceType = "instance"
ResourceTypeOrganization ResourceType = "organization"
ResourceTypeProject ResourceType = "project"
ResourceTypeProduct ResourceType = "product"
ResourceTypeGroup ResourceType = "group"
ResourceTypeInstance ResourceType = "instance"
ResourceTypeOrganization ResourceType = "organization"
ResourceTypeProject ResourceType = "project"
ResourceTypeProduct ResourceType = "product"
ResourceTypeGroup ResourceType = "group"
ResourceTypeBillingAccount ResourceType = "billing_account"
)

// Values implement https://pkg.go.dev/entgo.io/ent/schema/field#EnumValues
Expand All @@ -50,6 +51,7 @@ func (ResourceType) Values() (values []string) {
string(ResourceTypeProject),
string(ResourceTypeGroup),
string(ResourceTypeProduct),
string(ResourceTypeBillingAccount),
)

return
Expand Down
4 changes: 2 additions & 2 deletions app/controlplane/pkg/data/ent/membership/membership.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/controlplane/pkg/data/ent/migrate/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ var (
{Name: "current", Type: field.TypeBool, Default: false},
{Name: "created_at", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"},
{Name: "updated_at", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"},
{Name: "role", Type: field.TypeEnum, Enums: []string{"role:instance:admin", "role:org:owner", "role:org:admin", "role:org:viewer", "role:org:member", "role:org:contributor", "role:project:admin", "role:project:viewer", "role:group:maintainer", "role:product:admin", "role:product:viewer"}},
{Name: "role", Type: field.TypeEnum, Enums: []string{"role:instance:admin", "role:org:owner", "role:org:admin", "role:org:viewer", "role:org:member", "role:org:contributor", "role:project:admin", "role:project:viewer", "role:group:maintainer", "role:product:admin", "role:product:viewer", "role:billing_account:owner", "role:billing_account:admin"}},
{Name: "membership_type", Type: field.TypeEnum, Nullable: true, Enums: []string{"user", "group"}},
{Name: "member_id", Type: field.TypeUUID, Nullable: true},
{Name: "resource_type", Type: field.TypeEnum, Nullable: true, Enums: []string{"instance", "organization", "project", "group", "product"}},
{Name: "resource_type", Type: field.TypeEnum, Nullable: true, Enums: []string{"instance", "organization", "project", "group", "product", "billing_account"}},
{Name: "resource_id", Type: field.TypeUUID, Nullable: true},
{Name: "parent_id", Type: field.TypeUUID, Nullable: true},
{Name: "organization_memberships", Type: field.TypeUUID, Nullable: true},
Expand Down Expand Up @@ -396,7 +396,7 @@ var (
{Name: "status", Type: field.TypeEnum, Enums: []string{"accepted", "pending"}, Default: "pending"},
{Name: "created_at", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"},
{Name: "deleted_at", Type: field.TypeTime, Nullable: true},
{Name: "role", Type: field.TypeEnum, Nullable: true, Enums: []string{"role:instance:admin", "role:org:owner", "role:org:admin", "role:org:viewer", "role:org:member", "role:org:contributor", "role:project:admin", "role:project:viewer", "role:group:maintainer", "role:product:admin", "role:product:viewer"}},
{Name: "role", Type: field.TypeEnum, Nullable: true, Enums: []string{"role:instance:admin", "role:org:owner", "role:org:admin", "role:org:viewer", "role:org:member", "role:org:contributor", "role:project:admin", "role:project:viewer", "role:group:maintainer", "role:product:admin", "role:product:viewer", "role:billing_account:owner", "role:billing_account:admin"}},
{Name: "context", Type: field.TypeJSON, Nullable: true},
{Name: "organization_id", Type: field.TypeUUID},
{Name: "sender_id", Type: field.TypeUUID, Nullable: true},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading