Skip to content

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

feat: sync user groups from SSO (#15762)

boojacka1966f30ad6a
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index 8e4e72cf26..bb8c1f6e21 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -408,6 +408,13 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.
return nil, status.Errorf(codes.Internal, "failed to undelete user: %v", err)
}
}
+ if userInfo.HasGroups {
+ // Sync user groups with the identity provider.
+ // The userInfo.Groups is the groups that the user belongs to in the identity provider.
+ if err := s.syncUserGroups(ctx, user, userInfo.Groups); err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to sync user groups: %v", err)
+ }
+ }
return user, nil
}
@@ -433,6 +440,13 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to create user, error: %v", err)
}
+ if userInfo.HasGroups {
+ // Sync user groups with the identity provider.
+ // The userInfo.Groups is the groups that the user belongs to in the identity provider.
+ if err := s.syncUserGroups(ctx, user, userInfo.Groups); err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to sync user groups: %v", err)
+ }
+ }
return newUser, nil
}
@@ -467,3 +481,51 @@ func (s *AuthService) challengeRecoveryCode(ctx context.Context, user *store.Use
func validateWithCodeAndSecret(code, secret string) bool {
return totp.Validate(code, secret)
}
+
+// syncUserGroups syncs the user groups with the given groups.
+// The given groups are the groups that the user belongs to in the identity provider.
+// Supported groups format: ["group1", "group2", ...], ["[email protected]", ...]
+func (s *AuthService) syncUserGroups(ctx context.Context, user *store.UserMessage, groups []string) error {
+ bbGroups, err := s.store.ListGroups(ctx, &store.FindGroupMessage{})
+ if err != nil {
+ return status.Errorf(codes.Internal, "failed to list groups: %v", err)
+ }
+
+ for _, bbGroup := range bbGroups {
+ var isMember bool
+ for _, group := range groups {
+ if bbGroup.Email == group || bbGroup.Title == group {
+ isMember = true
+ break
+ }
+ }
+ var isBBGroupMember bool
+ for _, member := range bbGroup.Payload.Members {
+ if member.Member == common.FormatUserUID(user.ID) {
+ isBBGroupMember = true
+ break
+ }
+ }
+ if isMember != isBBGroupMember {
+ if isMember {
+ // Add the user to the group.
+ bbGroup.Payload.Members = append(bbGroup.Payload.Members, &storepb.GroupMember{
+ Role: storepb.GroupMember_MEMBER,
+ Member: common.FormatUserUID(user.ID),
+ })
+ } else {
+ // Remove the user from the group.
+ bbGroup.Payload.Members = slices.DeleteFunc(bbGroup.Payload.Members, func(member *storepb.GroupMember) bool {
+ return member.Member == common.FormatUserUID(user.ID)
+ })
+ }
+ if _, err := s.store.UpdateGroup(ctx, bbGroup.Email, &store.UpdateGroupMessage{
+ Payload: bbGroup.Payload,
+ }); err != nil {
+ return status.Errorf(codes.Internal, "failed to update group %q: %v", bbGroup.Email, err)
+ }
+ }
+ }
+
+ return nil
+}
diff --git a/backend/api/v1/idp_service.go b/backend/api/v1/idp_service.go
index 3c44985693..5e60e7e551 100644
--- a/backend/api/v1/idp_service.go
+++ b/backend/api/v1/idp_service.go
@@ -412,8 +412,8 @@ func convertIdentityProviderConfigFromStore(identityProviderConfig *storepb.Iden
fieldMapping := v1pb.FieldMapping{
Identifier: v.FieldMapping.Identifier,
DisplayName: v.FieldMapping.DisplayName,
- Email: v.FieldMapping.Email,
Phone: v.FieldMapping.Phone,
+ Groups: v.FieldMapping.Groups,
}
return &v1pb.IdentityProviderConfig{
Config: &v1pb.IdentityProviderConfig_Oauth2Config{
@@ -434,8 +434,8 @@ func convertIdentityProviderConfigFromStore(identityProviderConfig *storepb.Iden
fieldMapping := v1pb.FieldMapping{
Identifier: v.FieldMapping.Identifier,
DisplayName: v.FieldMapping.DisplayName,
- Email: v.FieldMapping.Email,
Phone: v.FieldMapping.Phone,
+ Groups: v.FieldMapping.Groups,
}
oidcConfig := &v1pb.OIDCIdentityProviderConfig{
Issuer: v.Issuer,
@@ -467,8 +467,8 @@ func convertIdentityProviderConfigFromStore(identityProviderConfig *storepb.Iden
fieldMapping := v1pb.FieldMapping{
Identifier: v.FieldMapping.Identifier,
DisplayName: v.FieldMapping.DisplayName,
- Email: v.FieldMapping.Email,
Phone: v.FieldMapping.Phone,
+ Groups: v.FieldMapping.Groups,
}
return &v1pb.IdentityProviderConfig{
Config: &v1pb.IdentityProviderConfig_LdapConfig{
@@ -494,8 +494,8 @@ func convertIdentityProviderConfigToStore(identityProviderConfig *v1pb.IdentityP
fieldMapping := storepb.FieldMapping{
Identifier: v.FieldMapping.Identifier,
DisplayName: v.FieldMapping.DisplayName,
- Email: v.FieldMapping.Email,
Phone: v.FieldMapping.Phone,
+ Groups: v.FieldMapping.Groups,
}
return &storepb.IdentityProviderConfig{
Config: &storepb.IdentityProviderConfig_Oauth2Config{
@@ -516,8 +516,8 @@ func convertIdentityProviderConfigToStore(identityProviderConfig *v1pb.IdentityP
fieldMapping := storepb.FieldMapping{
Identifier: v.FieldMapping.Identifier,
DisplayName: v.FieldMapping.DisplayName,
- Email: v.FieldMapping.Email,
Phone: v.FieldMapping.Phone,
+ Groups: v.FieldMapping.Groups,
}
return &storepb.IdentityProviderConfig{
Config: &storepb.IdentityProviderConfig_OidcConfig{
@@ -536,8 +536,8 @@ func convertIdentityProviderConfigToStore(identityProviderConfig *v1pb.IdentityP
fieldMapping := storepb.FieldMapping{
Identifier: v.FieldMapping.Identifier,
DisplayName: v.FieldMapping.DisplayName,
- Email: v.FieldMapping.Email,
Phone: v.FieldMapping.Phone,
+ Groups: v.FieldMapping.Groups,
}
return &storepb.IdentityProviderConfig{
Config: &storepb.IdentityProviderConfig_LdapConfig{
diff --git a/backend/plugin/idp/ldap/ldap.go b/backend/plugin/idp/ldap/ldap.go
index 3787347383..56967750e4 100644
--- a/backend/plugin/idp/ldap/ldap.go
+++ b/backend/plugin/idp/ldap/ldap.go
@@ -157,7 +157,7 @@ func (p *IdentityProvider) Authenticate(username, password string) (*storepb.Ide
0,
false,
strings.ReplaceAll(p.config.UserFilter, "%s", username),
- []string{"dn", p.config.FieldMapping.Identifier, p.config.FieldMapping.DisplayName, p.config.FieldMapping.Email},
+ []string{"dn", p.config.FieldMapping.Identifier, p.config.FieldMapping.DisplayName},
nil,
),
)
@@ -181,6 +181,5 @@ func (p *IdentityProvider) Authenticate(username, password string) (*storepb.Ide
return &storepb.IdentityProviderUserInfo{
Identifier: identifier,
DisplayName: entry.GetAttributeValue(p.config.FieldMapping.DisplayName),
- Email: entry.GetAttributeValue(p.config.FieldMapping.Email),
}, nil
}
diff --git a/backend/plugin/idp/ldap/ldap_test.go b/backend/plugin/idp/ldap/ldap_test.go
index 31a4781f37..3ac3aa29d6 100644
--- a/backend/plugin/idp/ldap/ldap_test.go
+++ b/backend/plugin/idp/ldap/ldap_test.go
@@ -241,7 +241,6 @@ func TestIdentityProvider(t *testing.T) {
FieldMapping: &storepb.FieldMapping{
Identifier: "uid",
DisplayName: "displayName",
- Email: "mail",
},
},
)
@@ -253,7 +252,6 @@ func TestIdentityProvider(t *testing.T) {
wantUserInfo := &storepb.IdentityProviderUserInfo{
Identifier: testUID,
DisplayName: testDisplayName,
- Email: testMail,
}
assert.Equal(t, wantUserInfo, userInfo)
}
diff --git a/backend/plugin/idp/oauth2/oauth2.go b/backend/plugin/idp/oauth2/oauth2.go
index 90f798be63..2a09680f87 100644
--- a/backend/plugin/idp/oauth2/oauth2.go
+++ b/backend/plugin/idp/oauth2/oauth2.go
@@ -131,11 +131,6 @@ func (p *IdentityProvider) UserInfo(token string) (*storepb.IdentityProviderUser
if userInfo.DisplayName == "" {
userInfo.DisplayName = userInfo.Identifier
}
- if p.config.FieldMapping.Email != "" {
- if v, ok := idp.GetValueWithKey(claims, p.config.FieldMapping.Email).(string); ok {
- userInfo.Email = v
- }
- }
if p.config.FieldMapping.Phone != "" {
if v, ok := idp.GetValueWithKey(claims, p.config.FieldMapping.Phone).(string); ok {
// Only set phone if it's valid.
diff --git a/backend/plugin/idp/oauth2/oauth2_test.go b/backend/plugin/idp/oauth2/oauth2_test.go
index 2e3dad0717..67ad9eee0b 100644
--- a/backend/plugin/idp/oauth2/oauth2_test.go
+++ b/backend/plugin/idp/oauth2/oauth2_test.go
@@ -145,7 +145,6 @@ func TestIdentityProvider(t *testing.T) {
FieldMapping: &storepb.FieldMapping{
Identifier: "sub",
DisplayName: "name",
- Email: "email",
},
},
)
@@ -162,7 +161,6 @@ func TestIdentityProvider(t *testing.T) {
wantUserInfo := &storepb.IdentityProviderUserInfo{
Identifier: testSubject,
DisplayName: testName,
- Email: testEmail,
}
assert.Equal(t, wantUserInfo, userInfoResult)
}
@@ -198,7 +196,6 @@ func TestIdentityProvider_SelfSigned(t *testing.T) {
FieldMapping: &storepb.FieldMapping{
Identifier: "sub",
DisplayName: "name",
- Email: "email",
},
},
)
@@ -220,7 +217,6 @@ func TestIdentityProvider_SelfSigned(t *testing.T) {
FieldMapping: &storepb.FieldMapping{
Identifier: "sub",
DisplayName: "name",
- Email: "email",
},
SkipTlsVerify: true,
},
@@ -238,7 +234,6 @@ func TestIdentityProvider_SelfSigned(t *testing.T) {
wantUserInfo := &storepb.IdentityProviderUserInfo{
Identifier: testSubject,
DisplayName: testName,
- Email: testEmail,
}
assert.Equal(t, wantUserInfo, userInfoResult)
})
diff --git a/backend/plugin/idp/oidc/oidc.go b/backend/plugin/idp/oidc/oidc.go
index c2661a834b..eca1a72b14 100644
--- a/backend/plugin/idp/oidc/oidc.go
+++ b/backend/plugin/idp/oidc/oidc.go
@@ -141,11 +141,6 @@ func (p *IdentityProvider) UserInfo(ctx context.Context, token *oauth2.Token, no
if userInfo.DisplayName == "" {
userInfo.DisplayName = userInfo.Identifier
}
- if p.config.FieldMapping.Email != "" {
- if v, ok := idp.GetValueWithKey(claims, p.config.FieldMapping.Email).(string); ok {
- userInfo.Email = v
- }
- }
if p.config.FieldMapping.Phone != "" {
if v, ok := idp.GetValueWithKey(claims, p.config.FieldMapping.Phone).(string); ok {
// Only set phone if it's valid.
@@ -154,6 +149,18 @@ func (p *IdentityProvider) UserInfo(ctx context.Context, token *oauth2.Token, no
}
}
}
+ if p.config.FieldMapping.Groups != "" {
+ if v, ok := idp.GetValueWithKey(claims, p.config.FieldMapping.Groups).([]any); ok {
+ slog.Debug("User groups", slog.Any("groups", v))
+ userInfo.HasGroups = true
+ for _, group := range v {
+ // Only handle string type here.
+ if groupStr, ok := group.(string); ok {
+ userInfo.Groups = append(userInfo.Groups, groupStr)
+ }
+ }
+ }
+ }
return userInfo, nil
}
diff --git a/backend/plugin/idp/oidc/oidc_test.go b/backend/plugin/idp/oidc/oidc_test.go
index f11cc74f95..684eb7e0ca 100644
--- a/backend/plugin/idp/oidc/oidc_test.go
+++ b/backend/plugin/idp/oidc/oidc_test.go
@@ -189,9 +189,10 @@ func TestIdentityProvider(t *testing.T) {
)
userinfo, err := json.Marshal(
map[string]any{
- "sub": testSubject,
- "name": testName,
- "email": testEmail,
+ "sub": testSubject,
+ "name": testName,
+ "email": testEmail,
+ "groups": []any{"Dev", "Admin"},
},
)
require.NoError(t, err)
@@ -206,7 +207,7 @@ func TestIdentityProvider(t *testing.T) {
FieldMapping: &storepb.FieldMapping{
Identifier: "sub",
DisplayName: "name",
- Email: "email",
+ Groups: "groups",
},
},
)
@@ -222,7 +223,8 @@ func TestIdentityProvider(t *testing.T) {
wantUserInfo := &storepb.IdentityProviderUserInfo{
Identifier: testSubject,
DisplayName: testName,
- Email: testEmail,
+ Groups: []string{"Dev", "Admin"},
+ HasGroups: true,
}
assert.Equal(t, wantUserInfo, userInfo)
}
@@ -241,9 +243,10 @@ func TestIdentityProvider_SelfSigned(t *testing.T) {
)
userinfo, err := json.Marshal(
map[string]any{
- "sub": testSubject,
- "name": testName,
- "email": testEmail,
+ "sub": testSubject,
+ "name": testName,
+ "email": testEmail,
+ "groups": []any{"Dev", "Admin"},
},
)
require.NoError(t, err)
@@ -259,7 +262,7 @@ func TestIdentityProvider_SelfSigned(t *testing.T) {
FieldMapping: &storepb.FieldMapping{
Identifier: "sub",
DisplayName: "name",
- Email: "email",
+ Groups: "groups",
},
},
)
@@ -277,7 +280,7 @@ func TestIdentityProvider_SelfSigned(t *testing.T) {
FieldMapping: &storepb.FieldMapping{
Identifier: "sub",
DisplayName: "name",
- Email: "email",
+ Groups: "groups",
},
SkipTlsVerify: true,
},
@@ -294,7 +297,8 @@ func TestIdentityProvider_SelfSigned(t *testing.T) {
wantUserInfo := &storepb.IdentityProviderUserInfo{
Identifier: testSubject,
DisplayName: testName,
- Email: testEmail,
+ Groups: []string{"Dev", "Admin"},
+ HasGroups: true,
}
assert.Equal(t, wantUserInfo, userInfo)
})
diff --git a/frontend/src/components/SSO/IdentityProviderCreateForm.vue b/frontend/src/components/SSO/IdentityProviderCreateForm.vue
index 4a4a5846dd..d2b20f5eb6 100644
--- a/frontend/src/components/SSO/IdentityProviderCreateForm.vue
+++ b/frontend/src/components/SSO/IdentityProviderCreateForm.vue
@@ -576,9 +576,7 @@
placeholder="e.g. login"
/>
<div class="w-full flex flex-row justify-start items-center text-sm">
- <heroicons-outline:arrow-right
- class="mx-1 h-auto w-4 text-gray-300"
- />
+ <ArrowRightIcon class="mx-2 h-auto w-4 text-gray-300" />
<p class="flex flex-row justify-start items-center">
{{ $t("settings.sso.form.identifier") }}
<span class="text-red-600">*</span>
@@ -601,9 +599,7 @@
placeholder="e.g. name"
/>
<div class="w-full flex flex-row justify-start items-center text-sm">
- <heroicons-outline:arrow-right
- class="mx-1 h-auto w-4 text-gray-300"
- />
+ <ArrowRightIcon class="mx-2 h-auto w-4 text-gray-300" />
<p>
{{ $t("settings.sso.form.display-name") }}
</p>
@@ -617,14 +613,29 @@
placeholder="e.g. phone"
/>
<div class="w-full flex flex-row justify-start items-center text-sm">
- <heroicons-outline:arrow-right
- class="mx-1 h-auto w-4 text-gray-300"
- />
+ <ArrowRightIcon class="mx-2 h-auto w-4 text-gray-300" />
<p>
{{ $t("settings.sso.form.phone") }}
</p>
</div>
</div>
+ <div
+ v-if="state.type === IdentityProviderType.OIDC"
+ class="w-full grid grid-cols-[256px_1fr]"
+ >
+ <BBTextField
+ v-model:value="state.fieldMapping.groups"
+ :disabled="!allowEdit"
+ class="mt-1 w-full"
+ placeholder="e.g. groups"
+ />
+ <div class="w-full flex flex-row justify-start items-center text-sm">
+ <ArrowRightIcon class="mx-2 h-auto w-4 text-gray-300" />
+ <p>
+ {{ $t("settings.sso.form.groups") }}
+ </p>
+ </div>
+ </div>
<div class="mt-4">
<NButton
v-if="!isDeleted"
@@ -698,6 +709,7 @@
<script lang="ts" setup>
import { cloneDeep, head, isEqual } from "lodash-es";
+import { ArrowRightIcon } from "lucide-vue-next";
import {
NRadioGroup,
NCheckbox,
@@ -884,8 +896,8 @@ const identityProviderTemplateList = computed(
fieldMapping: {
identifier: "email",
displayName: "name",
- email: "",
phone: "",
+ groups: "",
},
},
},
@@ -907,8 +919,8 @@ const identityProviderTemplateList = computed(
fieldMapping: {
identifier: "email",
displayName: "name",
- email: "",
phone: "",
+ groups: "",
},
},
},
@@ -930,8 +942,8 @@ const identityProviderTemplateList = computed(
fieldMapping: {
identifier: "email",
displayName: "name",
- email: "",
phone: "",
+ groups: "",
},
},
},
@@ -955,8 +967,8 @@ const identityProviderTemplateList = computed(
fieldMapping: {
identifier: "userPrincipalName",
displayName: "displayName",
- email: "",
phone: "",
+ groups: "",
},
},
},
@@ -978,8 +990,8 @@ const identityProviderTemplateList = computed(
fieldMapping: {
identifier: "",
displayName: "",
- email: "",
phone: "",
+ groups: "",
},
},
},
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 1267836ad1..7d7a1c33a1 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -451,6 +451,7 @@
"identifier-tips": "It should be a unique string. And if it is not in email format, it will be spliced with domain.",
"display-name": "Bytebase user's display name",
"phone": "Bytebase user's phone number",
+ "groups": "Bytebase user's groups",
"auth-style": {
"self": "Auth style",
"in-params": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 3b39835b83..32e10501eb 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -451,6 +451,7 @@
"identifier-tips": "Debe ser una cadena única. Y si no está en formato de correo electrónico, se empalmará con el dominio.",
"display-name": "Nombre para mostrar de usuario de Bytebase",
"phone": "Número de teléfono de usuario de Bytebase",
+ "groups": "Grupos de usuarios de Bytebase",
"auth-style": {
"self": "Estilo de autenticación",
"in-params": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 075dc14f7e..402add0ff2 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -451,6 +451,7 @@
"identifier-tips": "電子メールは一意である必要があります。実際の値がメールボックス形式でない場合は、ドメインと連結されます。",
"display-name": "バイトベースユーザーのニックネーム",
"phone": "Bytebase ユーザーの携帯電話番号",
+ "groups": "Bytebaseユーザーグループ",
"auth-style": {
"self": "認証パラメータの引き渡し方法",
"in-params": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 4440973095..fd2d69e191 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -451,6 +451,7 @@
"identifier-tips": "Nó phải là một chuỗi duy nhất. Và nếu nó không ở định dạng email, nó sẽ được nối với tên miền.",
"display-name": "Tên hiển thị của người dùng Bytebase",
"phone": "Số điện thoại của người dùng Bytebase",
+ "groups": "Nhóm người dùng Bytebase",
"auth-style": {
"self": "Kiểu xác thực",
"in-params": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 4dc3adca0c..9314c5c558 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -451,6 +451,7 @@
"identifier-tips": "邮箱应该具有唯一性。如果实际值不是邮箱格式,将会和 domain 进行拼接。",
"display-name": "Bytebase 用户的昵称",
"phone": "Bytebase 用户的手机号",
+ "groups": "Bytebase 用户的群组",
"auth-style": {
"self": "认证参数传递方式",
"in-params": {
diff --git a/frontend/src/types/proto/store/idp.ts b/frontend/src/types/proto/store/idp.ts
index 36acf5b427..5634a4682e 100644
--- a/frontend/src/types/proto/store/idp.ts
+++ b/frontend/src/types/proto/store/idp.ts
@@ -205,21 +205,19 @@ export interface LDAPIdentityProviderConfig {
* FieldMapping saves the field names from user info API of identity provider.
* As we save all raw json string of user info response data into `principal.idp_user_info`,
* we can extract the relevant data based with `FieldMapping`.
- *
- * e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
- * Then the identifier of FieldMapping will be `login`, display_name will be `name`,
- * and email will be `email`.
- * reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
*/
export interface FieldMapping {
/** Identifier is the field name of the unique identifier in 3rd-party idp user info. Required. */
identifier: string;
/** DisplayName is the field name of display name in 3rd-party idp user info. Optional. */
displayName: string;
- /** Email is the field name of primary email in 3rd-party idp user info. Optional. */
- email: string;
/** Phone is the field name of primary phone in 3rd-party idp user info. Optional. */
phone: string;
+ /**
+ * Groups is the field name of groups in 3rd-party idp user info. Optional.
+ * Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ */
+ groups: string;
}
export interface IdentityProviderUserInfo {
@@ -227,10 +225,14 @@ export interface IdentityProviderUserInfo {
identifier: string;
/** DisplayName is the value of display name in 3rd-party idp user info. */
displayName: string;
- /** Email is the value of primary email in 3rd-party idp user info. */
- email: string;
/** Phone is the value of primary phone in 3rd-party idp user info. */
phone: string;
+ /**
+ * Groups is the value of groups in 3rd-party idp user info.
+ * Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ */
+ groups: string[];
+ hasGroups: boolean;
}
function createBaseIdentityProviderConfig(): IdentityProviderConfig {
@@ -902,7 +904,7 @@ export const LDAPIdentityProviderConfig: MessageFns<LDAPIdentityProviderConfig>
};
function createBaseFieldMapping(): FieldMapping {
- return { identifier: "", displayName: "", email: "", phone: "" };
+ return { identifier: "", displayName: "", phone: "", groups: "" };
}
export const FieldMapping: MessageFns<FieldMapping> = {
@@ -913,12 +915,12 @@ export const FieldMapping: MessageFns<FieldMapping> = {
if (message.displayName !== "") {
writer.uint32(18).string(message.displayName);
}
- if (message.email !== "") {
- writer.uint32(26).string(message.email);
- }
if (message.phone !== "") {
writer.uint32(34).string(message.phone);
}
+ if (message.groups !== "") {
+ writer.uint32(42).string(message.groups);
+ }
return writer;
},
@@ -945,20 +947,20 @@ export const FieldMapping: MessageFns<FieldMapping> = {
message.displayName = reader.string();
continue;
}
- case 3: {
- if (tag !== 26) {
+ case 4: {
+ if (tag !== 34) {
break;
}
- message.email = reader.string();
+ message.phone = reader.string();
continue;
}
- case 4: {
- if (tag !== 34) {
+ case 5: {
+ if (tag !== 42) {
break;
}
- message.phone = reader.string();
+ message.groups = reader.string();
continue;
}
}
@@ -974,8 +976,8 @@ export const FieldMapping: MessageFns<FieldMapping> = {
return {
identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
displayName: isSet(object.displayName) ? globalThis.String(object.displayName) : "",
- email: isSet(object.email) ? globalThis.String(object.email) : "",
phone: isSet(object.phone) ? globalThis.String(object.phone) : "",
+ groups: isSet(object.groups) ? globalThis.String(object.groups) : "",
};
},
@@ -987,12 +989,12 @@ export const FieldMapping: MessageFns<FieldMapping> = {
if (message.displayName !== "") {
obj.displayName = message.displayName;
}
- if (message.email !== "") {
- obj.email = message.email;
- }
if (message.phone !== "") {
obj.phone = message.phone;
}
+ if (message.groups !== "") {
+ obj.groups = message.groups;
+ }
return obj;
},
@@ -1003,14 +1005,14 @@ export const FieldMapping: MessageFns<FieldMapping> = {
const message = createBaseFieldMapping();
message.identifier = object.identifier ?? "";
message.displayName = object.displayName ?? "";
- message.email = object.email ?? "";
message.phone = object.phone ?? "";
+ message.groups = object.groups ?? "";
return message;
},
};
function createBaseIdentityProviderUserInfo(): IdentityProviderUserInfo {
- return { identifier: "", displayName: "", email: "", phone: "" };
+ return { identifier: "", displayName: "", phone: "", groups: [], hasGroups: false };
}
export const IdentityProviderUserInfo: MessageFns<IdentityProviderUserInfo> = {
@@ -1021,12 +1023,15 @@ export const IdentityProviderUserInfo: MessageFns<IdentityProviderUserInfo> = {
if (message.displayName !== "") {
writer.uint32(18).string(message.displayName);
}
- if (message.email !== "") {
- writer.uint32(26).string(message.email);
- }
if (message.phone !== "") {
writer.uint32(34).string(message.phone);
}
+ for (const v of message.groups) {
+ writer.uint32(42).string(v!);
+ }
+ if (message.hasGroups !== false) {
+ writer.uint32(48).bool(message.hasGroups);
+ }
return writer;
},
@@ -1053,20 +1058,28 @@ export const IdentityProviderUserInfo: MessageFns<IdentityProviderUserInfo> = {
message.displayName = reader.string();
continue;
}
- case 3: {
- if (tag !== 26) {
+ case 4: {
+ if (tag !== 34) {
break;
}
- message.email = reader.string();
+ message.phone = reader.string();
continue;
}
- case 4: {
- if (tag !== 34) {
+ case 5: {
+ if (tag !== 42) {
break;
}
- message.phone = reader.string();
+ message.groups.push(reader.string());
+ continue;
+ }
+ case 6: {
+ if (tag !== 48) {
+ break;
+ }
+
+ message.hasGroups = reader.bool();
continue;
}
}
@@ -1082,8 +1095,9 @@ export const IdentityProviderUserInfo: MessageFns<IdentityProviderUserInfo> = {
return {
identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
displayName: isSet(object.displayName) ? globalThis.String(object.displayName) : "",
- email: isSet(object.email) ? globalThis.String(object.email) : "",
phone: isSet(object.phone) ? globalThis.String(object.phone) : "",
+ groups: globalThis.Array.isArray(object?.groups) ? object.groups.map((e: any) => globalThis.String(e)) : [],
+ hasGroups: isSet(object.hasGroups) ? globalThis.Boolean(object.hasGroups) : false,
};
},
@@ -1095,12 +1109,15 @@ export const IdentityProviderUserInfo: MessageFns<IdentityProviderUserInfo> = {
if (message.displayName !== "") {
obj.displayName = message.displayName;
}
- if (message.email !== "") {
- obj.email = message.email;
- }
if (message.phone !== "") {
obj.phone = message.phone;
}
+ if (message.groups?.length) {
+ obj.groups = message.groups;
+ }
+ if (message.hasGroups !== false) {
+ obj.hasGroups = message.hasGroups;
+ }
return obj;
},
@@ -1111,8 +1128,9 @@ export const IdentityProviderUserInfo: MessageFns<IdentityProviderUserInfo> = {
const message = createBaseIdentityProviderUserInfo();
message.identifier = object.identifier ?? "";
message.displayName = object.displayName ?? "";
- message.email = object.email ?? "";
message.phone = object.phone ?? "";
+ message.groups = object.groups?.map((e) => e) || [];
+ message.hasGroups = object.hasGroups ?? false;
return message;
},
};
diff --git a/frontend/src/types/proto/v1/idp_service.ts b/frontend/src/types/proto/v1/idp_service.ts
index faf376dd93..b67eca35b1 100644
--- a/frontend/src/types/proto/v1/idp_service.ts
+++ b/frontend/src/types/proto/v1/idp_service.ts
@@ -326,21 +326,19 @@ export interface LDAPIdentityProviderConfig {
* FieldMapping saves the field names from user info API of identity provider.
* As we save all raw json string of user info response data into `principal.idp_user_info`,
* we can extract the relevant data based with `FieldMapping`.
- *
- * e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
- * Then the identifier of FieldMapping will be `login`, display_name will be `name`,
- * and email will be `email`.
- * reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
*/
export interface FieldMapping {
/** Identifier is the field name of the unique identifier in 3rd-party idp user info. Required. */
identifier: string;
- /** DisplayName is the field name of display name in 3rd-party idp user info. */
+ /** DisplayName is the field name of display name in 3rd-party idp user info. Optional. */
displayName: string;
- /** Email is the field name of primary email in 3rd-party idp user info. */
- email: string;
- /** Phone is the field name of primary phone in 3rd-party idp user info. */
+ /** Phone is the field name of primary phone in 3rd-party idp user info. Optional. */
phone: string;
+ /**
+ * Groups is the field name of groups in 3rd-party idp user info. Optional.
+ * Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ */
+ groups: string;
}
function createBaseGetIdentityProviderRequest(): GetIdentityProviderRequest {
@@ -1879,7 +1877,7 @@ export const LDAPIdentityProviderConfig: MessageFns<LDAPIdentityProviderConfig>
};
function createBaseFieldMapping(): FieldMapping {
- return { identifier: "", displayName: "", email: "", phone: "" };
+ return { identifier: "", displayName: "", phone: "", groups: "" };
}
export const FieldMapping: MessageFns<FieldMapping> = {
@@ -1890,12 +1888,12 @@ export const FieldMapping: MessageFns<FieldMapping> = {
if (message.displayName !== "") {
writer.uint32(18).string(message.displayName);
}
- if (message.email !== "") {
- writer.uint32(26).string(message.email);
- }
if (message.phone !== "") {
writer.uint32(34).string(message.phone);
}
+ if (message.groups !== "") {
+ writer.uint32(42).string(message.groups);
+ }
return writer;
},
@@ -1922,20 +1920,20 @@ export const FieldMapping: MessageFns<FieldMapping> = {
message.displayName = reader.string();
continue;
}
- case 3: {
- if (tag !== 26) {
+ case 4: {
+ if (tag !== 34) {
break;
}
- message.email = reader.string();
+ message.phone = reader.string();
continue;
}
- case 4: {
- if (tag !== 34) {
+ case 5: {
+ if (tag !== 42) {
break;
}
- message.phone = reader.string();
+ message.groups = reader.string();
continue;
}
}
@@ -1951,8 +1949,8 @@ export const FieldMapping: MessageFns<FieldMapping> = {
return {
identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
displayName: isSet(object.displayName) ? globalThis.String(object.displayName) : "",
- email: isSet(object.email) ? globalThis.String(object.email) : "",
phone: isSet(object.phone) ? globalThis.String(object.phone) : "",
+ groups: isSet(object.groups) ? globalThis.String(object.groups) : "",
};
},
@@ -1964,12 +1962,12 @@ export const FieldMapping: MessageFns<FieldMapping> = {
if (message.displayName !== "") {
obj.displayName = message.displayName;
}
- if (message.email !== "") {
- obj.email = message.email;
- }
if (message.phone !== "") {
obj.phone = message.phone;
}
+ if (message.groups !== "") {
+ obj.groups = message.groups;
+ }
return obj;
},
@@ -1980,8 +1978,8 @@ export const FieldMapping: MessageFns<FieldMapping> = {
const message = createBaseFieldMapping();
message.identifier = object.identifier ?? "";
message.displayName = object.displayName ?? "";
- message.email = object.email ?? "";
message.phone = object.phone ?? "";
+ message.groups = object.groups ?? "";
return message;
},
};
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 083bfe6d17..57425b8e7c 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -9689,22 +9689,19 @@ components:
description: Identifier is the field name of the unique identifier in 3rd-party idp user info. Required.
displayName:
type: string
- description: DisplayName is the field name of display name in 3rd-party idp user info.
- email:
- type: string
- description: Email is the field name of primary email in 3rd-party idp user info.
+ description: DisplayName is the field name of display name in 3rd-party idp user info. Optional.
phone:
type: string
- description: Phone is the field name of primary phone in 3rd-party idp user info.
+ description: Phone is the field name of primary phone in 3rd-party idp user info. Optional.
+ groups:
+ type: string
+ description: |-
+ Groups is the field name of groups in 3rd-party idp user info. Optional.
+ Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
description: |-
FieldMapping saves the field names from user info API of identity provider.
As we save all raw json string of user info response data into `principal.idp_user_info`,
we can extract the relevant data based with `FieldMapping`.
-
- e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
- Then the identifier of FieldMapping will be `login`, display_name will be `name`,
- and email will be `email`.
- reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
ForeignKeyMetadata:
type: object
properties:
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index d71d8cc2be..cb899bfe10 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -2105,18 +2105,13 @@ FieldMapping saves the field names from user info API of identity provider.
As we save all raw json string of user info response data into `principal.idp_user_info`,
we can extract the relevant data based with `FieldMapping`.
-e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
-Then the identifier of FieldMapping will be `login`, display_name will be `name`,
-and email will be `email`.
-reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
-
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| identifier | [string](#string) | | Identifier is the field name of the unique identifier in 3rd-party idp user info. Required. |
| display_name | [string](#string) | | DisplayName is the field name of display name in 3rd-party idp user info. Optional. |
-| email | [string](#string) | | Email is the field name of primary email in 3rd-party idp user info. Optional. |
| phone | [string](#string) | | Phone is the field name of primary phone in 3rd-party idp user info. Optional. |
+| groups | [string](#string) | | Groups is the field name of groups in 3rd-party idp user info. Optional. Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/ |
@@ -2150,8 +2145,9 @@ reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get
| ----- | ---- | ----- | ----------- |
| identifier | [string](#string) | | Identifier is the value of the unique identifier in 3rd-party idp user info. |
| display_name | [string](#string) | | DisplayName is the value of display name in 3rd-party idp user info. |
-| email | [string](#string) | | Email is the value of primary email in 3rd-party idp user info. |
| phone | [string](#string) | | Phone is the value of primary phone in 3rd-party idp user info. |
+| groups | [string](#string) | repeated | Groups is the value of groups in 3rd-party idp user info. Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/ |
+| has_groups | [bool](#bool) | | |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 4b3774f843..ba02630f27 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -5952,7 +5952,7 @@ Format: users/{userUID}. </p></td>
<h3 id="bytebase.store.FieldMapping">FieldMapping</h3>
- <p>FieldMapping saves the field names from user info API of identity provider.</p><p>As we save all raw json string of user info response data into `principal.idp_user_info`,</p><p>we can extract the relevant data based with `FieldMapping`.</p><p>e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.</p><p>Then the identifier of FieldMapping will be `login`, display_name will be `name`,</p><p>and email will be `email`.</p><p>reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user</p>
+ <p>FieldMapping saves the field names from user info API of identity provider.</p><p>As we save all raw json string of user info response data into `principal.idp_user_info`,</p><p>we can extract the relevant data based with `FieldMapping`.</p>
<table class="field-table">
@@ -5976,17 +5976,18 @@ Format: users/{userUID}. </p></td>
</tr>
<tr>
- <td>email</td>
+ <td>phone</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>Email is the field name of primary email in 3rd-party idp user info. Optional. </p></td>
+ <td><p>Phone is the field name of primary phone in 3rd-party idp user info. Optional. </p></td>
</tr>
<tr>
- <td>phone</td>
+ <td>groups</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>Phone is the field name of primary phone in 3rd-party idp user info. Optional. </p></td>
+ <td><p>Groups is the field name of groups in 3rd-party idp user info. Optional.
+Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/ </p></td>
</tr>
</tbody>
@@ -6059,17 +6060,25 @@ Format: users/{userUID}. </p></td>
</tr>
<tr>
- <td>email</td>
+ <td>phone</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>Email is the value of primary email in 3rd-party idp user info. </p></td>
+ <td><p>Phone is the value of primary phone in 3rd-party idp user info. </p></td>
</tr>
<tr>
- <td>phone</td>
+ <td>groups</td>
<td><a href="#string">string</a></td>
+ <td>repeated</td>
+ <td><p>Groups is the value of groups in 3rd-party idp user info.
+Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/ </p></td>
+ </tr>
+
+ <tr>
+ <td>has_groups</td>
+ <td><a href="#bool">bool</a></td>
<td></td>
- <td><p>Phone is the value of primary phone in 3rd-party idp user info. </p></td>
+ <td><p> </p></td>
</tr>
</tbody>
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 1f2d3ee830..a99f9616c8 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -6731,18 +6731,13 @@ FieldMapping saves the field names from user info API of identity provider.
As we save all raw json string of user info response data into `principal.idp_user_info`,
we can extract the relevant data based with `FieldMapping`.
-e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
-Then the identifier of FieldMapping will be `login`, display_name will be `name`,
-and email will be `email`.
-reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
-
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| identifier | [string](#string) | | Identifier is the field name of the unique identifier in 3rd-party idp user info. Required. |
-| display_name | [string](#string) | | DisplayName is the field name of display name in 3rd-party idp user info. |
-| email | [string](#string) | | Email is the field name of primary email in 3rd-party idp user info. |
-| phone | [string](#string) | | Phone is the field name of primary phone in 3rd-party idp user info. |
+| display_name | [string](#string) | | DisplayName is the field name of display name in 3rd-party idp user info. Optional. |
+| phone | [string](#string) | | Phone is the field name of primary phone in 3rd-party idp user info. Optional. |
+| groups | [string](#string) | | Groups is the field name of groups in 3rd-party idp user info. Optional. Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/ |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 0e3b72e6ad..3adb4d867d 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -18845,7 +18845,7 @@ Format: idps/{identity_provider} </p></td>
<h3 id="bytebase.v1.FieldMapping">FieldMapping</h3>
- <p>FieldMapping saves the field names from user info API of identity provider.</p><p>As we save all raw json string of user info response data into `principal.idp_user_info`,</p><p>we can extract the relevant data based with `FieldMapping`.</p><p>e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.</p><p>Then the identifier of FieldMapping will be `login`, display_name will be `name`,</p><p>and email will be `email`.</p><p>reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user</p>
+ <p>FieldMapping saves the field names from user info API of identity provider.</p><p>As we save all raw json string of user info response data into `principal.idp_user_info`,</p><p>we can extract the relevant data based with `FieldMapping`.</p>
<table class="field-table">
@@ -18865,21 +18865,22 @@ Format: idps/{identity_provider} </p></td>
<td>display_name</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>DisplayName is the field name of display name in 3rd-party idp user info. </p></td>
+ <td><p>DisplayName is the field name of display name in 3rd-party idp user info. Optional. </p></td>
</tr>
<tr>
- <td>email</td>
+ <td>phone</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>Email is the field name of primary email in 3rd-party idp user info. </p></td>
+ <td><p>Phone is the field name of primary phone in 3rd-party idp user info. Optional. </p></td>
</tr>
<tr>
- <td>phone</td>
+ <td>groups</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>Phone is the field name of primary phone in 3rd-party idp user info. </p></td>
+ <td><p>Groups is the field name of groups in 3rd-party idp user info. Optional.
+Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/ </p></td>
</tr>
</tbody>
diff --git a/proto/generated-go/store/idp.pb.go b/proto/generated-go/store/idp.pb.go
index 41b90d8516..b02b45d8f9 100644
--- a/proto/generated-go/store/idp.pb.go
+++ b/proto/generated-go/store/idp.pb.go
@@ -554,21 +554,17 @@ func (x *LDAPIdentityProviderConfig) GetFieldMapping() *FieldMapping {
// FieldMapping saves the field names from user info API of identity provider.
// As we save all raw json string of user info response data into `principal.idp_user_info`,
// we can extract the relevant data based with `FieldMapping`.
-//
-// e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
-// Then the identifier of FieldMapping will be `login`, display_name will be `name`,
-// and email will be `email`.
-// reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
type FieldMapping struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Identifier is the field name of the unique identifier in 3rd-party idp user info. Required.
Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
// DisplayName is the field name of display name in 3rd-party idp user info. Optional.
DisplayName string `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
- // Email is the field name of primary email in 3rd-party idp user info. Optional.
- Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
// Phone is the field name of primary phone in 3rd-party idp user info. Optional.
- Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
+ Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
+ // Groups is the field name of groups in 3rd-party idp user info. Optional.
+ // Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ Groups string `protobuf:"bytes,5,opt,name=groups,proto3" json:"groups,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -617,16 +613,16 @@ func (x *FieldMapping) GetDisplayName() string {
return ""
}
-func (x *FieldMapping) GetEmail() string {
+func (x *FieldMapping) GetPhone() string {
if x != nil {
- return x.Email
+ return x.Phone
}
return ""
}
-func (x *FieldMapping) GetPhone() string {
+func (x *FieldMapping) GetGroups() string {
if x != nil {
- return x.Phone
+ return x.Groups
}
return ""
}
@@ -637,10 +633,12 @@ type IdentityProviderUserInfo struct {
Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
// DisplayName is the value of display name in 3rd-party idp user info.
DisplayName string `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
- // Email is the value of primary email in 3rd-party idp user info.
- Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
// Phone is the value of primary phone in 3rd-party idp user info.
- Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
+ Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
+ // Groups is the value of groups in 3rd-party idp user info.
+ // Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ Groups []string `protobuf:"bytes,5,rep,name=groups,proto3" json:"groups,omitempty"`
+ HasGroups bool `protobuf:"varint,6,opt,name=has_groups,json=hasGroups,proto3" json:"has_groups,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -689,18 +687,25 @@ func (x *IdentityProviderUserInfo) GetDisplayName() string {
return ""
}
-func (x *IdentityProviderUserInfo) GetEmail() string {
+func (x *IdentityProviderUserInfo) GetPhone() string {
if x != nil {
- return x.Email
+ return x.Phone
}
return ""
}
-func (x *IdentityProviderUserInfo) GetPhone() string {
+func (x *IdentityProviderUserInfo) GetGroups() []string {
if x != nil {
- return x.Phone
+ return x.Groups
}
- return ""
+ return nil
+}
+
+func (x *IdentityProviderUserInfo) GetHasGroups() bool {
+ if x != nil {
+ return x.HasGroups
+ }
+ return false
}
var File_store_idp_proto protoreflect.FileDescriptor
@@ -745,21 +750,23 @@ const file_store_idp_proto_rawDesc = "" +
"\vuser_filter\x18\a \x01(\tR\n" +
"userFilter\x12+\n" +
"\x11security_protocol\x18\b \x01(\tR\x10securityProtocol\x12A\n" +
- "\rfield_mapping\x18\t \x01(\v2\x1c.bytebase.store.FieldMappingR\ffieldMapping\"}\n" +
+ "\rfield_mapping\x18\t \x01(\v2\x1c.bytebase.store.FieldMappingR\ffieldMapping\"\x85\x01\n" +
"\fFieldMapping\x12\x1e\n" +
"\n" +
"identifier\x18\x01 \x01(\tR\n" +
"identifier\x12!\n" +
"\fdisplay_name\x18\x02 \x01(\tR\vdisplayName\x12\x14\n" +
- "\x05email\x18\x03 \x01(\tR\x05email\x12\x14\n" +
- "\x05phone\x18\x04 \x01(\tR\x05phone\"\x89\x01\n" +
+ "\x05phone\x18\x04 \x01(\tR\x05phone\x12\x16\n" +
+ "\x06groups\x18\x05 \x01(\tR\x06groupsJ\x04\b\x03\x10\x04\"\xb0\x01\n" +
"\x18IdentityProviderUserInfo\x12\x1e\n" +
"\n" +
"identifier\x18\x01 \x01(\tR\n" +
"identifier\x12!\n" +
"\fdisplay_name\x18\x02 \x01(\tR\vdisplayName\x12\x14\n" +
- "\x05email\x18\x03 \x01(\tR\x05email\x12\x14\n" +
- "\x05phone\x18\x04 \x01(\tR\x05phone*^\n" +
+ "\x05phone\x18\x04 \x01(\tR\x05phone\x12\x16\n" +
+ "\x06groups\x18\x05 \x03(\tR\x06groups\x12\x1d\n" +
+ "\n" +
+ "has_groups\x18\x06 \x01(\bR\thasGroupsJ\x04\b\x03\x10\x04*^\n" +
"\x14IdentityProviderType\x12&\n" +
"\"IDENTITY_PROVIDER_TYPE_UNSPECIFIED\x10\x00\x12\n" +
"\n" +
diff --git a/proto/generated-go/v1/idp_service.pb.go b/proto/generated-go/v1/idp_service.pb.go
index de63ae83ce..a5c6e8c92f 100644
--- a/proto/generated-go/v1/idp_service.pb.go
+++ b/proto/generated-go/v1/idp_service.pb.go
@@ -1197,21 +1197,17 @@ func (x *LDAPIdentityProviderConfig) GetFieldMapping() *FieldMapping {
// FieldMapping saves the field names from user info API of identity provider.
// As we save all raw json string of user info response data into `principal.idp_user_info`,
// we can extract the relevant data based with `FieldMapping`.
-//
-// e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
-// Then the identifier of FieldMapping will be `login`, display_name will be `name`,
-// and email will be `email`.
-// reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
type FieldMapping struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Identifier is the field name of the unique identifier in 3rd-party idp user info. Required.
Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
- // DisplayName is the field name of display name in 3rd-party idp user info.
+ // DisplayName is the field name of display name in 3rd-party idp user info. Optional.
DisplayName string `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
- // Email is the field name of primary email in 3rd-party idp user info.
- Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
- // Phone is the field name of primary phone in 3rd-party idp user info.
- Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
+ // Phone is the field name of primary phone in 3rd-party idp user info. Optional.
+ Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"`
+ // Groups is the field name of groups in 3rd-party idp user info. Optional.
+ // Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ Groups string `protobuf:"bytes,5,opt,name=groups,proto3" json:"groups,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1260,16 +1256,16 @@ func (x *FieldMapping) GetDisplayName() string {
return ""
}
-func (x *FieldMapping) GetEmail() string {
+func (x *FieldMapping) GetPhone() string {
if x != nil {
- return x.Email
+ return x.Phone
}
return ""
}
-func (x *FieldMapping) GetPhone() string {
+func (x *FieldMapping) GetGroups() string {
if x != nil {
- return x.Phone
+ return x.Groups
}
return ""
}
@@ -1358,14 +1354,14 @@ const file_v1_idp_service_proto_rawDesc = "" +
"\vuser_filter\x18\a \x01(\tR\n" +
"userFilter\x12+\n" +
"\x11security_protocol\x18\b \x01(\tR\x10securityProtocol\x12>\n" +
- "\rfield_mapping\x18\t \x01(\v2\x19.bytebase.v1.FieldMappingR\ffieldMapping\"}\n" +
+ "\rfield_mapping\x18\t \x01(\v2\x19.bytebase.v1.FieldMappingR\ffieldMapping\"\x85\x01\n" +
"\fFieldMapping\x12\x1e\n" +
"\n" +
"identifier\x18\x01 \x01(\tR\n" +
"identifier\x12!\n" +
"\fdisplay_name\x18\x02 \x01(\tR\vdisplayName\x12\x14\n" +
- "\x05email\x18\x03 \x01(\tR\x05email\x12\x14\n" +
- "\x05phone\x18\x04 \x01(\tR\x05phone*^\n" +
+ "\x05phone\x18\x04 \x01(\tR\x05phone\x12\x16\n" +
+ "\x06groups\x18\x05 \x01(\tR\x06groupsJ\x04\b\x03\x10\x04*^\n" +
"\x14IdentityProviderType\x12&\n" +
"\"IDENTITY_PROVIDER_TYPE_UNSPECIFIED\x10\x00\x12\n" +
"\n" +
diff --git a/proto/store/idp.proto b/proto/store/idp.proto
index f1d3b0cdb1..6bfc99649b 100644
--- a/proto/store/idp.proto
+++ b/proto/store/idp.proto
@@ -89,37 +89,40 @@ message LDAPIdentityProviderConfig {
// FieldMapping saves the field names from user info API of identity provider.
// As we save all raw json string of user info response data into `principal.idp_user_info`,
// we can extract the relevant data based with `FieldMapping`.
-//
-// e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
-// Then the identifier of FieldMapping will be `login`, display_name will be `name`,
-// and email will be `email`.
-// reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
message FieldMapping {
+ reserved 3;
+
// Identifier is the field name of the unique identifier in 3rd-party idp user info. Required.
string identifier = 1;
// DisplayName is the field name of display name in 3rd-party idp user info. Optional.
string display_name = 2;
- // Email is the field name of primary email in 3rd-party idp user info. Optional.
- string email = 3;
-
// Phone is the field name of primary phone in 3rd-party idp user info. Optional.
string phone = 4;
+
+ // Groups is the field name of groups in 3rd-party idp user info. Optional.
+ // Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ string groups = 5;
}
message IdentityProviderUserInfo {
+ reserved 3;
+
// Identifier is the value of the unique identifier in 3rd-party idp user info.
string identifier = 1;
// DisplayName is the value of display name in 3rd-party idp user info.
string display_name = 2;
- // Email is the value of primary email in 3rd-party idp user info.
- string email = 3;
-
// Phone is the value of primary phone in 3rd-party idp user info.
string phone = 4;
+
+ // Groups is the value of groups in 3rd-party idp user info.
+ // Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ repeated string groups = 5;
+
+ bool has_groups = 6;
}
enum OAuth2AuthStyle {
diff --git a/proto/v1/idp_service.proto b/proto/v1/idp_service.proto
index 1a07cd1d62..db7ac6f086 100644
--- a/proto/v1/idp_service.proto
+++ b/proto/v1/idp_service.proto
@@ -287,23 +287,21 @@ message LDAPIdentityProviderConfig {
// FieldMapping saves the field names from user info API of identity provider.
// As we save all raw json string of user info response data into `principal.idp_user_info`,
// we can extract the relevant data based with `FieldMapping`.
-//
-// e.g. For GitHub authenticated user API, it will return `login`, `name` and `email` in response.
-// Then the identifier of FieldMapping will be `login`, display_name will be `name`,
-// and email will be `email`.
-// reference: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user
message FieldMapping {
+ reserved 3;
+
// Identifier is the field name of the unique identifier in 3rd-party idp user info. Required.
string identifier = 1;
- // DisplayName is the field name of display name in 3rd-party idp user info.
+ // DisplayName is the field name of display name in 3rd-party idp user info. Optional.
string display_name = 2;
- // Email is the field name of primary email in 3rd-party idp user info.
- string email = 3;
-
- // Phone is the field name of primary phone in 3rd-party idp user info.
+ // Phone is the field name of primary phone in 3rd-party idp user info. Optional.
string phone = 4;
+
+ // Groups is the field name of groups in 3rd-party idp user info. Optional.
+ // Mainly used for OIDC: https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/
+ string groups = 5;
}
enum OAuth2AuthStyle {