Documentation
¶
Index ¶
- Variables
- func ConvertDBPermissions(dbPerms []database.CustomRolePermission) []rbac.Permission
- func ConvertDBRole(dbRole database.CustomRole) (rbac.Role, error)
- func ConvertPermissionsToDB(perms []rbac.Permission) []database.CustomRolePermission
- func CreateSystemRole(ctx context.Context, tx database.Store, org database.Organization, ...) error
- func CustomRoleCacheContext(ctx context.Context) context.Context
- func CustomRoleMW(next http.Handler) http.Handler
- func Expand(ctx context.Context, db database.Store, names []rbac.RoleIdentifier) (rbac.Roles, error)
- func IsSystemRoleName(name string) bool
- func ReconcileSystemRole(ctx context.Context, tx database.Store, in database.CustomRole, ...) (database.CustomRole, bool, error)
- func ReconcileSystemRoles(ctx context.Context, log slog.Logger, db database.Store) error
Constants ¶
This section is empty.
Variables ¶
var SystemRoleNames = maps.Keys(systemRoles)
Functions ¶
func ConvertDBPermissions ¶ added in v2.30.0
func ConvertDBPermissions(dbPerms []database.CustomRolePermission) []rbac.Permission
ConvertDBPermissions converts database permissions to RBAC permissions.
func ConvertDBRole ¶
func ConvertDBRole(dbRole database.CustomRole) (rbac.Role, error)
ConvertDBRole should not be used by any human facing apis. It is used for authz purposes.
func ConvertPermissionsToDB ¶ added in v2.30.0
func ConvertPermissionsToDB(perms []rbac.Permission) []database.CustomRolePermission
ConvertPermissionsToDB converts RBAC permissions to the database format.
func CreateSystemRole ¶ added in v2.32.0
func CreateSystemRole( ctx context.Context, tx database.Store, org database.Organization, roleName string, ) error
CreateSystemRole inserts a new system role into the database with permissions produced by permsFunc based on the organization's current settings.
func CustomRoleCacheContext ¶
CustomRoleCacheContext prevents needing to lookup custom roles within the same request lifecycle. Optimizing this to span requests should be done in the future.
func CustomRoleMW ¶
CustomRoleMW adds a custom role cache on the ctx to prevent duplicate db fetches.
func Expand ¶
func Expand(ctx context.Context, db database.Store, names []rbac.RoleIdentifier) (rbac.Roles, error)
Expand will expand built in roles, and fetch custom roles from the database. If a custom role is defined, but does not exist, the role will be omitted on the response. This means deleted roles are silently dropped.
func IsSystemRoleName ¶ added in v2.32.0
func ReconcileSystemRole ¶ added in v2.32.0
func ReconcileSystemRole( ctx context.Context, tx database.Store, in database.CustomRole, org database.Organization, ) (database.CustomRole, bool, error)
ReconcileSystemRole compares the given role's permissions against the desired permissions produced by the permissions function based on the organization's settings. If they differ, the DB row is updated. Uses set-based comparison so permission ordering doesn't matter. Returns the correct role and a boolean indicating whether the reconciliation was necessary.
IMPORTANT: Callers must hold database.LockIDReconcileSystemRoles for the duration of the enclosing transaction.
Types ¶
This section is empty.