mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: configurable default org member roles (#25994)
Refs #25936. Adds a configurable per-org default member role set. Unioned into each member's effective roles at read time. <sub>with Coder Agents on behalf of @Emyrk.</sub>
This commit is contained in:
@@ -609,21 +609,28 @@ SELECT
|
||||
-- Concatenating the organization id scopes the organization roles.
|
||||
array_agg(org_roles || ':' || organization_members.organization_id::text)
|
||||
FROM
|
||||
organization_members,
|
||||
organization_members
|
||||
JOIN organizations ON organizations.id = organization_members.organization_id,
|
||||
-- All org members get an implied role for their orgs. Most members
|
||||
-- get organization-member, but service accounts will get
|
||||
-- organization-service-account instead. They're largely the same,
|
||||
-- but having them be distinct means we can allow configuring
|
||||
-- service-accounts to have slightly broader permissions–such as
|
||||
-- service-accounts to have slightly broader permissions, such as
|
||||
-- for workspace sharing.
|
||||
--
|
||||
-- organizations.default_org_member_roles is unioned in so changes
|
||||
-- to org defaults propagate to every member on the next request.
|
||||
unnest(
|
||||
array_append(
|
||||
roles,
|
||||
CASE WHEN users.is_service_account THEN
|
||||
'organization-service-account'
|
||||
ELSE
|
||||
'organization-member'
|
||||
END
|
||||
array_cat(
|
||||
array_append(
|
||||
roles,
|
||||
CASE WHEN users.is_service_account THEN
|
||||
'organization-service-account'
|
||||
ELSE
|
||||
'organization-member'
|
||||
END
|
||||
),
|
||||
organizations.default_org_member_roles
|
||||
)
|
||||
) AS org_roles
|
||||
WHERE
|
||||
@@ -644,7 +651,7 @@ SELECT
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
id = @user_id;
|
||||
users.id = @user_id;
|
||||
|
||||
-- name: UpdateUserQuietHoursSchedule :one
|
||||
UPDATE
|
||||
|
||||
Reference in New Issue
Block a user