Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: add expiration to MFA temporary tokens (#17901)
Danny Xuab75a7ab7c57
diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.goindex 8d86035526..5637d5a4d0 100644--- a/backend/api/v1/user_service.go+++ b/backend/api/v1/user_service.go@@ -6,6 +6,7 @@ import ("net/mail""regexp""strings"+ "time""connectrpc.com/connect""github.com/pkg/errors"@@ -13,6 +14,7 @@ import ("github.com/pquerna/otp/totp""golang.org/x/crypto/bcrypt""google.golang.org/protobuf/types/known/emptypb"+ "google.golang.org/protobuf/types/known/timestamppb""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/config"@@ -414,9 +416,16 @@ func (s *UserService) UpdateUser(ctx context.Context, request *connect.Request[vif user.MFAConfig.TempOtpSecret == "" || len(user.MFAConfig.TempRecoveryCodes) == 0 {return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("MFA is not setup yet"))}+ if isMFATempSecretExpired(user.MFAConfig) {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("MFA setup has expired, please regenerate the temporary secret"))+ }+ // Promote temp secrets to permanent and clear temp fields to prevent reusepatch.MFAConfig = &storepb.MFAConfig{- OtpSecret: user.MFAConfig.TempOtpSecret,- RecoveryCodes: user.MFAConfig.TempRecoveryCodes,+ OtpSecret: user.MFAConfig.TempOtpSecret,+ RecoveryCodes: user.MFAConfig.TempRecoveryCodes,+ TempOtpSecret: "",+ TempRecoveryCodes: nil,+ TempOtpSecretCreatedTime: nil,}} else {setting, err := s.store.GetWorkspaceGeneralSetting(ctx)@@ -461,6 +470,9 @@ func (s *UserService) UpdateUser(ctx context.Context, request *connect.Request[v// This flag is mainly used for validating OTP code when user setup MFA.// We only validate OTP code but not update user.if request.Msg.OtpCode != nil {+ if isMFATempSecretExpired(user.MFAConfig) {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("MFA setup has expired, please regenerate the temporary secret"))+ }isValid := validateWithCodeAndSecret(*request.Msg.OtpCode, user.MFAConfig.TempOtpSecret)if !isValid {return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid OTP code"))@@ -478,8 +490,9 @@ func (s *UserService) UpdateUser(ctx context.Context, request *connect.Request[vreturn nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to generate recovery codes, error: %v", err))}patch.MFAConfig = &storepb.MFAConfig{- TempOtpSecret: tempSecret,- TempRecoveryCodes: tempRecoveryCodes,+ TempOtpSecret: tempSecret,+ TempRecoveryCodes: tempRecoveryCodes,+ TempOtpSecretCreatedTime: timestamppb.Now(),}if user.MFAConfig != nil {patch.MFAConfig.OtpSecret = user.MFAConfig.OtpSecret@@ -685,6 +698,7 @@ func convertToUser(ctx context.Context, user *store.UserMessage) *v1pb.User {if currentUser, ok := GetUserFromContext(ctx); ok && currentUser.ID == user.ID {convertedUser.TempOtpSecret = user.MFAConfig.TempOtpSecretconvertedUser.TempRecoveryCodes = user.MFAConfig.TempRecoveryCodes+ convertedUser.TempOtpSecretCreatedTime = user.MFAConfig.TempOtpSecretCreatedTime}}return convertedUser@@ -778,8 +792,20 @@ func extractDomain(input string) string {const (// issuerName is the name of the issuer of the OTP token.issuerName = "Bytebase"+ // mfaTempSecretExpiration is the duration after which temporary MFA secrets expire.+ // Industry standard is 2-5 minutes for temporary MFA verification tokens.+ mfaTempSecretExpiration = 5 * time.Minute)+// isMFATempSecretExpired checks if the temporary MFA secret has expired.+func isMFATempSecretExpired(mfaConfig *storepb.MFAConfig) bool {+ if mfaConfig == nil || mfaConfig.TempOtpSecretCreatedTime == nil {+ return true+ }+ createdAt := mfaConfig.TempOtpSecretCreatedTime.AsTime()+ return time.Since(createdAt) > mfaTempSecretExpiration+}+// generateRandSecret generates a random secret for the given account name.func generateRandSecret(accountName string) (string, error) {key, err := totp.Generate(totp.GenerateOpts{diff --git a/backend/generated-go/store/user.pb.go b/backend/generated-go/store/user.pb.goindex 474dcdbb18..4fd70bd560 100644--- a/backend/generated-go/store/user.pb.go+++ b/backend/generated-go/store/user.pb.go@@ -89,8 +89,10 @@ type MFAConfig struct {RecoveryCodes []string `protobuf:"bytes,3,rep,name=recovery_codes,json=recoveryCodes,proto3" json:"recovery_codes,omitempty"`// The temp_recovery_codes are the temporary codes that will replace the recovery_codes in two-phase commits.TempRecoveryCodes []string `protobuf:"bytes,4,rep,name=temp_recovery_codes,json=tempRecoveryCodes,proto3" json:"temp_recovery_codes,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache+ // The temp_otp_secret_created_time is the timestamp when temp_otp_secret was created. Used to enforce expiration.+ TempOtpSecretCreatedTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=temp_otp_secret_created_time,json=tempOtpSecretCreatedTime,proto3" json:"temp_otp_secret_created_time,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *MFAConfig) Reset() {@@ -151,6 +153,13 @@ func (x *MFAConfig) GetTempRecoveryCodes() []string {return nil}+func (x *MFAConfig) GetTempOtpSecretCreatedTime() *timestamppb.Timestamp {+ if x != nil {+ return x.TempOtpSecretCreatedTime+ }+ return nil+}+type UserProfile struct {state protoimpl.MessageState `protogen:"open.v1"`LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=last_login_time,json=lastLoginTime,proto3" json:"last_login_time,omitempty"`@@ -216,13 +225,14 @@ var File_store_user_proto protoreflect.FileDescriptorconst file_store_user_proto_rawDesc = "" +"\n" +- "\x10store/user.proto\x12\x0ebytebase.store\x1a\x1fgoogle/protobuf/timestamp.proto\"\xa9\x01\n" ++ "\x10store/user.proto\x12\x0ebytebase.store\x1a\x1fgoogle/protobuf/timestamp.proto\"\x85\x02\n" +"\tMFAConfig\x12\x1d\n" +"\n" +"otp_secret\x18\x01 \x01(\tR\totpSecret\x12&\n" +"\x0ftemp_otp_secret\x18\x02 \x01(\tR\rtempOtpSecret\x12%\n" +"\x0erecovery_codes\x18\x03 \x03(\tR\rrecoveryCodes\x12.\n" +- "\x13temp_recovery_codes\x18\x04 \x03(\tR\x11tempRecoveryCodes\"\xc0\x01\n" ++ "\x13temp_recovery_codes\x18\x04 \x03(\tR\x11tempRecoveryCodes\x12Z\n" ++ "\x1ctemp_otp_secret_created_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\x18tempOtpSecretCreatedTime\"\xc0\x01\n" +"\vUserProfile\x12B\n" +"\x0flast_login_time\x18\x01 \x01(\v2\x1a.google.protobuf.TimestampR\rlastLoginTime\x12U\n" +"\x19last_change_password_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x16lastChangePasswordTime\x12\x16\n" +@@ -255,13 +265,14 @@ var file_store_user_proto_goTypes = []any{(*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp}var file_store_user_proto_depIdxs = []int32{- 3, // 0: bytebase.store.UserProfile.last_login_time:type_name -> google.protobuf.Timestamp- 3, // 1: bytebase.store.UserProfile.last_change_password_time:type_name -> google.protobuf.Timestamp- 2, // [2:2] is the sub-list for method output_type- 2, // [2:2] is the sub-list for method input_type- 2, // [2:2] is the sub-list for extension type_name- 2, // [2:2] is the sub-list for extension extendee- 0, // [0:2] is the sub-list for field type_name+ 3, // 0: bytebase.store.MFAConfig.temp_otp_secret_created_time:type_name -> google.protobuf.Timestamp+ 3, // 1: bytebase.store.UserProfile.last_login_time:type_name -> google.protobuf.Timestamp+ 3, // 2: bytebase.store.UserProfile.last_change_password_time:type_name -> google.protobuf.Timestamp+ 3, // [3:3] is the sub-list for method output_type+ 3, // [3:3] is the sub-list for method input_type+ 3, // [3:3] is the sub-list for extension type_name+ 3, // [3:3] is the sub-list for extension extendee+ 0, // [0:3] is the sub-list for field type_name}func init() { file_store_user_proto_init() }diff --git a/backend/generated-go/store/user_equal.pb.go b/backend/generated-go/store/user_equal.pb.goindex d6799641c3..9a7fc598bc 100644--- a/backend/generated-go/store/user_equal.pb.go+++ b/backend/generated-go/store/user_equal.pb.go@@ -32,6 +32,9 @@ func (x *MFAConfig) Equal(y *MFAConfig) bool {return false}}+ if p, q := x.TempOtpSecretCreatedTime, y.TempOtpSecretCreatedTime; (p == nil && q != nil) || (p != nil && (q == nil || p.Seconds != q.Seconds || p.Nanos != q.Nanos)) {+ return false+ }return true}diff --git a/backend/generated-go/v1/user_service.pb.go b/backend/generated-go/v1/user_service.pb.goindex 35ed1689dc..24622cc554 100644--- a/backend/generated-go/v1/user_service.pb.go+++ b/backend/generated-go/v1/user_service.pb.go@@ -629,6 +629,8 @@ type User struct {TempOtpSecret string `protobuf:"bytes,10,opt,name=temp_otp_secret,json=tempOtpSecret,proto3" json:"temp_otp_secret,omitempty"`// Temporary recovery codes used during MFA setup and regeneration.TempRecoveryCodes []string `protobuf:"bytes,11,rep,name=temp_recovery_codes,json=tempRecoveryCodes,proto3" json:"temp_recovery_codes,omitempty"`+ // Timestamp when temp_otp_secret was created. Used by frontend to show countdown timer.+ TempOtpSecretCreatedTime *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=temp_otp_secret_created_time,json=tempOtpSecretCreatedTime,proto3" json:"temp_otp_secret_created_time,omitempty"`// Should be a valid E.164 compliant phone number.// Could be empty.Phone string `protobuf:"bytes,12,opt,name=phone,proto3" json:"phone,omitempty"`@@ -741,6 +743,13 @@ func (x *User) GetTempRecoveryCodes() []string {return nil}+func (x *User) GetTempOtpSecretCreatedTime() *timestamppb.Timestamp {+ if x != nil {+ return x.TempOtpSecretCreatedTime+ }+ return nil+}+func (x *User) GetPhone() string {if x != nil {return x.Phone@@ -863,7 +872,7 @@ const file_v1_user_service_proto_rawDesc = "" +"\x11bytebase.com/UserR\x04name\"D\n" +"\x13UndeleteUserRequest\x12-\n" +"\x04name\x18\x01 \x01(\tB\x19\xe0A\x02\xfaA\x13\n" +- "\x11bytebase.com/UserR\x04name\"\xb6\x05\n" ++ "\x11bytebase.com/UserR\x04name\"\x92\x06\n" +"\x04User\x12\x17\n" +"\x04name\x18\x01 \x01(\tB\x03\xe0A\x03R\x04name\x12(\n" +"\x05state\x18\x02 \x01(\x0e2\x12.bytebase.v1.StateR\x05state\x12\x14\n" +@@ -877,7 +886,8 @@ const file_v1_user_service_proto_rawDesc = "" +"mfaEnabled\x12&\n" +"\x0ftemp_otp_secret\x18\n" +" \x01(\tR\rtempOtpSecret\x12.\n" +- "\x13temp_recovery_codes\x18\v \x03(\tR\x11tempRecoveryCodes\x12\x14\n" ++ "\x13temp_recovery_codes\x18\v \x03(\tR\x11tempRecoveryCodes\x12Z\n" ++ "\x1ctemp_otp_secret_created_time\x18\x0f \x01(\v2\x1a.google.protobuf.TimestampR\x18tempOtpSecretCreatedTime\x12\x14\n" +"\x05phone\x18\f \x01(\tR\x05phone\x123\n" +"\aprofile\x18\r \x01(\v2\x19.bytebase.v1.User.ProfileR\aprofile\x12\x1b\n" +"\x06groups\x18\x0e \x03(\tB\x03\xe0A\x03R\x06groups\x1a\xbc\x01\n" +@@ -945,30 +955,31 @@ var file_v1_user_service_proto_depIdxs = []int32{12, // 4: bytebase.v1.UpdateUserRequest.update_mask:type_name -> google.protobuf.FieldMask13, // 5: bytebase.v1.User.state:type_name -> bytebase.v1.State0, // 6: bytebase.v1.User.user_type:type_name -> bytebase.v1.UserType- 11, // 7: bytebase.v1.User.profile:type_name -> bytebase.v1.User.Profile- 14, // 8: bytebase.v1.User.Profile.last_login_time:type_name -> google.protobuf.Timestamp- 14, // 9: bytebase.v1.User.Profile.last_change_password_time:type_name -> google.protobuf.Timestamp- 1, // 10: bytebase.v1.UserService.GetUser:input_type -> bytebase.v1.GetUserRequest- 2, // 11: bytebase.v1.UserService.BatchGetUsers:input_type -> bytebase.v1.BatchGetUsersRequest- 15, // 12: bytebase.v1.UserService.GetCurrentUser:input_type -> google.protobuf.Empty- 4, // 13: bytebase.v1.UserService.ListUsers:input_type -> bytebase.v1.ListUsersRequest- 6, // 14: bytebase.v1.UserService.CreateUser:input_type -> bytebase.v1.CreateUserRequest- 7, // 15: bytebase.v1.UserService.UpdateUser:input_type -> bytebase.v1.UpdateUserRequest- 8, // 16: bytebase.v1.UserService.DeleteUser:input_type -> bytebase.v1.DeleteUserRequest- 9, // 17: bytebase.v1.UserService.UndeleteUser:input_type -> bytebase.v1.UndeleteUserRequest- 10, // 18: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User- 3, // 19: bytebase.v1.UserService.BatchGetUsers:output_type -> bytebase.v1.BatchGetUsersResponse- 10, // 20: bytebase.v1.UserService.GetCurrentUser:output_type -> bytebase.v1.User- 5, // 21: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse- 10, // 22: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User- 10, // 23: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User- 15, // 24: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty- 10, // 25: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User- 18, // [18:26] is the sub-list for method output_type- 10, // [10:18] is the sub-list for method input_type- 10, // [10:10] is the sub-list for extension type_name- 10, // [10:10] is the sub-list for extension extendee- 0, // [0:10] is the sub-list for field type_name+ 14, // 7: bytebase.v1.User.temp_otp_secret_created_time:type_name -> google.protobuf.Timestamp+ 11, // 8: bytebase.v1.User.profile:type_name -> bytebase.v1.User.Profile+ 14, // 9: bytebase.v1.User.Profile.last_login_time:type_name -> google.protobuf.Timestamp+ 14, // 10: bytebase.v1.User.Profile.last_change_password_time:type_name -> google.protobuf.Timestamp+ 1, // 11: bytebase.v1.UserService.GetUser:input_type -> bytebase.v1.GetUserRequest+ 2, // 12: bytebase.v1.UserService.BatchGetUsers:input_type -> bytebase.v1.BatchGetUsersRequest+ 15, // 13: bytebase.v1.UserService.GetCurrentUser:input_type -> google.protobuf.Empty+ 4, // 14: bytebase.v1.UserService.ListUsers:input_type -> bytebase.v1.ListUsersRequest+ 6, // 15: bytebase.v1.UserService.CreateUser:input_type -> bytebase.v1.CreateUserRequest+ 7, // 16: bytebase.v1.UserService.UpdateUser:input_type -> bytebase.v1.UpdateUserRequest+ 8, // 17: bytebase.v1.UserService.DeleteUser:input_type -> bytebase.v1.DeleteUserRequest+ 9, // 18: bytebase.v1.UserService.UndeleteUser:input_type -> bytebase.v1.UndeleteUserRequest+ 10, // 19: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User+ 3, // 20: bytebase.v1.UserService.BatchGetUsers:output_type -> bytebase.v1.BatchGetUsersResponse+ 10, // 21: bytebase.v1.UserService.GetCurrentUser:output_type -> bytebase.v1.User+ 5, // 22: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse+ 10, // 23: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User+ 10, // 24: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User+ 15, // 25: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty+ 10, // 26: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User+ 19, // [19:27] is the sub-list for method output_type+ 11, // [11:19] is the sub-list for method input_type+ 11, // [11:11] is the sub-list for extension type_name+ 11, // [11:11] is the sub-list for extension extendee+ 0, // [0:11] is the sub-list for field type_name}func init() { file_v1_user_service_proto_init() }diff --git a/backend/generated-go/v1/user_service_equal.pb.go b/backend/generated-go/v1/user_service_equal.pb.goindex b3dc0de560..aaa2cbc3e2 100644--- a/backend/generated-go/v1/user_service_equal.pb.go+++ b/backend/generated-go/v1/user_service_equal.pb.go@@ -232,6 +232,9 @@ func (x *User) Equal(y *User) bool {return false}}+ if p, q := x.TempOtpSecretCreatedTime, y.TempOtpSecretCreatedTime; (p == nil && q != nil) || (p != nil && (q == nil || p.Seconds != q.Seconds || p.Nanos != q.Nanos)) {+ return false+ }if x.Phone != y.Phone {return false}diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 4a156fac8e..ea5e62c1d0 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2513,7 +2513,10 @@"description": "Use an authenticator app from your phone to scan. If you are unable to scan, {action} instead.","enter-the-text": "enter the text"},- "verify-code": "Verify the code from the app"+ "verify-code": "Verify the code from the app",+ "time-remaining": "Time remaining: {time}",+ "expired-notice": "This setup session has expired. Please regenerate to continue.",+ "regenerate": "Regenerate"},"download-recovery-codes": {"self": "Download your recovery codes",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex b2d4ca631c..b3f2379db2 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2513,7 +2513,10 @@"description": "Usa una aplicación de autenticación de tu teléfono para escanear. Si no puedes escanear, {action} en su lugar.","enter-the-text": "ingresa el texto"},- "verify-code": "Verifica el código de la aplicación"+ "verify-code": "Verifica el código de la aplicación",+ "time-remaining": "Tiempo restante: {time}",+ "expired-notice": "Esta sesión de configuración ha expirado. Por favor, regenera para continuar.",+ "regenerate": "Regenerar"},"download-recovery-codes": {"self": "Descarga tus códigos de recuperación",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 4137a0b904..78b6f05192 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2513,7 +2513,10 @@"description": "携帯電話の認証アプリを使用してスキャンします。スキャンできない場合は、{action} を実行できます。","enter-the-text": "テキストを入力してください"},- "verify-code": "アプリケーションのコードを検証する"+ "verify-code": "アプリケーションのコードを検証する",+ "time-remaining": "残り時間: {time}",+ "expired-notice": "このセットアップセッションは期限切れになりました。続行するには再生成してください。",+ "regenerate": "再生成"},"download-recovery-codes": {"self": "リカバリーコードをダウンロード",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex cbbae187b4..c800d2a31b 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -2513,7 +2513,10 @@"description": "Sử dụng ứng dụng xác thực từ điện thoại của bạn để quét. Nếu bạn không thể quét, {action} thay thế.","enter-the-text": "nhập văn bản"},- "verify-code": "Xác minh mã từ ứng dụng"+ "verify-code": "Xác minh mã từ ứng dụng",+ "time-remaining": "Thời gian còn lại: {time}",+ "expired-notice": "Phiên thiết lập này đã hết hạn. Vui lòng tạo lại để tiếp tục.",+ "regenerate": "Tạo lại"},"download-recovery-codes": {"self": "Tải xuống mã khôi phục của bạn",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex f49aabfe80..8b8fbbfa73 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2513,7 +2513,10 @@"description": "使用您手机中的认证器应用程序进行扫描。如果您无法扫描,可以{action}。","enter-the-text": "输入文本"},- "verify-code": "验证应用程序的代码"+ "verify-code": "验证应用程序的代码",+ "time-remaining": "剩余时间:{time}",+ "expired-notice": "此设置会话已过期。请重新生成以继续。",+ "regenerate": "重新生成"},"download-recovery-codes": {"self": "下载恢复码",diff --git a/frontend/src/types/proto-es/v1/user_service_pb.d.ts b/frontend/src/types/proto-es/v1/user_service_pb.d.tsindex 00664fb33e..76d56f7790 100644--- a/frontend/src/types/proto-es/v1/user_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/user_service_pb.d.ts@@ -351,6 +351,13 @@ export declare type User = Message<"bytebase.v1.User"> & {*/tempRecoveryCodes: string[];+ /**+ * Timestamp when temp_otp_secret was created. Used by frontend to show countdown timer.+ *+ * @generated from field: google.protobuf.Timestamp temp_otp_secret_created_time = 15;+ */+ tempOtpSecretCreatedTime?: Timestamp;+/*** Should be a valid E.164 compliant phone number.* Could be empty.diff --git a/frontend/src/types/proto-es/v1/user_service_pb.js b/frontend/src/types/proto-es/v1/user_service_pb.jsindex 091812c15b..dfdd7dd546 100644--- a/frontend/src/types/proto-es/v1/user_service_pb.js+++ b/frontend/src/types/proto-es/v1/user_service_pb.js@@ -15,7 +15,7 @@ import { file_v1_common } from "./common_pb";* Describes the file v1/user_service.proto.*/export const file_v1_user_service = /*@__PURE__*/- fileDesc("ChV2MS91c2VyX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIjkKDkdldFVzZXJSZXF1ZXN0EicKBG5hbWUYASABKAlCGeBBAvpBEwoRYnl0ZWJhc2UuY29tL1VzZXIiQAoUQmF0Y2hHZXRVc2Vyc1JlcXVlc3QSKAoFbmFtZXMYASADKAlCGeBBAvpBEwoRYnl0ZWJhc2UuY29tL1VzZXIiOQoVQmF0Y2hHZXRVc2Vyc1Jlc3BvbnNlEiAKBXVzZXJzGAEgAygLMhEuYnl0ZWJhc2UudjEuVXNlciJfChBMaXN0VXNlcnNSZXF1ZXN0EhEKCXBhZ2Vfc2l6ZRgBIAEoBRISCgpwYWdlX3Rva2VuGAIgASgJEhQKDHNob3dfZGVsZXRlZBgDIAEoCBIOCgZmaWx0ZXIYBCABKAkiTgoRTGlzdFVzZXJzUmVzcG9uc2USIAoFdXNlcnMYASADKAsyES5ieXRlYmFzZS52MS5Vc2VyEhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSI5ChFDcmVhdGVVc2VyUmVxdWVzdBIkCgR1c2VyGAEgASgLMhEuYnl0ZWJhc2UudjEuVXNlckID4EECIuwBChFVcGRhdGVVc2VyUmVxdWVzdBIkCgR1c2VyGAEgASgLMhEuYnl0ZWJhc2UudjEuVXNlckID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIVCghvdHBfY29kZRgDIAEoCUgAiAEBEiIKGnJlZ2VuZXJhdGVfdGVtcF9tZmFfc2VjcmV0GAQgASgIEiEKGXJlZ2VuZXJhdGVfcmVjb3ZlcnlfY29kZXMYBSABKAgSFQoNYWxsb3dfbWlzc2luZxgGIAEoCEILCglfb3RwX2NvZGUiPAoRRGVsZXRlVXNlclJlcXVlc3QSJwoEbmFtZRgBIAEoCUIZ4EEC+kET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Q6jACmOowAYLT5JMCIDoBKiIbL3YxL3tuYW1lPXVzZXJzLyp9OnVuZGVsZXRlQjZaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjFiBnByb3RvMw", [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_google_protobuf_timestamp, file_v1_annotation, file_v1_common]);+ fileDesc("ChV2MS91c2VyX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIjkKDkdldFVzZXJSZXF1ZXN0EicKBG5hbWUYASABKAlCGeBBAvpBEwoRYnl0ZWJhc2UuY29tL1VzZXIiQAoUQmF0Y2hHZXRVc2Vyc1JlcXVlc3QSKAoFbmFtZXMYASADKAlCGeBBAvpBEwoRYnl0ZWJhc2UuY29tL1VzZXIiOQoVQmF0Y2hHZXRVc2Vyc1Jlc3BvbnNlEiAKBXVzZXJzGAEgAygLMhEuYnl0ZWJhc2UudjEuVXNlciJfChBMaXN0VXNlcnNSZXF1ZXN0EhEKCXBhZ2Vfc2l6ZRgBIAEoBRISCgpwYWdlX3Rva2VuGAIgASgJEhQKDHNob3dfZGVsZXRlZBgDIAEoCBIOCgZmaWx0ZXIYBCABKAkiTgoRTGlzdFVzZXJzUmVzcG9uc2USIAoFdXNlcnMYASADKAsyES5ieXRlYmFzZS52MS5Vc2VyEhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSI5ChFDcmVhdGVVc2VyUmVxdWVzdBIkCgR1c2VyGAEgASgLMhEuYnl0ZWJhc2UudjEuVXNlckID4EECIuwBChFVcGRhdGVVc2VyUmVxdWVzdBIkCgR1c2VyGAEgASgLMhEuYnl0ZWJhc2UudjEuVXNlckID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIVCghvdHBfY29kZRgDIAEoCUgAiAEBEiIKGnJlZ2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yMhcvdjEve3VzZXIubmFtZT11c2Vycy8qfRJvCgpEZWxldGVVc2VyEh4uYnl0ZWJhc2UudjEuRGVsZXRlVXNlclJlcXVlc3QaFi5nb29nbGUucHJvdG9idWYuRW1wdHkiKdpBBG5hbWWQ6jACmOowAYLT5JMCFCoSL3YxL3tuYW1lPXVzZXJzLyp9EnMKDFVuZGVsZXRlVXNlchIgLmJ5dGViYXNlLnYxLlVuZGVsZXRlVXNlclJlcXVlc3QaES5ieXRlYmFzZS52MS5Vc2VyIi6Q6jACmOowAYLT5JMCIDoBKiIbL3YxL3tuYW1lPXVzZXJzLyp9OnVuZGVsZXRlQjZaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjFiBnByb3RvMw", [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_google_protobuf_timestamp, file_v1_annotation, file_v1_common]);/*** Describes the message bytebase.v1.GetUserRequest.diff --git a/frontend/src/views/TwoFactorSetup.vue b/frontend/src/views/TwoFactorSetup.vueindex daf594900d..5fa4ff84d3 100644--- a/frontend/src/views/TwoFactorSetup.vue+++ b/frontend/src/views/TwoFactorSetup.vue@@ -22,6 +22,42 @@<p>{{ $t("two-factor.setup-steps.setup-auth-app.description") }}</p>+ <div+ :class="[+ 'w-full border rounded-md p-3',+ state.isExpired || state.isExpiringSoon+ ? 'bg-red-50 border-red-200'+ : 'bg-yellow-50 border-yellow-200',+ ]"+ >+ <div class="flex items-center justify-between">+ <p+ :class="[+ 'text-sm',+ state.isExpired || state.isExpiringSoon+ ? 'text-red-800'+ : 'text-yellow-800',+ ]"+ >+ ⏱️+ {{+ state.isExpired+ ? $t("two-factor.setup-steps.setup-auth-app.expired-notice")+ : $t("two-factor.setup-steps.setup-auth-app.time-remaining", {+ time: state.timeRemaining,+ })+ }}+ </p>+ <button+ v-if="state.isExpired"+ type="button"+ class="ml-3 px-3 py-1 text-sm font-medium text-white bg-blue-600 rounded hover:bg-blue-700"+ @click="handleRegenerateSecret"+ >+ {{ $t("two-factor.setup-steps.setup-auth-app.regenerate") }}+ </button>+ </div>+ </div><p class="text-2xl">{{ $t("two-factor.setup-steps.setup-auth-app.scan-qr-code.self") }}</p>@@ -84,7 +120,7 @@ import { create } from "@bufbuild/protobuf";import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";import type { ConnectError } from "@connectrpc/connect";import * as QRCode from "qrcode";-import { computed, onMounted, reactive, watch } from "vue";+import { computed, onMounted, onUnmounted, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { BBTextField } from "@/bbkit";@@ -110,6 +146,9 @@ interface LocalState {qrcodeDataUrl: string;otpCode: string;recoveryCodesDownloaded: boolean;+ timeRemaining: string;+ isExpired: boolean;+ isExpiringSoon: boolean;}const props = defineProps<{@@ -125,8 +164,13 @@ const state = reactive<LocalState>({qrcodeDataUrl: "",otpCode: "",recoveryCodesDownloaded: false,+ timeRemaining: "5:00",+ isExpired: false,+ isExpiringSoon: false,});const currentUser = useCurrentUserV1();+const MFA_TEMP_SECRET_EXPIRATION = 5 * 60 * 1000; // 5 minutes in milliseconds+let countdownInterval: ReturnType<typeof setInterval> | null = null;const stepTabList = computed(() => {return [@@ -137,14 +181,66 @@ const stepTabList = computed(() => {const allowNext = computed(() => {if (state.currentStep === SETUP_AUTH_APP_STEP) {- return state.otpCode.length >= 6;+ return state.otpCode.length >= 6 && !state.isExpired;} else {return state.recoveryCodesDownloaded;}});+const updateCountdown = () => {+ if (!currentUser.value.tempOtpSecretCreatedTime) {+ state.isExpired = true;+ state.timeRemaining = "0:00";+ return;+ }++ const createdAt =+ Number(currentUser.value.tempOtpSecretCreatedTime.seconds) * 1000;+ const now = Date.now();+ const elapsed = now - createdAt;+ const remaining = MFA_TEMP_SECRET_EXPIRATION - elapsed;++ if (remaining <= 0) {+ state.isExpired = true;+ state.timeRemaining = "0:00";+ state.isExpiringSoon = false;+ if (countdownInterval) {+ clearInterval(countdownInterval);+ countdownInterval = null;+ }+ } else {+ state.isExpired = false;+ const minutes = Math.floor(remaining / 60000);+ const seconds = Math.floor((remaining % 60000) / 1000);+ state.timeRemaining = `${minutes}:${seconds.toString().padStart(2, "0")}`;+ state.isExpiringSoon = remaining < 60000; // Less than 1 minute+ }+};++const startCountdown = () => {+ updateCountdown();+ if (countdownInterval) {+ clearInterval(countdownInterval);+ }+ countdownInterval = setInterval(updateCountdown, 1000);+};++const handleRegenerateSecret = async () => {+ state.otpCode = "";+ await regenerateTempMfaSecret();+ startCountdown();+};+onMounted(async () => {await regenerateTempMfaSecret();+ startCountdown();+});++onUnmounted(() => {+ if (countdownInterval) {+ clearInterval(countdownInterval);+ countdownInterval = null;+ }});const regenerateTempMfaSecret = async () => {diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 6f8323a5fd..61baf79b7b 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -14661,6 +14661,10 @@ components:items:type: stringdescription: Temporary recovery codes used during MFA setup and regeneration.+ tempOtpSecretCreatedTime:+ type: string+ description: Timestamp when temp_otp_secret was created. Used by frontend to show countdown timer.+ format: date-timephone:type: stringdescription: |-diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.mdindex 45ba63504e..f85739f872 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -5236,6 +5236,7 @@ MFAConfig is the MFA configuration for a user.| temp_otp_secret | [string](#string) | | The temp_otp_secret is the temporary secret key used to validate the OTP code and will replace the otp_secret in two-phase commits. || recovery_codes | [string](#string) | repeated | The recovery_codes are the codes that can be used to recover the account. || temp_recovery_codes | [string](#string) | repeated | The temp_recovery_codes are the temporary codes that will replace the recovery_codes in two-phase commits. |+| temp_otp_secret_created_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The temp_otp_secret_created_time is the timestamp when temp_otp_secret was created. Used to enforce expiration. |diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.htmlindex 7461832ff8..3b37cef016 100644--- a/proto/gen/grpc-doc/store/index.html+++ b/proto/gen/grpc-doc/store/index.html@@ -13611,6 +13611,13 @@ The indexes of the executed commands. </p></td><td><p>The temp_recovery_codes are the temporary codes that will replace the recovery_codes in two-phase commits. </p></td></tr>+ <tr>+ <td>temp_otp_secret_created_time</td>+ <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>+ <td></td>+ <td><p>The temp_otp_secret_created_time is the timestamp when temp_otp_secret was created. Used to enforce expiration. </p></td>+ </tr>+</tbody></table>diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 41e0e8a165..22e8dd4998 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -5070,6 +5070,7 @@ The user's `name` field is used to identify the user to update. Format: user| mfa_enabled | [bool](#bool) | | The mfa_enabled flag means if the user has enabled MFA. || temp_otp_secret | [string](#string) | | Temporary OTP secret used during MFA setup and regeneration. || temp_recovery_codes | [string](#string) | repeated | Temporary recovery codes used during MFA setup and regeneration. |+| temp_otp_secret_created_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | Timestamp when temp_otp_secret was created. Used by frontend to show countdown timer. || phone | [string](#string) | | Should be a valid E.164 compliant phone number. Could be empty. || profile | [User.Profile](#bytebase-v1-User-Profile) | | User profile metadata. || groups | [string](#string) | repeated | The groups for the user. Format: groups/{email} |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex f1a0dec83e..9b834176ce 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -14751,6 +14751,13 @@ Format: users/{user}. {user} is a system-generated unique ID. </p></td><td><p>Temporary recovery codes used during MFA setup and regeneration. </p></td></tr>+ <tr>+ <td>temp_otp_secret_created_time</td>+ <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>+ <td></td>+ <td><p>Timestamp when temp_otp_secret was created. Used by frontend to show countdown timer. </p></td>+ </tr>+<tr><td>phone</td><td><a href="#string">string</a></td>diff --git a/proto/store/store/user.proto b/proto/store/store/user.protoindex c6e8f628c3..411a1ed91e 100644--- a/proto/store/store/user.proto+++ b/proto/store/store/user.proto@@ -30,6 +30,9 @@ message MFAConfig {// The temp_recovery_codes are the temporary codes that will replace the recovery_codes in two-phase commits.repeated string temp_recovery_codes = 4;++ // The temp_otp_secret_created_time is the timestamp when temp_otp_secret was created. Used to enforce expiration.+ google.protobuf.Timestamp temp_otp_secret_created_time = 5;}message UserProfile {diff --git a/proto/v1/v1/user_service.proto b/proto/v1/v1/user_service.protoindex 6d5e0708fb..472cbf45c0 100644--- a/proto/v1/v1/user_service.proto+++ b/proto/v1/v1/user_service.proto@@ -259,6 +259,9 @@ message User {// Temporary recovery codes used during MFA setup and regeneration.repeated string temp_recovery_codes = 11;+ // Timestamp when temp_otp_secret was created. Used by frontend to show countdown timer.+ google.protobuf.Timestamp temp_otp_secret_created_time = 15;+// Should be a valid E.164 compliant phone number.// Could be empty.string phone = 12;