Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: support group id (#18209)

ecmadao9cf49d079d72
diff --git a/backend/api/directory-sync/aad.go b/backend/api/directory-sync/aad.go
index 8e917c4778..b1c5247982 100644
--- a/backend/api/directory-sync/aad.go
+++ b/backend/api/directory-sync/aad.go
@@ -10,13 +10,26 @@ type AADResourceMeta struct {
ResourceType string `json:"resourceType"`
}
-// AAD user schema
+// AADUser represents the SCIM User schema for Azure AD (Entra ID) provisioning.
// Docs: https://learn.microsoft.com/en-us/entra/identity/app-provisioning/use-scim-to-provision-users-and-groups#design-your-user-and-group-schema
+//
+// SCIM ID mapping for users:
+// - id: Bytebase's user UID (numeric, returned as string). Used by Azure in subsequent API calls.
+// - externalId: Azure's objectId (optional). Azure sends this but we use userName (email) for user matching.
+// - userName: User's email address (maps to userPrincipalName in Azure). Primary identifier for user lookup.
+//
+// Unlike groups, users are matched by userName (email) rather than externalId because:
+// - Email is the natural unique identifier for users in Bytebase
+// - Azure's default attribute mapping uses userPrincipalName -> userName
+//
+// Docs: https://learn.microsoft.com/en-us/entra/identity/app-provisioning/use-scim-to-provision-users-and-groups#get-user-by-query
type AADUser struct {
- ID string `json:"id"`
- Schemas []string `json:"schemas"`
- ExternalID string `json:"externalId"`
- // Map to userPrincipalName in AAD.
+ // id is Bytebase's user UID, used by Azure in subsequent requests (GET/PATCH/DELETE /Users/{id}).
+ ID string `json:"id"`
+ Schemas []string `json:"schemas"`
+ // externalId is Azure's objectId. We don't use this for user matching; we use userName instead.
+ ExternalID string `json:"externalId"`
+ // userName maps to userPrincipalName in Azure. This is the primary identifier for user lookup.
UserName string `json:"userName"`
Active bool `json:"active"`
DisplayName string `json:"displayName"`
@@ -24,10 +37,27 @@ type AADUser struct {
Meta *AADResourceMeta `json:"meta"`
}
+// AADGroup represents the SCIM Group schema for Azure AD (Entra ID) provisioning.
+// Docs: https://learn.microsoft.com/en-us/entra/identity/app-provisioning/use-scim-to-provision-users-and-groups
+//
+// SCIM ID mapping:
+// - id: Bytebase's internal group identifier (returned to Azure, used in subsequent API calls)
+// - externalId: Azure's objectId for the group (sent by Azure to identify the group in their system)
+//
+// Docs: https://learn.microsoft.com/en-us/answers/questions/1394370/azure-ad-scim-provisioning-group-update-requests-w
+// Docs: https://stackoverflow.com/questions/67198152/where-does-azuread-store-the-id-attribute-returned-by-a-scim-endpoint
type AADGroup struct {
- ID string `json:"id"`
- Schemas []string `json:"schemas"`
- ExternalID string `json:"externalId"`
+ // id is returned by our SCIM server and used by Azure in subsequent requests (GET/PATCH/DELETE /Groups/{id}).
+ ID string `json:"id"`
+ Schemas []string `json:"schemas"`
+ // externalId is Azure's objectId for the group. Azure sends this so we can correlate their group with ours.
+ // By default, Azure maps objectId -> externalId in attribute mappings.
+ ExternalID string `json:"externalId"`
+ // email is a custom attribute mapped from Azure group's mail attribute.
+ // Configure in Azure: Entra ID -> Enterprise apps -> Provisioning -> Attribute Mappings -> Groups
+ // Add custom attribute "email" and map Azure "mail" -> SCIM "email".
+ // Docs: https://learn.microsoft.com/en-us/entra/identity/app-provisioning/customize-application-attributes
+ Email string `json:"email"`
DisplayName string `json:"displayName"`
Members []string `json:"members"`
Meta *AADResourceMeta `json:"meta"`
diff --git a/backend/api/directory-sync/webhook.go b/backend/api/directory-sync/webhook.go
index 510af42e89..1ffb685d48 100644
--- a/backend/api/directory-sync/webhook.go
+++ b/backend/api/directory-sync/webhook.go
@@ -24,6 +24,7 @@ import (
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/store"
+ "github.com/bytebase/bytebase/backend/utils"
)
const entraIDSource = "Entra ID"
@@ -132,7 +133,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
return c.JSON(http.StatusOK, convertToAADUser(user))
})
- // List users. AAD SCIM will send ?filter=userName eq "{user name}" query
+ // List users. AAD SCIM will send ?filter=userName eq "{email}" query.
+ // userName maps to userPrincipalName in Azure, which is typically the user's email.
+ // Docs: https://learn.microsoft.com/en-us/entra/identity/app-provisioning/use-scim-to-provision-users-and-groups#get-user-by-query
g.GET("/workspaces/:workspaceID/Users", func(c echo.Context) error {
ctx := c.Request().Context()
if err := s.validRequestURL(ctx, c); err != nil {
@@ -323,7 +326,8 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
// 2. POST group without members
// 3. PATCH group with members
group, err := s.store.CreateGroup(ctx, &store.GroupMessage{
- Email: aadGroup.ExternalID,
+ ID: aadGroup.ExternalID,
+ Email: aadGroup.Email,
Title: aadGroup.DisplayName,
Payload: &storepb.GroupPayload{
Source: entraIDSource,
@@ -346,12 +350,11 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
return c.String(http.StatusForbidden, err.Error())
}
- email, err := decodeGroupEmail(c.Param("groupID"))
+ groupName, err := decodeGroupIdentifier(c.Param("groupID"))
if err != nil {
- return c.String(http.StatusInternalServerError, err.Error())
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to parse group %v, error %v", c.Param("groupID"), err))
}
-
- group, err := s.store.GetGroup(ctx, email)
+ group, err := utils.GetGroupByName(ctx, s.store, groupName)
if err != nil {
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to find group, error %v", err))
}
@@ -367,7 +370,11 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
return c.JSON(http.StatusOK, convertToAADGroup(group))
})
- // List groups. AAD SCIM will send ?filter=externalId eq "{group email}" query
+ // List groups. AAD SCIM will send ?filter=externalId eq "{value}" query.
+ // externalId can be Azure's objectId or group email depending on customer's attribute mapping:
+ // - New default: objectId -> externalId (recommended, stable across email changes)
+ // - Legacy mapping: mail -> externalId (for backward compatibility)
+ // Docs: https://learn.microsoft.com/en-us/entra/identity/app-provisioning/use-scim-to-provision-users-and-groups#get-group-by-query
g.GET("/workspaces/:workspaceID/Groups", func(c echo.Context) error {
ctx := c.Request().Context()
if err := s.validRequestURL(ctx, c); err != nil {
@@ -405,7 +412,14 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
slog.Warn("unsupport filter key", slog.String("key", expr.Key), slog.String("operator", string(expr.Operator)), slog.String("value", expr.Value))
continue
}
- find.Email = &expr.Value
+ // externalId can be either Azure's objectId or group email, depending on customer's attribute mapping.
+ // - New default: objectId -> externalId (UUID format, no @)
+ // - Legacy mapping: mail -> externalId (email format, contains @)
+ if strings.Contains(expr.Value, "@") {
+ find.Email = &expr.Value
+ } else {
+ find.ID = &expr.Value
+ }
}
groups, err := s.store.ListGroups(ctx, find)
@@ -430,12 +444,24 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
return c.String(http.StatusForbidden, err.Error())
}
- email, err := decodeGroupEmail(c.Param("groupID"))
+ groupName, err := decodeGroupIdentifier(c.Param("groupID"))
if err != nil {
- return c.String(http.StatusInternalServerError, err.Error())
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to parse group %v, error %v", c.Param("groupID"), err))
+ }
+ group, err := utils.GetGroupByName(ctx, s.store, groupName)
+ if err != nil {
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to find group, error %v", err))
+ }
+ if group == nil {
+ return c.JSON(http.StatusNotFound, map[string]any{
+ "schemas": []string{
+ "urn:ietf:params:scim:api:messages:2.0:Error",
+ },
+ "status": "404",
+ })
}
- if err := s.store.DeleteGroup(ctx, email); err != nil {
+ if err := s.store.DeleteGroup(ctx, group.ID); err != nil {
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to delete group, error %v", err))
}
@@ -465,20 +491,26 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to unmarshal body, error %v", err))
}
- email, err := decodeGroupEmail(c.Param("groupID"))
+ groupName, err := decodeGroupIdentifier(c.Param("groupID"))
if err != nil {
- return c.String(http.StatusInternalServerError, err.Error())
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to parse group %v, error %v", c.Param("groupID"), err))
}
-
- group, err := s.store.GetGroup(ctx, email)
+ group, err := utils.GetGroupByName(ctx, s.store, groupName)
if err != nil {
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to find group, error %v", err))
}
if group == nil {
- return c.String(http.StatusNotFound, "cannot found group")
+ return c.JSON(http.StatusNotFound, map[string]any{
+ "schemas": []string{
+ "urn:ietf:params:scim:api:messages:2.0:Error",
+ },
+ "status": "404",
+ })
}
- updateGroup := &store.UpdateGroupMessage{}
+ updateGroup := &store.UpdateGroupMessage{
+ ID: group.ID,
+ }
for _, op := range patch.Operations {
switch op.Path {
case "members":
@@ -554,7 +586,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
}
}
- updatedGroup, err := s.store.UpdateGroup(ctx, group.Email, updateGroup)
+ updatedGroup, err := s.store.UpdateGroup(ctx, updateGroup)
if err != nil {
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to update group, error %v", err))
}
@@ -610,12 +642,12 @@ func (s *Service) validRequestURL(ctx context.Context, c echo.Context) error {
return nil
}
-func decodeGroupEmail(groupID string) (string, error) {
- email, err := url.QueryUnescape(groupID)
+func decodeGroupIdentifier(groupID string) (string, error) {
+ identifier, err := url.QueryUnescape(groupID)
if err != nil {
return "", errors.Wrapf(err, "failed to decode group id %s", groupID)
}
- return email, nil
+ return identifier, nil
}
func convertToAADUser(user *store.UserMessage) *AADUser {
@@ -645,8 +677,11 @@ func convertToAADGroup(group *store.GroupMessage) *AADGroup {
Schemas: []string{
"urn:ietf:params:scim:schemas:core:2.0:Group",
},
- ID: group.Email,
- ExternalID: group.Email,
+ // We use the azure group object id (external id) to create the group.
+ // So both ID and ExternalID should be the group.ID (equals external id).
+ ID: group.ID,
+ ExternalID: group.ID,
+ Email: group.Email,
DisplayName: group.Title,
Meta: &AADResourceMeta{
ResourceType: "Group",
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index 9ae6e1dfb5..e9a760a649 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -649,7 +649,8 @@ func (s *AuthService) syncUserGroups(ctx context.Context, user *store.UserMessag
return member.Member == common.FormatUserUID(user.ID)
})
}
- if _, err := s.store.UpdateGroup(ctx, bbGroup.Email, &store.UpdateGroupMessage{
+ if _, err := s.store.UpdateGroup(ctx, &store.UpdateGroupMessage{
+ ID: bbGroup.ID,
Payload: bbGroup.Payload,
}); err != nil {
return connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to update group %q", bbGroup.Email))
diff --git a/backend/api/v1/group_service.go b/backend/api/v1/group_service.go
index aa3bddaa35..2f09f120d6 100644
--- a/backend/api/v1/group_service.go
+++ b/backend/api/v1/group_service.go
@@ -16,6 +16,7 @@ import (
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
"github.com/bytebase/bytebase/backend/store"
+ "github.com/bytebase/bytebase/backend/utils"
)
// GroupService implements the group service.
@@ -37,15 +38,13 @@ func NewGroupService(store *store.Store, iamManager *iam.Manager, licenseService
// GetGroup gets a group.
func (s *GroupService) GetGroup(ctx context.Context, req *connect.Request[v1pb.GetGroupRequest]) (*connect.Response[v1pb.Group], error) {
- email, err := common.GetGroupEmail(req.Msg.Name)
- if err != nil {
- return nil, connect.NewError(connect.CodeInvalidArgument, err)
- }
-
- group, err := s.store.GetGroup(ctx, email)
+ group, err := utils.GetGroupByName(ctx, s.store, req.Msg.Name)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
+ if group == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("cannot found the group %v", req.Msg.Name))
+ }
result, err := s.convertToV1Group(ctx, group)
if err != nil {
@@ -151,22 +150,17 @@ func (s *GroupService) UpdateGroup(ctx context.Context, req *connect.Request[v1p
if err := s.licenseService.IsFeatureEnabled(v1pb.PlanFeature_FEATURE_USER_GROUPS); err != nil {
return nil, connect.NewError(connect.CodePermissionDenied, err)
}
- groupEmail, err := common.GetGroupEmail(req.Msg.Group.Name)
- if err != nil {
- return nil, connect.NewError(connect.CodeInvalidArgument, err)
- }
- user, ok := GetUserFromContext(ctx)
- if !ok {
- return nil, connect.NewError(connect.CodeInternal, errors.New("user not found"))
- }
-
- group, err := s.store.GetGroup(ctx, groupEmail)
+ group, err := utils.GetGroupByName(ctx, s.store, req.Msg.Group.Name)
if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get group %q", groupEmail))
+ return nil, connect.NewError(connect.CodeInternal, err)
}
if group == nil {
if req.Msg.AllowMissing {
+ groupEmail, err := common.GetGroupEmail(req.Msg.Group.Name)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, err)
+ }
// Permission check is now handled by the ACL interceptor
// which verifies both bb.groups.update and bb.groups.create
return s.CreateGroup(ctx, connect.NewRequest(&v1pb.CreateGroupRequest{
@@ -174,16 +168,27 @@ func (s *GroupService) UpdateGroup(ctx context.Context, req *connect.Request[v1p
GroupEmail: groupEmail,
}))
}
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("group %q not found", groupEmail))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("group %q not found", req.Msg.Group.Name))
+ }
+ if group.Payload.Source != "" {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("not support update external group %q", req.Msg.Group.Name))
}
+ user, ok := GetUserFromContext(ctx)
+ if !ok {
+ return nil, connect.NewError(connect.CodeInternal, errors.New("user not found"))
+ }
if err := s.checkPermission(ctx, group, user, iam.PermissionGroupsUpdate); err != nil {
return nil, err
}
- patch := &store.UpdateGroupMessage{}
+ patch := &store.UpdateGroupMessage{
+ ID: group.ID,
+ }
for _, path := range req.Msg.UpdateMask.Paths {
switch path {
+ case "email":
+ patch.Email = &req.Msg.Group.Email
case "title":
patch.Title = &req.Msg.Group.Title
case "description":
@@ -202,7 +207,7 @@ func (s *GroupService) UpdateGroup(ctx context.Context, req *connect.Request[v1p
}
}
- groupMessage, err := s.store.UpdateGroup(ctx, groupEmail, patch)
+ groupMessage, err := s.store.UpdateGroup(ctx, patch)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
@@ -220,9 +225,12 @@ func (s *GroupService) UpdateGroup(ctx context.Context, req *connect.Request[v1p
// DeleteGroup deletes a group.
func (s *GroupService) DeleteGroup(ctx context.Context, req *connect.Request[v1pb.DeleteGroupRequest]) (*connect.Response[emptypb.Empty], error) {
- email, err := common.GetGroupEmail(req.Msg.Name)
+ group, err := utils.GetGroupByName(ctx, s.store, req.Msg.Name)
if err != nil {
- return nil, connect.NewError(connect.CodeInvalidArgument, err)
+ return nil, connect.NewError(connect.CodeInternal, err)
+ }
+ if group == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("cannot found the group %v", req.Msg.Name))
}
user, ok := GetUserFromContext(ctx)
@@ -230,19 +238,11 @@ func (s *GroupService) DeleteGroup(ctx context.Context, req *connect.Request[v1p
return nil, connect.NewError(connect.CodeInternal, errors.New("user not found"))
}
- group, err := s.store.GetGroup(ctx, email)
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get group %q", email))
- }
- if group == nil {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("cannot found the group %v", req.Msg.Name))
- }
-
if err := s.checkPermission(ctx, group, user, iam.PermissionGroupsDelete); err != nil {
return nil, err
}
- if err := s.store.DeleteGroup(ctx, email); err != nil {
+ if err := s.store.DeleteGroup(ctx, group.ID); err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
@@ -332,11 +332,18 @@ func (s *GroupService) convertToV1Group(ctx context.Context, groupMessage *store
return nil, connect.NewError(connect.CodeNotFound, errors.New("cannot found group"))
}
+ var name string
+ if groupMessage.Email != "" {
+ name = common.FormatGroupEmail(groupMessage.Email)
+ } else {
+ name = common.FormatGroupEmail(groupMessage.ID)
+ }
group := &v1pb.Group{
- Name: common.FormatGroupEmail(groupMessage.Email),
+ Name: name,
Title: groupMessage.Title,
Description: groupMessage.Description,
Source: groupMessage.Payload.Source,
+ Email: groupMessage.Email,
}
for _, member := range groupMessage.Payload.Members {
diff --git a/backend/generated-go/v1/group_service.pb.go b/backend/generated-go/v1/group_service.pb.go
index c5e7c9ce0e..233f1a1bc8 100644
--- a/backend/generated-go/v1/group_service.pb.go
+++ b/backend/generated-go/v1/group_service.pb.go
@@ -592,7 +592,7 @@ func (x *GroupMember) GetRole() GroupMember_Role {
type Group struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the group to retrieve.
- // Format: groups/{group}, group is an email.
+ // Format: groups/{group}, the group should be email or uuid.
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The display title of the group.
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
@@ -601,7 +601,9 @@ type Group struct {
// The members of the group.
Members []*GroupMember `protobuf:"bytes,5,rep,name=members,proto3" json:"members,omitempty"`
// The source system where the group originated (e.g., Entra ID for SCIM sync).
- Source string `protobuf:"bytes,7,opt,name=source,proto3" json:"source,omitempty"`
+ Source string `protobuf:"bytes,7,opt,name=source,proto3" json:"source,omitempty"`
+ // The unique email for the group.
+ Email string `protobuf:"bytes,8,opt,name=email,proto3" json:"email,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -671,6 +673,13 @@ func (x *Group) GetSource() string {
return ""
}
+func (x *Group) GetEmail() string {
+ if x != nil {
+ return x.Email
+ }
+ return ""
+}
+
var File_v1_group_service_proto protoreflect.FileDescriptor
const file_v1_group_service_proto_rawDesc = "" +
@@ -711,13 +720,14 @@ const file_v1_group_service_proto_rawDesc = "" +
"\x10ROLE_UNSPECIFIED\x10\x00\x12\t\n" +
"\x05OWNER\x10\x01\x12\n" +
"\n" +
- "\x06MEMBER\x10\x02\"\xe1\x01\n" +
+ "\x06MEMBER\x10\x02\"\xf7\x01\n" +
"\x05Group\x12\x17\n" +
"\x04name\x18\x01 \x01(\tB\x03\xe0A\x03R\x04name\x12\x1e\n" +
"\x05title\x18\x02 \x01(\tB\b\xbaH\x05r\x03\x18\xc8\x01R\x05title\x12*\n" +
"\vdescription\x18\x03 \x01(\tB\b\xbaH\x05r\x03\x18\xe8\aR\vdescription\x122\n" +
"\amembers\x18\x05 \x03(\v2\x18.bytebase.v1.GroupMemberR\amembers\x12\x16\n" +
- "\x06source\x18\a \x01(\tR\x06source:'\xeaA$\n" +
+ "\x06source\x18\a \x01(\tR\x06source\x12\x14\n" +
+ "\x05email\x18\b \x01(\tR\x05email:'\xeaA$\n" +
"\x12bytebase.com/Group\x12\x0egroups/{group}2\xcf\x06\n" +
"\fGroupService\x12u\n" +
"\bGetGroup\x12\x1c.bytebase.v1.GetGroupRequest\x1a\x12.bytebase.v1.Group\"7\xdaA\x04name\x8a\xea0\rbb.groups.get\x90\xea0\x01\x82\xd3\xe4\x93\x02\x15\x12\x13/v1/{name=groups/*}\x12\x8b\x01\n" +
diff --git a/backend/generated-go/v1/group_service_equal.pb.go b/backend/generated-go/v1/group_service_equal.pb.go
index 0d5d10b153..cc0bc8958e 100644
--- a/backend/generated-go/v1/group_service_equal.pb.go
+++ b/backend/generated-go/v1/group_service_equal.pb.go
@@ -192,5 +192,8 @@ func (x *Group) Equal(y *Group) bool {
if x.Source != y.Source {
return false
}
+ if x.Email != y.Email {
+ return false
+ }
return true
}
diff --git a/backend/migrator/migration/3.13/0001##add_group_id_column.sql b/backend/migrator/migration/3.13/0001##add_group_id_column.sql
new file mode 100644
index 0000000000..705501ef14
--- /dev/null
+++ b/backend/migrator/migration/3.13/0001##add_group_id_column.sql
@@ -0,0 +1,40 @@
+-- Add id column with UUID default for new rows
+ALTER TABLE user_group ADD COLUMN IF NOT EXISTS id TEXT DEFAULT gen_random_uuid()::text;
+
+-- Backfill existing rows:
+-- 1. If email doesn't contain '@', it's likely an Azure object ID (legacy mapping: objectId -> externalId -> email)
+-- Move the value to id column and set email to NULL
+-- 2. Otherwise, generate a new UUID for id
+UPDATE user_group SET
+ id = CASE
+ WHEN email IS NOT NULL AND email NOT LIKE '%@%' THEN email
+ ELSE gen_random_uuid()::text
+ END,
+ email = CASE
+ WHEN email IS NOT NULL AND email NOT LIKE '%@%' THEN NULL
+ ELSE email
+ END
+WHERE id IS NULL OR id = '';
+
+-- Set NOT NULL constraint after backfill
+ALTER TABLE user_group ALTER COLUMN id SET NOT NULL;
+
+-- Drop the primary key constraint on email if it exists
+ALTER TABLE user_group DROP CONSTRAINT IF EXISTS user_group_pkey;
+
+-- Add primary key on id if not exists
+DO $$
+BEGIN
+ IF NOT EXISTS (
+ SELECT 1 FROM pg_constraint
+ WHERE conname = 'user_group_pkey' AND conrelid = 'user_group'::regclass
+ ) THEN
+ ALTER TABLE user_group ADD PRIMARY KEY (id);
+ END IF;
+END $$;
+
+-- Make email nullable
+ALTER TABLE user_group ALTER COLUMN email DROP NOT NULL;
+
+-- Create unique index on email (only for non-null values)
+CREATE UNIQUE INDEX IF NOT EXISTS idx_user_group_unique_email ON user_group(email) WHERE email IS NOT NULL;
diff --git a/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sql
index c90e82da5b..63706eb031 100644
--- a/backend/migrator/migration/LATEST.sql
+++ b/backend/migrator/migration/LATEST.sql
@@ -464,13 +464,16 @@ CREATE TABLE export_archive (
);
CREATE TABLE user_group (
- email text PRIMARY KEY,
+ id text PRIMARY KEY DEFAULT gen_random_uuid()::text,
+ email text,
name text NOT NULL,
description text NOT NULL DEFAULT '',
-- Stored as GroupPayload (proto/store/store/group.proto)
payload jsonb NOT NULL DEFAULT '{}'
);
+CREATE UNIQUE INDEX idx_user_group_unique_email ON user_group(email) WHERE email IS NOT NULL;
+
-- review config table.
CREATE TABLE review_config (
id text NOT NULL PRIMARY KEY,
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index 13f412fe1e..45108f2328 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -12,7 +12,7 @@ import (
func TestLatestVersion(t *testing.T) {
files, err := getSortedVersionedFiles()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("3.13.0"), *files[len(files)-1].version)
+ require.Equal(t, semver.MustParse("3.13.1"), *files[len(files)-1].version)
}
func TestVersionUnique(t *testing.T) {
diff --git a/backend/store/group.go b/backend/store/group.go
index 85537deb7a..8dc17a1100 100644
--- a/backend/store/group.go
+++ b/backend/store/group.go
@@ -19,6 +19,7 @@ import (
// FindGroupMessage is the message for finding groups.
type FindGroupMessage struct {
+ ID *string
Email *string
ProjectID *string
FilterQ *qb.Query
@@ -29,6 +30,11 @@ type FindGroupMessage struct {
// UpdateGroupMessage is the message to update a group.
type UpdateGroupMessage struct {
+ // identifier
+ ID string
+
+ // payload
+ Email *string
Title *string
Description *string
Payload *storepb.GroupPayload
@@ -36,6 +42,7 @@ type UpdateGroupMessage struct {
// GroupMessage is the message for a group.
type GroupMessage struct {
+ ID string
Email string
Title string
Description string
@@ -43,9 +50,11 @@ type GroupMessage struct {
}
// GetGroup gets a group.
-func (s *Store) GetGroup(ctx context.Context, email string) (*GroupMessage, error) {
- if v, ok := s.groupCache.Get(email); ok && s.enableCache {
- return v, nil
+func (s *Store) GetGroup(ctx context.Context, find *FindGroupMessage) (*GroupMessage, error) {
+ if find.Email != nil {
+ if v, ok := s.groupCache.Get(*find.Email); ok && s.enableCache {
+ return v, nil
+ }
}
tx, err := s.GetDB().BeginTx(ctx, nil)
@@ -54,9 +63,7 @@ func (s *Store) GetGroup(ctx context.Context, email string) (*GroupMessage, erro
}
defer tx.Rollback()
- groups, err := s.listGroupImpl(ctx, tx, &FindGroupMessage{
- Email: &email,
- })
+ groups, err := s.listGroupImpl(ctx, tx, find)
if err != nil {
return nil, err
}
@@ -67,7 +74,7 @@ func (s *Store) GetGroup(ctx context.Context, email string) (*GroupMessage, erro
if len(groups) == 0 {
return nil, nil
} else if len(groups) > 1 {
- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d groups with email %+v, expect 1", len(groups), email)}
+ return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d groups with filter %+v, expect 1", len(groups), find)}
}
return groups[0], nil
}
@@ -117,6 +124,9 @@ func (*Store) listGroupImpl(ctx context.Context, txn *sql.Tx, find *FindGroupMes
if filterQ := find.FilterQ; filterQ != nil {
where.And("?", filterQ)
}
+ if v := find.ID; v != nil {
+ where.And("id = ?", *v)
+ }
if v := find.Email; v != nil {
where.And("email = ?", *v)
}
@@ -127,6 +137,7 @@ func (*Store) listGroupImpl(ctx context.Context, txn *sql.Tx, find *FindGroupMes
}
q.Space(`
SELECT
+ user_group.id,
user_group.email,
user_group.name,
user_group.description,
@@ -157,15 +168,20 @@ func (*Store) listGroupImpl(ctx context.Context, txn *sql.Tx, find *FindGroupMes
for rows.Next() {
var group GroupMessage
+ var email sql.NullString
var payload []byte
if err := rows.Scan(
- &group.Email,
+ &group.ID,
+ &email,
&group.Title,
&group.Description,
&payload,
); err != nil {
return nil, err
}
+ if email.Valid {
+ group.Email = email.String
+ }
groupPayload := storepb.GroupPayload{}
if err := common.ProtojsonUnmarshaler.Unmarshal(payload, &groupPayload); err != nil {
return nil, err
@@ -191,14 +207,21 @@ func (s *Store) CreateGroup(ctx context.Context, create *GroupMessage) (*GroupMe
return nil, err
}
+ var email *string
+ if create.Email != "" {
+ email = &create.Email
+ }
+
q := qb.Q().Space(`
INSERT INTO user_group (
+ id,
email,
name,
description,
payload
- ) VALUES (?, ?, ?, ?)
- `, create.Email, create.Title, create.Description, payloadBytes)
+ ) VALUES (COALESCE(NULLIF(?, ''), gen_random_uuid()::text), ?, ?, ?, ?)
+ RETURNING id
+ `, create.ID, email, create.Title, create.Description, payloadBytes)
query, args, err := q.ToSQL()
if err != nil {
@@ -211,7 +234,7 @@ func (s *Store) CreateGroup(ctx context.Context, create *GroupMessage) (*GroupMe
}
defer tx.Rollback()
- if _, err := tx.ExecContext(ctx, query, args...); err != nil {
+ if err := tx.QueryRowContext(ctx, query, args...).Scan(&create.ID); err != nil {
return nil, err
}
@@ -224,9 +247,11 @@ func (s *Store) CreateGroup(ctx context.Context, create *GroupMessage) (*GroupMe
}
// UpdateGroup updates a group.
-func (s *Store) UpdateGroup(ctx context.Context, email string, patch *UpdateGroupMessage) (*GroupMessage, error) {
+func (s *Store) UpdateGroup(ctx context.Context, patch *UpdateGroupMessage) (*GroupMessage, error) {
set := qb.Q()
-
+ if v := patch.Email; v != nil {
+ set.Comma("email = ?", *v)
+ }
if v := patch.Title; v != nil {
set.Comma("name = ?", *v)
}
@@ -244,13 +269,14 @@ func (s *Store) UpdateGroup(ctx context.Context, email string, patch *UpdateGrou
q := qb.Q().Space(`
UPDATE user_group
SET ?
- WHERE email = ?
+ WHERE id = ?
RETURNING
+ id,
email,
name,
description,
payload
- `, set, email)
+ `, set, patch.ID)
query, args, err := q.ToSQL()
if err != nil {
@@ -267,6 +293,7 @@ func (s *Store) UpdateGroup(ctx context.Context, email string, patch *UpdateGrou
var payload []byte
if err := tx.QueryRowContext(ctx, query, args...).Scan(
+ &group.ID,
&group.Email,
&group.Title,
&group.Description,
@@ -290,20 +317,21 @@ func (s *Store) UpdateGroup(ctx context.Context, email string, patch *UpdateGrou
}
// DeleteGroup deletes a group.
-func (s *Store) DeleteGroup(ctx context.Context, email string) error {
+func (s *Store) DeleteGroup(ctx context.Context, id string) error {
tx, err := s.GetDB().BeginTx(ctx, nil)
if err != nil {
return errors.Wrap(err, "failed to begin transaction")
}
defer tx.Rollback()
- q := qb.Q().Space("DELETE FROM user_group WHERE email = ?", email)
+ q := qb.Q().Space("DELETE FROM user_group WHERE id = ? RETURNING email", id)
query, args, err := q.ToSQL()
if err != nil {
return errors.Wrapf(err, "failed to build sql")
}
- if _, err := tx.ExecContext(ctx, query, args...); err != nil {
+ var email string
+ if err := tx.QueryRowContext(ctx, query, args...).Scan(&email); err != nil {
return err
}
diff --git a/backend/utils/member.go b/backend/utils/member.go
index 730830d4fa..1dab4325a6 100644
--- a/backend/utils/member.go
+++ b/backend/utils/member.go
@@ -7,6 +7,8 @@ import (
"strings"
"time"
+ "github.com/pkg/errors"
+
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
@@ -66,6 +68,30 @@ func GetUsersByRoleInIAMPolicy(ctx context.Context, stores *store.Store, role st
return users
}
+// GetGroupByName finds a group by identifier which can be either:
+// - Azure objectId (UUID format, no @) - used as group ID in new deployments
+// - Group email (contains @) - used as group ID in legacy deployments
+//
+// This supports both attribute mapping configurations in Azure Entra ID.
+func GetGroupByName(ctx context.Context, stores *store.Store, name string) (*store.GroupMessage, error) {
+ identifier, err := common.GetGroupEmail(name)
+ if err != nil {
+ return nil, err
+ }
+ find := &store.FindGroupMessage{}
+ if strings.Contains(identifier, "@") {
+ find.Email = &identifier
+ } else {
+ find.ID = &identifier
+ }
+
+ group, err := stores.GetGroup(ctx, find)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get group %q", name)
+ }
+ return group, nil
+}
+
// GetUsersByMember gets user messages by member.
// The member should in users/{uid} or groups/{email} format.
func GetUsersByMember(ctx context.Context, stores *store.Store, member string) []*store.UserMessage {
@@ -76,12 +102,7 @@ func GetUsersByMember(ctx context.Context, stores *store.Store, member string) [
users = append(users, user)
}
} else if strings.HasPrefix(member, common.GroupPrefix) {
- groupEmail, err := common.GetGroupEmail(member)
- if err != nil {
- slog.Error("failed to parse group email", slog.String("group", member), log.BBError(err))
- return users
- }
- group, err := stores.GetGroup(ctx, groupEmail)
+ group, err := GetGroupByName(ctx, stores, member)
if err != nil {
slog.Error("failed to get group", slog.String("group", member), log.BBError(err))
return users
@@ -139,12 +160,7 @@ func GetUserIAMPolicyBindings(ctx context.Context, stores *store.Store, user *st
break
}
if strings.HasPrefix(member, common.GroupPrefix) {
- groupEmail, err := common.GetGroupEmail(member)
- if err != nil {
- slog.Error("failed to parse group email", slog.String("group", member), log.BBError(err))
- continue
- }
- group, err := stores.GetGroup(ctx, groupEmail)
+ group, err := GetGroupByName(ctx, stores, member)
if err != nil {
slog.Error("failed to get group", slog.String("group", member), log.BBError(err))
continue
@@ -191,12 +207,7 @@ func MemberContainsUser(ctx context.Context, stores *store.Store, member string,
// Check if member is a group
if strings.HasPrefix(member, common.GroupPrefix) {
- groupEmail, err := common.GetGroupEmail(member)
- if err != nil {
- slog.Error("failed to parse group email", slog.String("group", member), log.BBError(err))
- return false
- }
- group, err := stores.GetGroup(ctx, groupEmail)
+ group, err := GetGroupByName(ctx, stores, member)
if err != nil {
slog.Error("failed to get group", slog.String("group", member), log.BBError(err))
return false
diff --git a/frontend/src/components/User/Settings/CreateGroupDrawer.vue b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
index af206fa785..568221d7d0 100644
--- a/frontend/src/components/User/Settings/CreateGroupDrawer.vue
+++ b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
@@ -62,6 +62,7 @@
:multiple="false"
:size="'medium'"
:include-all="false"
+ :disabled="!allowEdit"
:filter="
(user, _) =>
!state.group.members.find(
@@ -74,6 +75,7 @@
<GroupMemberRoleSelect
:value="member.role"
:size="'medium'"
+ :disabled="!allowEdit"
@update:value="(role) => updateMemberRole(i, role)"
/>
<div class="flex justify-end">
@@ -81,7 +83,7 @@
quaternary
size="tiny"
type="error"
- :disabled="disallowEditMember"
+ :disabled="!allowEdit"
@click="deleteMember(i)"
>
<template #icon>
@@ -93,7 +95,7 @@
</div>
<div>
<NButton
- :disabled="!allowEdit || disallowEditMember"
+ :disabled="!allowEdit"
@click="addMember"
>
{{ $t("settings.members.add-member") }}
@@ -154,7 +156,6 @@ import EmailInput from "@/components/EmailInput.vue";
import RequiredStar from "@/components/RequiredStar.vue";
import { Drawer, DrawerContent, UserSelect } from "@/components/v2";
import {
- extractGroupEmail,
pushNotification,
useCurrentUserV1,
useGroupStore,
@@ -202,7 +203,7 @@ const currentUserV1 = useCurrentUserV1();
const state = reactive<LocalState>({
isRequesting: false,
group: {
- email: extractGroupEmail(props.group?.name ?? ""),
+ email: props.group?.email ?? "",
title: props.group?.title ?? "",
description: props.group?.description ?? "",
members: cloneDeep(
@@ -225,8 +226,6 @@ watchEffect(async () => {
}
});
-const disallowEditMember = computed(() => !!props.group?.source);
-
const isGroupOwner = computed(() => {
return (
props.group?.members.find(
@@ -240,6 +239,10 @@ const allowDelete = computed(() => {
});
const allowEdit = computed(() => {
+ if (!!props.group?.source) {
+ // do not support edit external group manually.
+ return false;
+ }
if (isGroupOwner.value) {
return true;
}
@@ -262,7 +265,9 @@ const validGroup = computed(() => {
}
}
return create(GroupSchema, {
- name: `${groupNamePrefix}${state.group.email}`,
+ name: props.group
+ ? props.group.name
+ : `${groupNamePrefix}${state.group.email}`,
title: state.group.title,
description: state.group.description,
members: [...memberMap.values()],
diff --git a/frontend/src/types/proto-es/v1/group_service_pb.d.ts b/frontend/src/types/proto-es/v1/group_service_pb.d.ts
index 44450fad49..89fcd5973c 100644
--- a/frontend/src/types/proto-es/v1/group_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/group_service_pb.d.ts
@@ -314,7 +314,7 @@ export declare const GroupMember_RoleSchema: GenEnum<GroupMember_Role>;
export declare type Group = Message<"bytebase.v1.Group"> & {
/**
* The name of the group to retrieve.
- * Format: groups/{group}, group is an email.
+ * Format: groups/{group}, the group should be email or uuid.
*
* @generated from field: string name = 1;
*/
@@ -347,6 +347,13 @@ export declare type Group = Message<"bytebase.v1.Group"> & {
* @generated from field: string source = 7;
*/
source: string;
+
+ /**
+ * The unique email for the group.
+ *
+ * @generated from field: string email = 8;
+ */
+ email: string;
};
/**
diff --git a/frontend/src/types/proto-es/v1/group_service_pb.js b/frontend/src/types/proto-es/v1/group_service_pb.js
index 5eb1b626e8..e054dc03e2 100644
--- a/frontend/src/types/proto-es/v1/group_service_pb.js
+++ b/frontend/src/types/proto-es/v1/group_service_pb.js
@@ -15,7 +15,7 @@ import { file_v1_annotation } from "./annotation_pb";
* Describes the file v1/group_service.proto.
*/
export const file_v1_group_service = /*@__P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5ieXRlYmFzZS52MS5Hcm91cCJs2kERZ3JvdXAsdXBkYXRlX21hc2uK6jAQYmIuZ3JvdXBzLnVwZGF0ZZDqMAKY6jABouowEGJiLmdyb3Vwcy5jcmVhdGWC0+STAiI6BWdyb3VwMhkvdjEve2dyb3VwLm5hbWU9Z3JvdXBzLyp9EoYBCgtEZWxldGVHcm91cBIfLmJ5dGViYXNlLnYxLkRlbGV0ZUdyb3VwUmVxdWVzdBoWLmdvb2dsZS5wcm90b2J1Zi5FbXB0eSI+2kEEbmFtZYrqMBBiYi5ncm91cHMuZGVsZXRlkOowApjqMAGC0+STAhUqEy92MS97bmFtZT1ncm91cHMvKn1CpwEKD2NvbS5ieXRlYmFzZS52MUIRR3JvdXBTZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_v1_annotation]);
+ fileDesc("ChZ2MS9ncm91cF9zZXJ2aWNlLnByb3RvEgtieXRlYmFzZS52MSI7Cg9HZXRHcm91cFJlcXVlc3QSKAoEbmFtZRgBIAEoCUIa4EEC+kEUChJieXRlYmFzZS5jb20vR3JvdXAiQgoVQmF0Y2hHZXRHcm91cHNSZXF1ZXN0EikKBW5hbWVzGAEgAygJQhrgQQL6QRQKEmJ5dGViYXNlLmNvbS9Hcm91cCI8ChZCYXRjaEdldEdyb3Vwc1Jlc3BvbnNlEiIKBmdyb3VwcxgBIAMoCzISLmJ5dGViYXNlLnYxLkdyb3VwIkoKEUxpc3RHcm91cHNSZXF1ZXN0EhEKCXBhZ2Vfc2l6ZRgBIAEo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2NvbS5ieXRlYmFzZS52MUIRR3JvdXBTZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_v1_annotation]);
/**
* Describes the message bytebase.v1.GetGroupRequest.
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 0ff01250fa..66e5ee8583 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -10518,7 +10518,7 @@ components:
type: string
description: |-
The name of the group to retrieve.
- Format: groups/{group}, group is an email.
+ Format: groups/{group}, the group should be email or uuid.
title:
type: string
description: The display title of the group.
@@ -10533,6 +10533,9 @@ components:
source:
type: string
description: The source system where the group originated (e.g., Entra ID for SCIM sync).
+ email:
+ type: string
+ description: The unique email for the group.
description: A group of users within the workspace.
GroupMember:
type: object
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 5cb210f97e..e3015a6ec6 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -6616,11 +6616,12 @@ A group of users within the workspace.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| name | [string](#string) | | The name of the group to retrieve. Format: groups/{group}, group is an email. |
+| name | [string](#string) | | The name of the group to retrieve. Format: groups/{group}, the group should be email or uuid. |
| title | [string](#string) | | The display title of the group. |
| description | [string](#string) | | The description of the group. |
| members | [GroupMember](#bytebase-v1-GroupMember) | repeated | The members of the group. |
| source | [string](#string) | | The source system where the group originated (e.g., Entra ID for SCIM sync). |
+| email | [string](#string) | | The unique email for the group. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 57826ec9b8..14dd87d39e 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -18859,7 +18859,7 @@ Format: groups/{email} </p></td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>The name of the group to retrieve.
-Format: groups/{group}, group is an email. </p></td>
+Format: groups/{group}, the group should be email or uuid. </p></td>
</tr>
<tr>
@@ -18890,6 +18890,13 @@ Format: groups/{group}, group is an email. </p></td>
<td><p>The source system where the group originated (e.g., Entra ID for SCIM sync). </p></td>
</tr>
+ <tr>
+ <td>email</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>The unique email for the group. </p></td>
+ </tr>
+
</tbody>
</table>
diff --git a/proto/v1/v1/group_service.proto b/proto/v1/v1/group_service.proto
index c42483bbfd..2ab0cc9f95 100644
--- a/proto/v1/v1/group_service.proto
+++ b/proto/v1/v1/group_service.proto
@@ -215,7 +215,7 @@ message Group {
};
// The name of the group to retrieve.
- // Format: groups/{group}, group is an email.
+ // Format: groups/{group}, the group should be email or uuid.
string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
// The display title of the group.
@@ -229,4 +229,7 @@ message Group {
// The source system where the group originated (e.g., Entra ID for SCIM sync).
string source = 7;
+
+ // The unique email for the group.
+ string email = 8;
}