mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: include custom roles in list org roles (#13336)
* chore: include custom roles in list org roles * move cli show roles to org scope
This commit is contained in:
@@ -5,10 +5,13 @@ FROM
|
||||
custom_roles
|
||||
WHERE
|
||||
true
|
||||
-- Lookup roles filter
|
||||
-- Lookup roles filter expects the role names to be in the rbac package
|
||||
-- format. Eg: name[:<organization_id>]
|
||||
AND CASE WHEN array_length(@lookup_roles :: text[], 1) > 0 THEN
|
||||
-- Case insensitive
|
||||
name ILIKE ANY(@lookup_roles :: text [])
|
||||
-- Case insensitive lookup with org_id appended (if non-null).
|
||||
-- This will return just the name if org_id is null. It'll append
|
||||
-- the org_id if not null
|
||||
concat(name, NULLIF(concat(':', organization_id), ':')) ILIKE ANY(@lookup_roles :: text [])
|
||||
ELSE true
|
||||
END
|
||||
-- Org scoping filter, to only fetch site wide roles
|
||||
@@ -16,6 +19,10 @@ WHERE
|
||||
organization_id IS null
|
||||
ELSE true
|
||||
END
|
||||
AND CASE WHEN @organization_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN
|
||||
organization_id = @organization_id
|
||||
ELSE true
|
||||
END
|
||||
;
|
||||
|
||||
-- name: UpsertCustomRole :one
|
||||
@@ -23,6 +30,7 @@ INSERT INTO
|
||||
custom_roles (
|
||||
name,
|
||||
display_name,
|
||||
organization_id,
|
||||
site_permissions,
|
||||
org_permissions,
|
||||
user_permissions,
|
||||
@@ -33,6 +41,7 @@ VALUES (
|
||||
-- Always force lowercase names
|
||||
lower(@name),
|
||||
@display_name,
|
||||
@organization_id,
|
||||
@site_permissions,
|
||||
@org_permissions,
|
||||
@user_permissions,
|
||||
|
||||
Reference in New Issue
Block a user