Files
zitadel/backend/v3/domain/permission.go
T
Marco A.andGitHub 39a29f534a feat(domain): Instance APIs with relational tables (#10953)
# Which Problems Are Solved

This PR implements the endpoints listed in
https://github.com/zitadel/zitadel/issues/10443 .

# How the Problems Are Solved

The implementation follows the same pattern as the Organization one.
There are no peculiarities to this PR. The `Update`, `Delete` are
implementing the `Commander` interface, while `Get` and `List`
instance(s) endpoints are implementing the `Querier` interace.

# Additional Context

- Closes #10443
- Depends on #10445
2025-10-28 14:17:19 +00:00

58 lines
2.1 KiB
Go

package domain
import "context"
const (
InstanceReadPermission = "instance.read"
InstanceWritePermission = "instance.write"
OrganizationReadPermission = "organization.read"
OrganizationWritePermission = "organization.write"
)
// PermissionRepository is the interface that manages and checks Zitadel permissions.
//
// TODO(muhlemmer): This just defines the checker methods, rest to be done later.
type PermissionRepository interface {
PermissionChecker
}
// PermissionChecker defines the methods needed to check permissions.
//
//go:generate mockgen -typed -package domainmock -destination ./mock/permission.mock.go . PermissionChecker
type PermissionChecker interface {
// Check if the authenticated user has the given permission on instance level.
CheckInstancePermission(ctx context.Context, permission string) error
// Check if the authenticated user has the given permission on the given organization.
// A permission may be inherited from the instance level.
CheckOrganizationPermission(ctx context.Context, permission, orgID string) error
// Check if the authenticated user has the given permission on the given project.
// A permission may be inherited from the instance or organization level.
CheckProjectPermission(ctx context.Context, permission, projectID string) error
// Check if the authenticated user has the given permission on the given project grant.
// A permission may be inherited from the instance or granted organization level.
CheckProjectGrantPermission(ctx context.Context, permission, projectGrantID string) error
}
type noopPermissionChecker struct{}
var _ PermissionChecker = (*noopPermissionChecker)(nil)
func (*noopPermissionChecker) CheckInstancePermission(context.Context, string) error {
return nil
}
func (*noopPermissionChecker) CheckOrganizationPermission(context.Context, string, string) error {
return nil
}
func (*noopPermissionChecker) CheckProjectPermission(context.Context, string, string) error {
return nil
}
func (*noopPermissionChecker) CheckProjectGrantPermission(context.Context, string, string) error {
return nil
}