Skip to content

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

feat: update principal store module with idp fields (#4361)

boojack7176d61d40e6
diff --git a/frontend/src/types/proto/v1/auth_service.ts b/frontend/src/types/proto/v1/auth_service.ts
index 36c7d4ce7a..24121082a3 100644
--- a/frontend/src/types/proto/v1/auth_service.ts
+++ b/frontend/src/types/proto/v1/auth_service.ts
@@ -192,6 +192,7 @@ export interface User {
email: string;
title: string;
password: string;
+ identityProvider: string;
userType: UserType;
/** The user role will not be respected in the create user request, because the role is controlled by workspace owner. */
userRole: UserRole;
@@ -726,7 +727,7 @@ export const LogoutRequest = {
};
function createBaseUser(): User {
- return { name: "", state: 0, email: "", title: "", password: "", userType: 0, userRole: 0 };
+ return { name: "", state: 0, email: "", title: "", password: "", identityProvider: "", userType: 0, userRole: 0 };
}
export const User = {
@@ -746,11 +747,14 @@ export const User = {
if (message.password !== "") {
writer.uint32(42).string(message.password);
}
+ if (message.identityProvider !== "") {
+ writer.uint32(50).string(message.identityProvider);
+ }
if (message.userType !== 0) {
- writer.uint32(48).int32(message.userType);
+ writer.uint32(56).int32(message.userType);
}
if (message.userRole !== 0) {
- writer.uint32(56).int32(message.userRole);
+ writer.uint32(64).int32(message.userRole);
}
return writer;
},
@@ -778,9 +782,12 @@ export const User = {
message.password = reader.string();
break;
case 6:
- message.userType = reader.int32() as any;
+ message.identityProvider = reader.string();
break;
case 7:
+ message.userType = reader.int32() as any;
+ break;
+ case 8:
message.userRole = reader.int32() as any;
break;
default:
@@ -798,6 +805,7 @@ export const User = {
email: isSet(object.email) ? String(object.email) : "",
title: isSet(object.title) ? String(object.title) : "",
password: isSet(object.password) ? String(object.password) : "",
+ identityProvider: isSet(object.identityProvider) ? String(object.identityProvider) : "",
userType: isSet(object.userType) ? userTypeFromJSON(object.userType) : 0,
userRole: isSet(object.userRole) ? userRoleFromJSON(object.userRole) : 0,
};
@@ -810,6 +818,7 @@ export const User = {
message.email !== undefined && (obj.email = message.email);
message.title !== undefined && (obj.title = message.title);
message.password !== undefined && (obj.password = message.password);
+ message.identityProvider !== undefined && (obj.identityProvider = message.identityProvider);
message.userType !== undefined && (obj.userType = userTypeToJSON(message.userType));
message.userRole !== undefined && (obj.userRole = userRoleToJSON(message.userRole));
return obj;
@@ -822,6 +831,7 @@ export const User = {
message.email = object.email ?? "";
message.title = object.title ?? "";
message.password = object.password ?? "";
+ message.identityProvider = object.identityProvider ?? "";
message.userType = object.userType ?? 0;
message.userRole = object.userRole ?? 0;
return message;
diff --git a/proto/generated-go/v1/auth_service.pb.go b/proto/generated-go/v1/auth_service.pb.go
index 08cb3444f4..d9e675abb8 100644
--- a/proto/generated-go/v1/auth_service.pb.go
+++ b/proto/generated-go/v1/auth_service.pb.go
@@ -12,6 +12,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
+ _ "google.golang.org/protobuf/types/known/wrapperspb"
reflect "reflect"
sync "sync"
)
@@ -669,14 +670,15 @@ type User struct {
// The name of the user.
// Format: users/{user}. {user} is a system-generated unique ID.
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- State State `protobuf:"varint,2,opt,name=state,proto3,enum=bytebase.v1.State" json:"state,omitempty"`
- Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
- Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
- Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"password,omitempty"`
- UserType UserType `protobuf:"varint,6,opt,name=user_type,json=userType,proto3,enum=bytebase.v1.UserType" json:"user_type,omitempty"`
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ State State `protobuf:"varint,2,opt,name=state,proto3,enum=bytebase.v1.State" json:"state,omitempty"`
+ Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
+ Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
+ Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"password,omitempty"`
+ IdentityProvider string `protobuf:"bytes,6,opt,name=identity_provider,json=identityProvider,proto3" json:"identity_provider,omitempty"`
+ UserType UserType `protobuf:"varint,7,opt,name=user_type,json=userType,proto3,enum=bytebase.v1.UserType" json:"user_type,omitempty"`
// The user role will not be respected in the create user request, because the role is controlled by workspace owner.
- UserRole UserRole `protobuf:"varint,7,opt,name=user_role,json=userRole,proto3,enum=bytebase.v1.UserRole" json:"user_role,omitempty"`
+ UserRole UserRole `protobuf:"varint,8,opt,name=user_role,json=userRole,proto3,enum=bytebase.v1.UserRole" json:"user_role,omitempty"`
}
func (x *User) Reset() {
@@ -746,6 +748,13 @@ func (x *User) GetPassword() string {
return ""
}
+func (x *User) GetIdentityProvider() string {
+ if x != nil {
+ return x.IdentityProvider
+ }
+ return ""
+}
+
func (x *User) GetUserType() UserType {
if x != nil {
return x.UserType
@@ -774,7 +783,9 @@ var file_v1_auth_service_proto_rawDesc = []byte{
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d,
0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64,
- 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x76, 0x31, 0x2f,
+ 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f,
+ 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61,
+ 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x76, 0x31, 0x2f,
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2a, 0x0a, 0x0e,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41,
@@ -818,7 +829,7 @@ var file_v1_auth_service_proto_rawDesc = []byte{
0x08, 0x52, 0x03, 0x77, 0x65, 0x62, 0x22, 0x25, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x0f, 0x0a,
- 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x80,
+ 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xb3,
0x02, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x12, 0x28, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e,
@@ -828,77 +839,80 @@ var file_v1_auth_service_proto_rawDesc = []byte{
0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77,
0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x04, 0x52,
- 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x32, 0x0a, 0x09, 0x75, 0x73, 0x65,
- 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x62,
- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x54,
- 0x79, 0x70, 0x65, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x32, 0x0a,
- 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e,
- 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55,
- 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c,
- 0x65, 0x2a, 0x54, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a,
- 0x15, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45,
- 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x53, 0x45, 0x52,
- 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x42, 0x4f, 0x54,
- 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x41, 0x43,
- 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10, 0x03, 0x2a, 0x48, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x52,
- 0x6f, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x52, 0x4f, 0x4c, 0x45,
- 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x09,
- 0x0a, 0x05, 0x4f, 0x57, 0x4e, 0x45, 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x42, 0x41,
- 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x45, 0x56, 0x45, 0x4c, 0x4f, 0x50, 0x45, 0x52, 0x10,
- 0x03, 0x32, 0xba, 0x06, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
- 0x65, 0x12, 0x5c, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x62,
- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73,
+ 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x31, 0x0a, 0x11, 0x69, 0x64, 0x65,
+ 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x06,
+ 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x10, 0x69, 0x64, 0x65, 0x6e,
+ 0x74, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x09,
+ 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32,
+ 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73,
+ 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65,
+ 0x12, 0x32, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x08, 0x20,
+ 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,
+ 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
+ 0x52, 0x6f, 0x6c, 0x65, 0x2a, 0x54, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65,
+ 0x12, 0x19, 0x0a, 0x15, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e,
+ 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55,
+ 0x53, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f,
+ 0x42, 0x4f, 0x54, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45,
+ 0x5f, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10, 0x03, 0x2a, 0x48, 0x0a, 0x08, 0x55, 0x73,
+ 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x52,
+ 0x4f, 0x4c, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10,
+ 0x00, 0x12, 0x09, 0x0a, 0x05, 0x4f, 0x57, 0x4e, 0x45, 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03,
+ 0x44, 0x42, 0x41, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x45, 0x56, 0x45, 0x4c, 0x4f, 0x50,
+ 0x45, 0x52, 0x10, 0x03, 0x32, 0xba, 0x06, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, 0x72,
+ 0x76, 0x69, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12,
+ 0x1b, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65,
+ 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62,
+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22,
+ 0x21, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12,
+ 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f,
+ 0x2a, 0x7d, 0x12, 0x66, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12,
+ 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69,
+ 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e,
+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73,
+ 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a,
+ 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x12,
+ 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x5f, 0x0a, 0x0a, 0x43, 0x72,
+ 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65,
+ 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1e, 0xda, 0x41, 0x04,
+ 0x75, 0x73, 0x65, 0x72, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x3a, 0x04, 0x75, 0x73, 0x65, 0x72,
+ 0x22, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x79, 0x0a, 0x0a, 0x55,
+ 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65,
+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73,
0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65,
- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x21, 0xda, 0x41,
- 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31,
+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x38, 0xda, 0x41,
+ 0x10, 0x75, 0x73, 0x65, 0x72, 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73,
+ 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, 0x17, 0x2f,
+ 0x76, 0x31, 0x2f, 0x7b, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73,
+ 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x67, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
+ 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
+ 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71,
+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
+ 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x21, 0xda, 0x41,
+ 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x2a, 0x12, 0x2f, 0x76, 0x31,
0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12,
- 0x66, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x1d, 0x2e, 0x62,
- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55,
- 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x62, 0x79,
- 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73,
- 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0xda, 0x41, 0x06,
- 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x12, 0x09, 0x2f, 0x76,
- 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x5f, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74,
- 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
- 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
- 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
- 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1e, 0xda, 0x41, 0x04, 0x75, 0x73, 0x65,
- 0x72, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x3a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x09, 0x2f,
- 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x79, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61,
- 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52,
- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x38, 0xda, 0x41, 0x10, 0x75, 0x73,
- 0x65, 0x72, 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3,
- 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, 0x17, 0x2f, 0x76, 0x31, 0x2f,
- 0x7b, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73,
- 0x2f, 0x2a, 0x7d, 0x12, 0x67, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65,
- 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
- 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
- 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x21, 0xda, 0x41, 0x04, 0x6e, 0x61,
- 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x2a, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e,
- 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x6b, 0x0a, 0x0c,
- 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x62,
- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6e, 0x64, 0x65, 0x6c,
- 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11,
- 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65,
- 0x72, 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x3a, 0x01, 0x2a, 0x22, 0x1b, 0x2f, 0x76,
- 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d,
- 0x3a, 0x75, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x59, 0x0a, 0x05, 0x4c, 0x6f, 0x67,
- 0x69, 0x6e, 0x12, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
- 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e,
- 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x69,
- 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02,
- 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x6c,
- 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x58, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x1a,
- 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67,
- 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f,
- 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70,
- 0x74, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f,
- 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x42, 0x11,
- 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76,
- 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x6b, 0x0a, 0x0c, 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12,
+ 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6e,
+ 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+ 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x55, 0x73, 0x65, 0x72, 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x3a, 0x01, 0x2a, 0x22,
+ 0x1b, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73,
+ 0x2f, 0x2a, 0x7d, 0x3a, 0x75, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x59, 0x0a, 0x05,
+ 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
+ 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+ 0x1a, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c,
+ 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3,
+ 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74,
+ 0x68, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x58, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x6f, 0x75,
+ 0x74, 0x12, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
+ 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
+ 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a,
+ 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x6c, 0x6f, 0x67, 0x6f, 0x75,
+ 0x74, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67,
+ 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
diff --git a/proto/v1/auth_service.proto b/proto/v1/auth_service.proto
index 07e7f184d0..04f83e4ecf 100644
--- a/proto/v1/auth_service.proto
+++ b/proto/v1/auth_service.proto
@@ -7,6 +7,7 @@ import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
+import "google/protobuf/wrappers.proto";
import "v1/common.proto";
@@ -163,10 +164,12 @@ message User {
string password = 5 [(google.api.field_behavior) = INPUT_ONLY];
- UserType user_type = 6;
+ string identity_provider = 6 [(google.api.field_behavior) = OUTPUT_ONLY];;
+
+ UserType user_type = 7;
// The user role will not be respected in the create user request, because the role is controlled by workspace owner.
- UserRole user_role = 7;
+ UserRole user_role = 8;
}
enum UserType {
diff --git a/server/api/v1/auth_service.go b/server/api/v1/auth_service.go
index c563c70e6c..67a00a381d 100644
--- a/server/api/v1/auth_service.go
+++ b/server/api/v1/auth_service.go
@@ -135,7 +135,6 @@ func (s *AuthService) CreateUser(ctx context.Context, request *v1pb.CreateUserRe
if _, err := s.store.CreateActivity(ctx, activityCreate); err != nil {
return nil, status.Errorf(codes.Internal, "failed to create activity, error: %v", err)
}
-
return convertToUser(user), nil
}
@@ -283,7 +282,8 @@ func convertToUser(user *store.UserMessage) *v1pb.User {
case api.ServiceAccount:
userType = v1pb.UserType_SERVICE_ACCOUNT
}
- return &v1pb.User{
+
+ convertedUser := &v1pb.User{
Name: fmt.Sprintf("%s%d", userNamePrefix, user.ID),
State: convertDeletedToState(user.MemberDeleted),
Email: user.Email,
@@ -291,6 +291,12 @@ func convertToUser(user *store.UserMessage) *v1pb.User {
UserType: userType,
UserRole: role,
}
+ if common.FeatureFlag(common.FeatureFlagNoop) {
+ if user.IdentityProviderResourceID != nil {
+ convertedUser.IdentityProvider = fmt.Sprintf("%s%s", identityProviderNamePrefix, *user.IdentityProviderResourceID)
+ }
+ }
+ return convertedUser
}
func convertUserRole(userRole v1pb.UserRole) api.Role {
diff --git a/store/principal.go b/store/principal.go
index f1254f4669..9273ad15ff 100644
--- a/store/principal.go
+++ b/store/principal.go
@@ -86,13 +86,18 @@ type UpdateUserMessage struct {
// UserMessage is the message for an user.
type UserMessage struct {
- ID int
- Email string
- Name string
- Type api.PrincipalType
- PasswordHash string
- Role api.Role
- MemberDeleted bool
+ ID int
+ Email string
+ Name string
+ Type api.PrincipalType
+ PasswordHash string
+ IdentityProviderResourceID *string
+ // IdentityProviderUserInfo is a raw json string from userinfo api response.
+ // e.g. for GitHub's authenticated user api, it looks like the following structure..
+ // https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
+ IdentityProviderUserInfo string
+ Role api.Role
+ MemberDeleted bool
}
// ListUsers list all users.
@@ -203,51 +208,108 @@ func (*Store) listUserImpl(ctx context.Context, tx *Tx, find *FindUserMessage) (
}
var userMessages []*UserMessage
- rows, err := tx.QueryContext(ctx, `
- SELECT
- principal.id AS user_id,
- principal.email,
- principal.name,
- principal.type,
- principal.password_hash,
- member.role,
- member.row_status AS row_status
- FROM principal
- LEFT JOIN member ON principal.id = member.principal_id
- WHERE `+strings.Join(where, " AND "),
- args...,
- )
- if err != nil {
- return nil, FormatError(err)
- }
- defer rows.Close()
- for rows.Next() {
- var userMessage UserMessage
- var role, rowStatus sql.NullString
- if err := rows.Scan(
- &userMessage.ID,
- &userMessage.Email,
- &userMessage.Name,
- &userMessage.Type,
- &userMessage.PasswordHash,
- &role,
- &rowStatus,
- ); err != nil {
+ if common.FeatureFlag(common.FeatureFlagNoop) {
+ rows, err := tx.QueryContext(ctx, `
+ SELECT
+ principal.id AS user_id,
+ principal.email,
+ principal.name,
+ principal.type,
+ principal.password_hash,
+ principal.idp_user_info,
+ member.role,
+ member.row_status AS row_status,
+ idp.resource_id AS idp_resource_id
+ FROM principal
+ LEFT JOIN member ON principal.id = member.principal_id
+ LEFT JOIN idp ON principal.idp_id = idp.id
+ WHERE `+strings.Join(where, " AND "),
+ args...,
+ )
+ if err != nil {
return nil, FormatError(err)
}
- if role.Valid {
- userMessage.Role = api.Role(role.String)
- } else if userMessage.ID == api.SystemBotID {
- userMessage.Role = api.Owner
- } else {
- userMessage.Role = api.Developer
+ defer rows.Close()
+ for rows.Next() {
+ var userMessage UserMessage
+ var role, rowStatus, idpResourceID sql.NullString
+ if err := rows.Scan(
+ &userMessage.ID,
+ &userMessage.Email,
+ &userMessage.Name,
+ &userMessage.Type,
+ &userMessage.PasswordHash,
+ &userMessage.IdentityProviderUserInfo,
+ &role,
+ &rowStatus,
+ &idpResourceID,
+ ); err != nil {
+ return nil, FormatError(err)
+ }
+ if role.Valid {
+ userMessage.Role = api.Role(role.String)
+ } else if userMessage.ID == api.SystemBotID {
+ userMessage.Role = api.Owner
+ } else {
+ userMessage.Role = api.Developer
+ }
+ if rowStatus.Valid {
+ userMessage.MemberDeleted = convertRowStatusToDeleted(rowStatus.String)
+ } else if userMessage.ID != api.SystemBotID {
+ userMessage.MemberDeleted = true
+ }
+ if idpResourceID.Valid {
+ userMessage.IdentityProviderResourceID = &idpResourceID.String
+ }
+ userMessages = append(userMessages, &userMessage)
}
- if rowStatus.Valid {
- userMessage.MemberDeleted = convertRowStatusToDeleted(rowStatus.String)
- } else if userMessage.ID != api.SystemBotID {
- userMessage.MemberDeleted = true
+ } else {
+ rows, err := tx.QueryContext(ctx, `
+ SELECT
+ principal.id AS user_id,
+ principal.email,
+ principal.name,
+ principal.type,
+ principal.password_hash,
+ member.role,
+ member.row_status AS row_status
+ FROM principal
+ LEFT JOIN member ON principal.id = member.principal_id
+ WHERE `+strings.Join(where, " AND "),
+ args...,
+ )
+ if err != nil {
+ return nil, FormatError(err)
+ }
+ defer rows.Close()
+ for rows.Next() {
+ var userMessage UserMessage
+ var role, rowStatus sql.NullString
+ if err := rows.Scan(
+ &userMessage.ID,
+ &userMessage.Email,
+ &userMessage.Name,
+ &userMessage.Type,
+ &userMessage.PasswordHash,
+ &role,
+ &rowStatus,
+ ); err != nil {
+ return nil, FormatError(err)
+ }
+ if role.Valid {
+ userMessage.Role = api.Role(role.String)
+ } else if userMessage.ID == api.SystemBotID {
+ userMessage.Role = api.Owner
+ } else {
+ userMessage.Role = api.Developer
+ }
+ if rowStatus.Valid {
+ userMessage.MemberDeleted = convertRowStatusToDeleted(rowStatus.String)
+ } else if userMessage.ID != api.SystemBotID {
+ userMessage.MemberDeleted = true
+ }
+ userMessages = append(userMessages, &userMessage)
}
- userMessages = append(userMessages, &userMessage)
}
return userMessages, nil
}
@@ -275,25 +337,36 @@ func (s *Store) CreateUser(ctx context.Context, create *UserMessage, creatorID i
if count == 0 {
role = api.Owner
}
+
+ set := []string{"creator_id", "updater_id", "email", "name", "type", "password_hash"}
+ args := []interface{}{creatorID, creatorID, create.Email, create.Name, create.Type, create.PasswordHash}
+ // Set idp fields into principal only when the related id is not null.
+ if common.FeatureFlag(common.FeatureFlagNoop) {
+ if create.IdentityProviderResourceID != nil {
+ identityProvider, err := s.GetIdentityProvider(ctx, &FindIdentityProviderMessage{
+ ResourceID: create.IdentityProviderResourceID,
+ })
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to find identity provider with resource id %s", *create.IdentityProviderResourceID)
+ }
+ set, args = append(set, "idp_id"), append(args, identityProvider.UID)
+ set, args = append(set, "idp_user_info"), append(args, create.IdentityProviderUserInfo)
+ }
+ }
+ placeholder := []string{}
+ for index := range set {
+ placeholder = append(placeholder, fmt.Sprintf("$%d", index+1))
+ }
+
var userID int
- if err := tx.QueryRowContext(ctx, `
+ if err := tx.QueryRowContext(ctx, fmt.Sprintf(`
INSERT INTO principal (
- creator_id,
- updater_id,
- email,
- name,
- type,
- password_hash
+ %s
)
- VALUES ($1, $2, $3, $4, $5, $6)
+ VALUES (%s)
RETURNING id
- `,
- creatorID,
- creatorID,
- create.Email,
- create.Name,
- create.Type,
- create.PasswordHash,
+ `, strings.Join(set, ","), strings.Join(placeholder, ",")),
+ args...,
).Scan(&userID); err != nil {
return nil, FormatError(err)
}
@@ -329,6 +402,10 @@ func (s *Store) CreateUser(ctx context.Context, create *UserMessage, creatorID i
PasswordHash: create.PasswordHash,
Role: role,
}
+ if common.FeatureFlag(common.FeatureFlagNoop) {
+ user.IdentityProviderResourceID = create.IdentityProviderResourceID
+ user.IdentityProviderUserInfo = create.IdentityProviderUserInfo
+ }
s.userIDCache.Store(user.ID, user)
s.userEmailCache.Store(user.Email, user)
return user, nil