Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: switch vcs to use access token (#11224)
Danny Xu018b88ace72b
diff --git a/backend/api/gitops/webhook.go b/backend/api/gitops/webhook.goindex beb9118c56..27ea8abde2 100644--- a/backend/api/gitops/webhook.go+++ b/backend/api/gitops/webhook.go@@ -111,11 +111,7 @@ func (s *Service) RegisterWebhookRoutes(g *echo.Group) {repo := repositoryList[0]oauthContext := &common.OauthContext{- ClientID: repo.vcs.ApplicationID,- ClientSecret: repo.vcs.Secret,- AccessToken: repo.repository.AccessToken,- RefreshToken: repo.repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repo.repository.WebURL),+ AccessToken: repo.vcs.AccessToken,}baseVCSPushEvent, err := pushEvent.ToVCS()@@ -191,11 +187,7 @@ func (s *Service) RegisterWebhookRoutes(g *echo.Group) {}repo := repositoryList[0]oauthContext := &common.OauthContext{- ClientID: repo.vcs.ApplicationID,- ClientSecret: repo.vcs.Secret,- AccessToken: repo.repository.AccessToken,- RefreshToken: repo.repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repo.repository.WebURL),+ AccessToken: repo.vcs.AccessToken,}baseVCSPushEvent := pushEvent.ToVCS()@@ -260,11 +252,7 @@ func (s *Service) RegisterWebhookRoutes(g *echo.Group) {repo := repositoryList[0]oauthContext := &common.OauthContext{- ClientID: repo.vcs.ApplicationID,- ClientSecret: repo.vcs.Secret,- AccessToken: repo.repository.AccessToken,- RefreshToken: repo.repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repo.repository.WebURL),+ AccessToken: repo.vcs.AccessToken,}var commitList []vcs.Commit@@ -407,18 +395,9 @@ func (s *Service) RegisterWebhookRoutes(g *echo.Group) {return c.String(http.StatusOK, "No repository matched")}- setting, err := s.store.GetWorkspaceGeneralSetting(ctx)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find workspace setting").SetInternal(err)- }-+ repo := repositoryList[0]oauthContext := &common.OauthContext{- ClientID: repositoryList[0].vcs.ApplicationID,- ClientSecret: repositoryList[0].vcs.Secret,- AccessToken: repositoryList[0].repository.AccessToken,- RefreshToken: repositoryList[0].repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repositoryList[0].repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),+ AccessToken: repo.vcs.AccessToken,}if len(pushEvent.Resource.Commits) == 0 {@@ -634,12 +613,7 @@ func (s *Service) RegisterWebhookRoutes(g *echo.Group) {repo := repositoryList[0]oauthContext := &common.OauthContext{- ClientID: repo.vcs.ApplicationID,- ClientSecret: repo.vcs.Secret,- AccessToken: repo.repository.AccessToken,- RefreshToken: repo.repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repo.repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),+ AccessToken: repo.vcs.AccessToken,}prFiles, err := vcs.Get(repo.vcs.Type, vcs.ProviderConfig{}).ListPullRequestFile(diff --git a/backend/api/v1/acl_config.go b/backend/api/v1/acl_config.goindex b3c28c9f59..dfaf554f0f 100644--- a/backend/api/v1/acl_config.go+++ b/backend/api/v1/acl_config.go@@ -117,7 +117,6 @@ var methodPermissionMap = map[string]iam.Permission{v1pb.VCSProviderService_ListVCSProviders_FullMethodName: iam.PermissionVCSProvidersList,v1pb.VCSProviderService_GetVCSProvider_FullMethodName: iam.PermissionVCSProvidersGet,v1pb.VCSProviderService_CreateVCSProvider_FullMethodName: iam.PermissionVCSProvidersCreate,- v1pb.VCSProviderService_ExchangeToken_FullMethodName: iam.PermissionVCSProvidersExchangeToken,v1pb.VCSProviderService_UpdateVCSProvider_FullMethodName: iam.PermissionVCSProvidersUpdate,v1pb.VCSProviderService_DeleteVCSProvider_FullMethodName: iam.PermissionVCSProvidersDelete,v1pb.VCSProviderService_SearchVCSProviderProjects_FullMethodName: iam.PermissionVCSProvidersSearchProjects,diff --git a/backend/api/v1/acl_iam.go b/backend/api/v1/acl_iam.goindex 4147ceb74a..3b97a0632e 100644--- a/backend/api/v1/acl_iam.go+++ b/backend/api/v1/acl_iam.go@@ -240,7 +240,6 @@ func (in *ACLInterceptor) doIAMPermissionCheck(ctx context.Context, fullMethod sv1pb.VCSProviderService_ListVCSProviders_FullMethodName,v1pb.VCSProviderService_GetVCSProvider_FullMethodName,v1pb.VCSProviderService_CreateVCSProvider_FullMethodName,- v1pb.VCSProviderService_ExchangeToken_FullMethodName,v1pb.VCSProviderService_UpdateVCSProvider_FullMethodName,v1pb.VCSProviderService_DeleteVCSProvider_FullMethodName,v1pb.VCSProviderService_SearchVCSProviderProjects_FullMethodName,diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex a45794b83f..3a73ec87b8 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -504,8 +504,6 @@ func (s *ProjectService) UpdateProjectGitOpsInfo(ctx context.Context, request *vreturn nil, status.Errorf(codes.InvalidArgument, "invalid schema_path_template: %s", err.Error())}patch.SchemaPathTemplate = &request.ProjectGitopsInfo.SchemaPathTemplate- case "sheet_path_template":- patch.SheetPathTemplate = &request.ProjectGitopsInfo.SheetPathTemplatecase "enable_sql_review_ci":patch.EnableSQLReviewCI = &request.ProjectGitopsInfo.EnableSqlReviewCi}@@ -529,13 +527,9 @@ func (s *ProjectService) UpdateProjectGitOpsInfo(ctx context.Context, request *vnotFound, err := isBranchNotFound(ctx,vcs,- s.store,- repo.WebURL,- repo.AccessToken,- repo.RefreshToken,+ vcs.AccessToken,repo.ExternalID,*v,- setting.ExternalUrl,)if err != nil {return nil, status.Errorf(codes.Internal, "failed to check branch: %v", err.Error())@@ -666,12 +660,7 @@ func (s *ProjectService) UnsetProjectGitOpsInfo(ctx context.Context, request *v1ctx,// Need to get ApplicationID, Secret from vcs instead of repository.vcs since the latter is not composed.&common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repo.AccessToken,- RefreshToken: repo.RefreshToken,- Refresher: refreshTokenNoop(),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),+ AccessToken: vcs.AccessToken,},vcs.InstanceURL,repo.ExternalID,@@ -1083,13 +1072,7 @@ func (s *ProjectService) createProjectGitOpsInfo(ctx context.Context, request *vBaseDirectory: baseDir,FilePathTemplate: request.ProjectGitopsInfo.FilePathTemplate,SchemaPathTemplate: request.ProjectGitopsInfo.SchemaPathTemplate,- SheetPathTemplate: request.ProjectGitopsInfo.SheetPathTemplate,ExternalID: request.ProjectGitopsInfo.ExternalId,- AccessToken: request.ProjectGitopsInfo.AccessToken,- RefreshToken: request.ProjectGitopsInfo.RefreshToken,- }- if request.ProjectGitopsInfo.ExpiresTime != nil {- repositoryCreate.ExpiresTs = request.ProjectGitopsInfo.ExpiresTime.AsTime().Unix()}if repositoryCreate.BranchFilter == "" {@@ -1123,13 +1106,9 @@ func (s *ProjectService) createProjectGitOpsInfo(ctx context.Context, request *vnotFound, err := isBranchNotFound(ctx,vcs,- s.store,- repositoryCreate.WebURL,- repositoryCreate.AccessToken,- repositoryCreate.RefreshToken,+ vcs.AccessToken,repositoryCreate.ExternalID,repositoryCreate.BranchFilter,- setting.ExternalUrl,)if err != nil {return nil, status.Errorf(codes.Internal, "failed to check branch %s with error: %v", repositoryCreate.BranchFilter, err.Error())@@ -1170,7 +1149,7 @@ func (s *ProjectService) createProjectGitOpsInfo(ctx context.Context, request *vif gitopsWebhookURL == "" {gitopsWebhookURL = setting.ExternalUrl}- webhookID, err := createVCSWebhook(ctx, vcs.Type, repositoryCreate.WebhookEndpointID, secretToken, repositoryCreate.AccessToken, vcs.InstanceURL, repositoryCreate.ExternalID, gitopsWebhookURL)+ webhookID, err := createVCSWebhook(ctx, vcs.Type, repositoryCreate.WebhookEndpointID, secretToken, vcs.AccessToken, vcs.InstanceURL, repositoryCreate.ExternalID, gitopsWebhookURL)if err != nil {return nil, status.Errorf(codes.Internal, "failed to create webhook for project %s with error: %v", repositoryCreate.ProjectResourceID, err.Error())}@@ -1208,12 +1187,7 @@ func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *st}oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repository.AccessToken,- RefreshToken: repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),+ AccessToken: vcs.AccessToken,}if err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).UpsertEnvironmentVariable(@@ -1277,12 +1251,7 @@ func (s *ProjectService) setupVCSSQLReviewBranch(ctx context.Context, repositoryreturn nil, status.Errorf(codes.FailedPrecondition, "external url is required")}oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repository.AccessToken,- RefreshToken: repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, s.store, repository.WebURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),+ AccessToken: vcs.AccessToken,}branch, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).GetBranch(ctx,@@ -1375,7 +1344,7 @@ func setupVCSSQLReviewCIForBitBucket(sqlReviewEndpoint string,) error {bitbucketPlugin := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{})- if err := bitbucket.EnableSQLReviewCI(ctx, oauthContext, bitbucketPlugin.APIURL(vcs.InstanceURL), vcs.InstanceURL, repository.ExternalID); err != nil {+ if err := bitbucket.EnableSQLReviewCI(ctx, oauthContext, bitbucketPlugin.APIURL(vcs.InstanceURL), repository.ExternalID); err != nil {return errors.Wrapf(err, "failed to enable the pipeline")}@@ -3037,7 +3006,6 @@ func convertToProjectGitOpsInfo(repository *store.RepositoryMessage) *v1pb.ProjeBaseDirectory: repository.BaseDirectory,FilePathTemplate: repository.FilePathTemplate,SchemaPathTemplate: repository.SchemaPathTemplate,- SheetPathTemplate: repository.SheetPathTemplate,EnableSqlReviewCi: repository.EnableSQLReviewCI,WebhookEndpointId: repository.WebhookEndpointID,ExternalId: repository.ExternalID,@@ -3047,16 +3015,10 @@ func convertToProjectGitOpsInfo(repository *store.RepositoryMessage) *v1pb.Projefunc isBranchNotFound(ctx context.Context,vcs *store.VCSProviderMessage,- store *store.Store,- webURL, accessToken, refreshToken, externalID, branch, externalURL string,+ accessToken, externalID, branch string,) (bool, error) {oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: accessToken,- RefreshToken: refreshToken,- Refresher: utils.RefreshToken(ctx, store, webURL),- RedirectURL: fmt.Sprintf("%s/oauth/callback", externalURL),+ AccessToken: accessToken,}_, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).GetBranch(ctx,oauthContext,@@ -3141,8 +3103,6 @@ func createVCSWebhook(ctx context.Context, vcsType vcsplugin.Type, webhookEndpoictx,&common.OauthContext{AccessToken: accessToken,- // We use refreshTokenNoop() because the repository isn't created yet.- Refresher: refreshTokenNoop(),},instanceURL,externalRepoID,@@ -3153,10 +3113,3 @@ func createVCSWebhook(ctx context.Context, vcsType vcsplugin.Type, webhookEndpoi}return webhookID, nil}--// refreshToken is a no-op token refresher. It should be used when the repository isn't created yet.-func refreshTokenNoop() common.TokenRefresher {- return func(_, _ string, _ int64) error {- return nil- }-}diff --git a/backend/api/v1/vcs_provider_service.go b/backend/api/v1/vcs_provider_service.goindex 79e7461c67..cc39fd5f61 100644--- a/backend/api/v1/vcs_provider_service.go+++ b/backend/api/v1/vcs_provider_service.go@@ -4,13 +4,11 @@ import ("context""fmt""strings"- "time""github.com/pkg/errors""google.golang.org/grpc/codes""google.golang.org/grpc/status""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/plugin/vcs"@@ -91,16 +89,11 @@ func (s *VCSProviderService) UpdateVCSProvider(ctx context.Context, request *v1preturn nil, status.Errorf(codes.InvalidArgument, "title should not be empty")}update.Name = &request.VcsProvider.Title- case "application_id":- if request.VcsProvider.ApplicationId == "" {- return nil, status.Errorf(codes.InvalidArgument, "application_id should not be empty")- }- update.ApplicationID = &request.VcsProvider.ApplicationId- case "secret":- if request.VcsProvider.Secret == "" {+ case "access_token":+ if request.VcsProvider.AccessToken == "" {return nil, status.Errorf(codes.InvalidArgument, "secret should not be empty")}- update.Secret = &request.VcsProvider.Secret+ update.AccessToken = &request.VcsProvider.AccessToken}}@@ -162,12 +155,7 @@ func (s *VCSProviderService) SearchVCSProviderProjects(ctx context.Context, requapiExternalProjectList, err := vcs.Get(vcsProvider.Type, vcs.ProviderConfig{}).FetchAllRepositoryList(ctx,&common.OauthContext{- ClientID: vcsProvider.ApplicationID,- ClientSecret: vcsProvider.Secret,- AccessToken: request.AccessToken,- RefreshToken: request.RefreshToken,- RedirectURL: fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl),- Refresher: nil,+ AccessToken: vcsProvider.AccessToken,},vcsProvider.InstanceURL,)@@ -212,83 +200,6 @@ func (s *VCSProviderService) ListProjectGitOpsInfo(ctx context.Context, requestreturn resp, nil}-// ExchangeToken exchanges the OAuth token for VCS.-func (s *VCSProviderService) ExchangeToken(ctx context.Context, request *v1pb.ExchangeTokenRequest) (*v1pb.OAuthToken, error) {- var vcsType vcs.Type- var instanceURL string- var oauthExchange *common.OAuthExchange-- if request.ExchangeToken.Name == fmt.Sprintf("%s-", common.VCSProviderPrefix) {- tp, err := convertVCSProviderTypeToVCSType(request.ExchangeToken.Type)- if err != nil {- return nil, status.Errorf(codes.Internal, err.Error())- }- vcsType = tp-- instanceURL = request.ExchangeToken.InstanceUrl- oauthExchange = &common.OAuthExchange{- ClientID: request.ExchangeToken.ClientId,- ClientSecret: request.ExchangeToken.ClientSecret,- Code: request.ExchangeToken.Code,- }-- if instanceURL == "" {- return nil, status.Errorf(codes.InvalidArgument, "instance url is required")- }- if oauthExchange.ClientID == "" || oauthExchange.ClientSecret == "" || oauthExchange.Code == "" {- return nil, status.Errorf(codes.InvalidArgument, "client_id, client_secret and code is required")- }- } else {- vcsProvider, err := s.getVCS(ctx, request.ExchangeToken.Name)- if err != nil {- return nil, err- }-- vcsType = vcsProvider.Type- instanceURL = vcsProvider.InstanceURL- clientID := request.ExchangeToken.ClientId- clientSecret := request.ExchangeToken.ClientSecret- // Since we may not pass in ClientID and ClientSecret in the request, we will use the client ID and secret from VCS store even if it's stale.- // If it's stale, we should return better error messages and ask users to update the VCS secrets.- // https://sourcegraph.com/github.com/bytebase/bytebase/-/blob/frontend/src/components/RepositorySelectionPanel.vue?L77:8&subtree=true- // https://github.com/bytebase/bytebase/issues/1372- if clientID == "" || clientSecret == "" {- clientID = vcsProvider.ApplicationID- clientSecret = vcsProvider.Secret- }- oauthExchange = &common.OAuthExchange{- ClientID: clientID,- ClientSecret: clientSecret,- Code: request.ExchangeToken.Code,- }- }-- setting, err := s.store.GetWorkspaceGeneralSetting(ctx)- if err != nil {- return nil, status.Errorf(codes.Internal, "failed to find workspace setting with error: %v", err.Error())- }- if setting.ExternalUrl == "" {- return nil, status.Errorf(codes.FailedPrecondition, "external url is required")- }-- oauthExchange.RedirectURL = fmt.Sprintf("%s/oauth/callback", setting.ExternalUrl)- oauthToken, err := vcs.Get(vcsType, vcs.ProviderConfig{}).- ExchangeOAuthToken(- ctx,- instanceURL,- oauthExchange,- )- if err != nil {- return nil, status.Errorf(codes.Internal, "failed to exchange OAuth token with error: %v. Make sure %q matches your browser host. Note that if you are not using port 80 or 443, you should also specify the port such as --external-url=http://host:port", err.Error(), setting.ExternalUrl)- }-- return &v1pb.OAuthToken{- AccessToken: oauthToken.AccessToken,- RefreshToken: oauthToken.RefreshToken,- ExpiresTime: timestamppb.New(time.Unix(oauthToken.ExpiresTs, 0)),- }, nil-}-func (s *VCSProviderService) getVCS(ctx context.Context, name string) (*store.VCSProviderMessage, error) {vcsProviderUID, err := common.GetVCSProviderID(name)if err != nil {@@ -328,12 +239,10 @@ func convertToVCSProvider(vcsProvider *store.VCSProviderMessage) *v1pb.VCSProvid}return &v1pb.VCSProvider{- Name: fmt.Sprintf("%s%d", common.VCSProviderPrefix, vcsProvider.ID),- Title: vcsProvider.Name,- Type: tp,- Url: vcsProvider.InstanceURL,- ApiUrl: vcsProvider.APIURL,- ApplicationId: vcsProvider.ApplicationID,+ Name: fmt.Sprintf("%s%d", common.VCSProviderPrefix, vcsProvider.ID),+ Title: vcsProvider.Name,+ Type: tp,+ Url: vcsProvider.InstanceURL,}}@@ -347,16 +256,12 @@ func checkAndConvertToStoreVersionControl(vcsProvider *v1pb.VCSProvider) (*storeif vcsProvider.Url == "" {return nil, errors.Errorf("Empty VCSProvider.Url")}- if vcsProvider.ApplicationId == "" {- return nil, errors.Errorf("Empty VCSProvider.ApplicationId")- }- if vcsProvider.Secret == "" {+ if vcsProvider.AccessToken == "" {return nil, errors.Errorf("Empty VCSProvider.Secret")}storeVCSProvider := &store.VCSProviderMessage{- Name: vcsProvider.Title,- ApplicationID: vcsProvider.ApplicationId,- Secret: vcsProvider.Secret,+ Name: vcsProvider.Title,+ AccessToken: vcsProvider.AccessToken,}tp, err := convertVCSProviderTypeToVCSType(vcsProvider.Type)diff --git a/backend/common/oauth.go b/backend/common/oauth.goindex 2c07320721..fd1c8b497c 100644--- a/backend/common/oauth.go+++ b/backend/common/oauth.go@@ -5,12 +5,7 @@ type TokenRefresher func(token, refreshToken string, expiresTs int64) error// OauthContext encapsulated the oauth info.type OauthContext struct {- ClientID string- ClientSecret string- AccessToken string- RefreshToken string- RedirectURL string- Refresher TokenRefresher+ AccessToken string}// OAuthExchange encapsulated the exchange OAuth context.diff --git a/backend/migrator/migration/prod/2.15/0003##vcs_token.sql b/backend/migrator/migration/prod/2.15/0003##vcs_token.sqlnew file mode 100644index 0000000000..8c0b991008--- /dev/null+++ b/backend/migrator/migration/prod/2.15/0003##vcs_token.sql@@ -0,0 +1,7 @@+ALTER TABLE vcs DROP COLUMN application_id;+ALTER TABLE vcs DROP COLUMN secret;+ALTER TABLE vcs ADD COLUMN access_token TEXT NOT NULL DEFAULT '';+ALTER TABLE repository DROP COLUMN sheet_path_template;+ALTER TABLE repository DROP COLUMN access_token;+ALTER TABLE repository DROP COLUMN expires_ts;+ALTER TABLE repository DROP COLUMN refresh_token;diff --git a/backend/migrator/migration/prod/LATEST.sql b/backend/migrator/migration/prod/LATEST.sqlindex c4ee68b323..a0170d69af 100644--- a/backend/migrator/migration/prod/LATEST.sql+++ b/backend/migrator/migration/prod/LATEST.sql@@ -858,8 +858,7 @@ CREATE TABLE vcs (type TEXT NOT NULL CHECK (type IN ('GITLAB', 'GITHUB', 'BITBUCKET', 'AZURE_DEVOPS')),instance_url TEXT NOT NULL CHECK ((instance_url LIKE 'http://%' OR instance_url LIKE 'https://%') AND instance_url = rtrim(instance_url, '/')),api_url TEXT NOT NULL CHECK ((api_url LIKE 'http://%' OR api_url LIKE 'https://%') AND api_url = rtrim(api_url, '/')),- application_id TEXT NOT NULL,- secret TEXT NOT NULL+ access_token TEXT NOT NULL DEFAULT '');ALTER SEQUENCE vcs_id_seq RESTART WITH 101;@@ -905,8 +904,6 @@ CREATE TABLE repository (-- The file path template for storing the latest schema auto-generated by Bytebase after migration.-- If empty, then Bytebase won't auto generate it.schema_path_template TEXT NOT NULL DEFAULT '',- -- The file path template to match the script file for sheet.- sheet_path_template TEXT NOT NULL DEFAULT '',-- Repository id from the corresponding VCS provider.-- For GitLab, this is the project id. e.g. 123external_id TEXT NOT NULL,@@ -918,11 +915,7 @@ CREATE TABLE repository (-- Identify the target repository receiving the webhook event. This is a random string.webhook_endpoint_id TEXT NOT NULL,-- For GitLab, webhook request contains this in the 'X-Gitlab-Token" header and we compare it with the one stored in db to validate it sends to the expected endpoint.- webhook_secret_token TEXT NOT NULL,- -- access_token, expires_ts, refresh_token belongs to the user linking the project to the VCS repository.- access_token TEXT NOT NULL,- expires_ts BIGINT NOT NULL,- refresh_token TEXT NOT NULL+ webhook_secret_token TEXT NOT NULL);CREATE UNIQUE INDEX idx_repository_unique_project_id ON repository(project_id);diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 6922c10b7a..2c5a2b7d1a 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -230,5 +230,5 @@ func TestMigrationCompatibility(t *testing.T) {func TestGetCutoffVersion(t *testing.T) {releaseVersion, err := getProdCutoffVersion()require.NoError(t, err)- require.Equal(t, semver.MustParse("2.15.2"), releaseVersion)+ require.Equal(t, semver.MustParse("2.15.3"), releaseVersion)}diff --git a/backend/plugin/vcs/azure/azure.go b/backend/plugin/vcs/azure/azure.goindex 7156a59843..5d58055d18 100644--- a/backend/plugin/vcs/azure/azure.go+++ b/backend/plugin/vcs/azure/azure.go@@ -6,13 +6,11 @@ import ("context""encoding/json""fmt"- "io""log/slog""net/http""net/url""path/filepath""sort"- "strconv""strings""time"@@ -52,16 +50,6 @@ func (*Provider) APIURL(instanceURL string) string {return instanceURL}-// oauthResponse is a Azure DevOps OAuth response.-type oauthResponse struct {- AccessToken string `json:"access_token"`- RefreshToken string `json:"refresh_token"`- ExpiresIn string `json:"expires_in"`- TokenType string `json:"token_type"`- Error string `json:"error,omitempty"`- ErrorDescription string `json:"error_description,omitempty"`-}-// WebhookCreateConsumerInputs represents the consumer inputs for creating a webhook.type WebhookCreateConsumerInputs struct {URL string `json:"url"`@@ -160,63 +148,6 @@ type ServiceHookCodePushEvent struct {Resource ServiceHookCodePushEventResource `json:"resource"`}-// toVCSOAuthToken converts the response to *vcs.OAuthToken.-func (o oauthResponse) toVCSOAuthToken() (*vcs.OAuthToken, error) {- expiresIn, err := strconv.ParseInt(o.ExpiresIn, 10, 64)- if err != nil {- return nil, errors.Wrapf(err, `failed to parse expires_in "%s" with error: %v`, o.ExpiresIn, err.Error())- }- oauthToken := &vcs.OAuthToken{- AccessToken: o.AccessToken,- RefreshToken: o.RefreshToken,- ExpiresIn: expiresIn,- CreatedAt: time.Now().Unix(),- ExpiresTs: time.Now().Add(time.Duration(expiresIn) * time.Second).Unix(),- }-- return oauthToken, nil-}--// ExchangeOAuthToken exchanges OAuth content with the provided authorization code.-func (p *Provider) ExchangeOAuthToken(ctx context.Context, _ string, oauthExchange *common.OAuthExchange) (*vcs.OAuthToken, error) {- params := &url.Values{}- params.Set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer")- params.Set("client_assertion", oauthExchange.ClientSecret)- params.Set("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer")- params.Set("assertion", oauthExchange.Code)- params.Set("redirect_uri", oauthExchange.RedirectURL)- url := "https://app.vssps.visualstudio.com/oauth2/token"- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(params.Encode()))- if err != nil {- return nil, errors.Wrapf(err, "construct POST %s", url)- }-- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")-- resp, err := p.client.Do(req)- if err != nil {- return nil, errors.Wrap(err, "failed to exchange OAuth token")- }-- body, err := io.ReadAll(resp.Body)- if err != nil {- return nil, errors.Wrapf(err, "failed to read OAuth response body, code %v", resp.StatusCode)- }-- defer func() {- _ = resp.Body.Close()- }()-- oauthResp := new(oauthResponse)- if err := json.Unmarshal(body, oauthResp); err != nil {- return nil, errors.Wrapf(err, "failed to unmarshal OAuth response body, code %v", resp.StatusCode)- }- if oauthResp.Error != "" {- return nil, errors.Errorf("failed to exchange OAuth token, error: %v, error_description: %v", oauthResp.Error, oauthResp.ErrorDescription)- }- return oauthResp.toVCSOAuthToken()-}-// ChangesResponseChangeItem represents a Azure DevOps changes response change item.type ChangesResponseChangeItem struct {GitObjectType string `json:"gitObjectType"`@@ -249,14 +180,7 @@ func GetChangesByCommit(ctx context.Context, oauthCtx *common.OauthContext, extevalues := &url.Values{}values.Set("api-version", "7.0")url := fmt.Sprintf("%s/commits/%s/changes?%s", apiURL, url.PathEscape(commitID), values.Encode())- code, _, body, err := oauth.Get(ctx, client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, client, url, oauthCtx.AccessToken)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)}@@ -294,14 +218,7 @@ func (p *Provider) FetchCommitByID(ctx context.Context, oauthCtx *common.OauthCovalues := &url.Values{}values.Set("api-version", "7.0")url := fmt.Sprintf("%s/commits/%s?%s", apiURL, url.PathEscape(commitID), values.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)}@@ -371,14 +288,7 @@ func (p *Provider) getPaginatedDiffFileList(ctx context.Context, oauthCtx *commovalues.Set("diffCommonCommit", "false")url := fmt.Sprintf("%s/diffs/commits?%s", apiURL, values.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return nil, false, errors.Wrapf(err, "GET %s", url)}@@ -459,14 +369,7 @@ func (p *Provider) FetchAllRepositoryList(ctx context.Context, oauthCtx *common.for _, organization := range organizations {if err := func() error {url := fmt.Sprintf("https://dev.azure.com/%s/_apis/git/repositories?%s", url.PathEscape(organization), urlParams.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return errors.Wrapf(err, "GET %s", url)}@@ -521,14 +424,7 @@ func (p *Provider) getAuthenticatedProfilePublicAlias(ctx context.Context, oauthvalues.Set("api-version", "7.0")url := fmt.Sprintf("https://app.vssps.visualstudio.com/_apis/profile/profiles/me?%s", values.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return "", errors.Wrapf(err, "GET %s", url)}@@ -557,14 +453,7 @@ func (p *Provider) listOrganizationsForMember(ctx context.Context, oauthCtx *comurlParams.Set("api-version", "7.0")url := fmt.Sprintf("https://app.vssps.visualstudio.com/_apis/accounts?%s", urlParams.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)}@@ -607,14 +496,7 @@ func (p *Provider) FetchRepositoryFileList(ctx context.Context, oauthCtx *commonvalues.Set("recursive", "true")url := fmt.Sprintf("%s/trees/%s?%s", apiURL, url.PathEscape(ref), values.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)}@@ -674,14 +556,7 @@ func (p *Provider) getLatestCommitIDOnBranch(ctx context.Context, oauthCtx *commvalues.Set("searchCriteria.itemVersion.version", branchName)url := fmt.Sprintf("%s/commits?%s", apiURL, values.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return "", errors.Wrapf(err, "GET %s", url)}@@ -802,14 +677,7 @@ func (p *Provider) createOrUpdateFile(ctx context.Context, oauthCtx *common.Oautif err != nil {return errors.Wrapf(err, "failed to marshal create file request body, request body: %+v", requestBody)}- code, _, body, err := oauth.Post(ctx, p.client, url, &oauthCtx.AccessToken, bytes.NewReader(marshalBody), tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Post(ctx, p.client, url, oauthCtx.AccessToken, bytes.NewReader(marshalBody))if err != nil {return errors.Wrapf(err, "POST %s", url)}@@ -868,14 +736,7 @@ func (p *Provider) ReadFileMeta(ctx context.Context, oauthCtx *common.OauthConteValue []fileMetaResponseValue `json:"value"`}- code, _, body, err := oauth.Get(ctx, p.client, itemsURL, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, itemsURL, oauthCtx.AccessToken)if err != nil {return nil, errors.Wrapf(err, "GET %s", itemsURL)}@@ -905,14 +766,7 @@ func (p *Provider) ReadFileMeta(ctx context.Context, oauthCtx *common.OauthConteSize int64 `json:"size"`}- code, _, body, err = oauth.Get(ctx, p.client, blobURL, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err = oauth.Get(ctx, p.client, blobURL, oauthCtx.AccessToken)if err != nil {return nil, errors.Wrapf(err, "GET %s", blobURL)}@@ -968,14 +822,7 @@ func (p *Provider) ReadFileContent(ctx context.Context, oauthCtx *common.OauthCovalues.Set("versionDescriptor.version", refInfo.RefName)url := fmt.Sprintf("%s/items?%s", apiURL, values.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return "", errors.Wrapf(err, "GET %s", url)}@@ -1007,14 +854,7 @@ func (p *Provider) GetBranch(ctx context.Context, oauthCtx *common.OauthContext,urlParams.Set("api-version", "7.0")url := fmt.Sprintf("%s/stats/branches?%s", apiURL, urlParams.Encode())- code, _, body, err := oauth.Get(ctx, p.client, url, &oauthCtx.AccessToken, tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Get(ctx, p.client, url, oauthCtx.AccessToken)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)}@@ -1075,16 +915,8 @@ func (p *Provider) CreateBranch(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "GET %s", url)@@ -1124,15 +956,7 @@ func (p *Provider) ListPullRequestFile(ctx context.Context, oauthCtx *common.Oauctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -1203,16 +1027,8 @@ func (p *Provider) CreatePullRequest(ctx context.Context, oauthCtx *common.Oauthctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),)if err != nil {return nil, errors.Wrapf(err, "POST %s", url)@@ -1262,16 +1078,8 @@ func (p *Provider) CreateWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),)if err != nil {return "", errors.Wrapf(err, "failed to create webhook")@@ -1319,15 +1127,7 @@ func (p *Provider) DeleteWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return errors.Wrapf(err, "failed to send delete webhook request")@@ -1370,15 +1170,7 @@ func GetPushCommitsByPushID(ctx context.Context, oauthCtx *common.OauthContext,ctx,client,url,- &oauthCtx.AccessToken,- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "failed to get push commits")@@ -1442,14 +1234,7 @@ func QueryPullRequest(ctx context.Context, oauthCtx *common.OauthContext, reposireturn nil, errors.Wrap(err, "marshal pull request query input")}- code, _, body, err := oauth.Post(ctx, client, url, &oauthCtx.AccessToken, bytes.NewReader(marshalBody), tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ))+ code, _, body, err := oauth.Post(ctx, client, url, oauthCtx.AccessToken, bytes.NewReader(marshalBody))if err != nil {return nil, errors.Wrapf(err, "failed to query pull request")}@@ -1517,15 +1302,7 @@ func GetPullRequestCommits(ctx context.Context, oauthCtx *common.OauthContext, rctx,client,url,- &oauthCtx.AccessToken,- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -1546,69 +1323,6 @@ func GetPullRequestCommits(ctx context.Context, oauthCtx *common.OauthContext, rreturn r.Value, nil}-// oauthContext is the request context for OAuth.-type oauthContext struct {- ClientSecret string- RefreshToken string- RedirectURL string-}--type refreshOAuthTokenResponse struct {- AccessToken string `json:"access_token"`- ExpiresIn string `json:"expires_in"`- RefreshToken string `json:"refresh_token"`-}--// https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops#refresh-an-expired-access-token-func tokenRefresher(oauthCtx oauthContext, refresher common.TokenRefresher) oauth.TokenRefresher {- return func(ctx context.Context, client *http.Client, oldToken *string) error {- values := url.Values{}- values.Set("client_assertion_type", `urn:ietf:params:oauth:client-assertion-type:jwt-bearer`)- values.Set("client_assertion", oauthCtx.ClientSecret)- values.Set("grant_type", "refresh_token")- values.Set("assertion", oauthCtx.RefreshToken)- values.Set("redirect_uri", oauthCtx.RedirectURL)- encodedValues := values.Encode()-- url := "https://app.vssps.visualstudio.com/oauth2/token"- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(encodedValues))- if err != nil {- return errors.Wrapf(err, "construct POST %s", url)- }-- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")- req.Header.Set("Content-Length", strconv.Itoa(len(encodedValues)))- resp, err := client.Do(req)- if err != nil {- return errors.Wrapf(err, "failed to refresh OAuth token")- }-- body, err := io.ReadAll(resp.Body)- if err != nil {- return errors.Wrapf(err, "read body of POST %s", url)- }- defer resp.Body.Close()-- if resp.StatusCode != http.StatusOK {- return errors.Errorf("non-200 POST %s status code %d with body %q", url, resp.StatusCode, body)- }-- r := new(refreshOAuthTokenResponse)- if err := json.Unmarshal(body, r); err != nil {- return errors.Wrapf(err, "failed to unmarshal refresh OAuth token response body, code %v", resp.StatusCode)- }-- *oldToken = r.AccessToken-- var expiresIn int64- if r.ExpiresIn != "" {- expiresAt, _ := strconv.ParseInt(r.ExpiresIn, 10, 64)- expiresIn = time.Now().Unix() + expiresAt- }- return refresher(r.AccessToken, r.RefreshToken, expiresIn)- }-}-func getRepositoryAPIURL(repositoryID string) (string, error) {// By design, we encode the repository ID as <organization>/<projectID>/<repositoryID> for Azure DevOps.parts := strings.Split(repositoryID, "/")diff --git a/backend/plugin/vcs/azure/sql_review.go b/backend/plugin/vcs/azure/sql_review.goindex 12cc21ec19..b2e78b87b7 100644--- a/backend/plugin/vcs/azure/sql_review.go+++ b/backend/plugin/vcs/azure/sql_review.go@@ -149,16 +149,8 @@ func createSQLReviewPipeline(ctx context.Context, oauthCtx *common.OauthContext,ctx,client,apiURL,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),)if err != nil {return nil, errors.Wrapf(err, "POST %s", apiURL)@@ -222,16 +214,8 @@ func createSQLReviewBranchPolicy(ctx context.Context, oauthCtx *common.OauthContctx,client,apiURL,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- oauthContext{- RefreshToken: oauthCtx.RefreshToken,- ClientSecret: oauthCtx.ClientSecret,- RedirectURL: oauthCtx.RedirectURL,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "POST %s", apiURL)diff --git a/backend/plugin/vcs/bitbucket/bitbucket.go b/backend/plugin/vcs/bitbucket/bitbucket.goindex d7a4d00c6e..ffe22cc22f 100644--- a/backend/plugin/vcs/bitbucket/bitbucket.go+++ b/backend/plugin/vcs/bitbucket/bitbucket.go@@ -4,10 +4,8 @@ package bitbucketimport ("bytes""context"- "encoding/base64""encoding/json""fmt"- "io""mime/multipart""net/http""net/url"@@ -59,66 +57,6 @@ func (*Provider) APIURL(instanceURL string) string {return fmt.Sprintf("%s/2.0", instanceURL)}-// oauthResponse is a Bitbucket Cloud OAuth response.-type oauthResponse struct {- AccessToken string `json:"access_token"`- RefreshToken string `json:"refresh_token"`- ExpiresIn int64 `json:"expires_in"`- Error string `json:"error,omitempty"`- ErrorDescription string `json:"error_description,omitempty"`-}--// toVCSOAuthToken converts the response to *vcs.OAuthToken.-func (o oauthResponse) toVCSOAuthToken() *vcs.OAuthToken {- oauthToken := &vcs.OAuthToken{- AccessToken: o.AccessToken,- RefreshToken: o.RefreshToken,- ExpiresIn: o.ExpiresIn,- CreatedAt: time.Now().Unix(),- ExpiresTs: time.Now().Add(time.Duration(o.ExpiresIn) * time.Second).Unix(),- }- return oauthToken-}--// ExchangeOAuthToken exchanges OAuth content with the provided authorization code.-func (p *Provider) ExchangeOAuthToken(ctx context.Context, instanceURL string, oauthExchange *common.OAuthExchange) (*vcs.OAuthToken, error) {- params := &url.Values{}- params.Set("code", oauthExchange.Code)- params.Set("redirect_uri", oauthExchange.RedirectURL)- params.Set("grant_type", "authorization_code")- url := fmt.Sprintf("%s/site/oauth2/access_token", instanceURL)- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(params.Encode()))- if err != nil {- return nil, errors.Wrapf(err, "construct POST %s", url)- }-- digested := base64.StdEncoding.EncodeToString([]byte(oauthExchange.ClientID + ":" + oauthExchange.ClientSecret))- req.Header.Set("Authorization", "Basic "+digested)- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")-- resp, err := p.client.Do(req)- if err != nil {- return nil, errors.Wrap(err, "failed to exchange OAuth token")- }-- body, err := io.ReadAll(resp.Body)- if err != nil {- return nil, errors.Wrapf(err, "failed to read OAuth response body, code %v", resp.StatusCode)- }- defer func() {- _ = resp.Body.Close()- }()-- oauthResp := new(oauthResponse)- if err := json.Unmarshal(body, oauthResp); err != nil {- return nil, errors.Wrapf(err, "failed to unmarshal OAuth response body, code %v", resp.StatusCode)- }- if oauthResp.Error != "" {- return nil, errors.Errorf("failed to exchange OAuth token, error: %v, error_description: %v", oauthResp.Error, oauthResp.ErrorDescription)- }- return oauthResp.toVCSOAuthToken(), nil-}-// User represents a Bitbucket Cloud API response for a user.type User struct {DisplayName string `json:"display_name"`@@ -148,16 +86,7 @@ func (p *Provider) FetchCommitByID(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrap(err, "GET")@@ -240,16 +169,7 @@ func (p *Provider) fetchPaginatedDiffFileList(ctx context.Context, oauthCtx *comctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, "", errors.Wrapf(err, "GET %s", url)@@ -302,7 +222,7 @@ func (p *Provider) FetchAllRepositoryList(ctx context.Context, oauthCtx *common.for next != "" {var err errorvar repos []*Repository- repos, next, err = p.fetchPaginatedRepositoryList(ctx, oauthCtx, instanceURL, next)+ repos, next, err = p.fetchPaginatedRepositoryList(ctx, oauthCtx, next)if err != nil {return nil, errors.Wrap(err, "fetch paginated list")}@@ -326,21 +246,12 @@ func (p *Provider) FetchAllRepositoryList(ctx context.Context, oauthCtx *common.// fetchPaginatedRepositoryList fetches repositories in given page. It returns// the paginated results along with a string indicating the URL of the next page// (if exists).-func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, oauthCtx *common.OauthContext, instanceURL, url string) (repos []*Repository, next string, err error) {+func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, oauthCtx *common.OauthContext, url string) (repos []*Repository, next string, err error) {code, _, body, err := oauth.Get(ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, "", errors.Wrapf(err, "GET %s", url)@@ -402,7 +313,7 @@ func (p *Provider) FetchRepositoryFileList(ctx context.Context, oauthCtx *commonfor next != "" {var err errorvar treeEntries []*TreeEntry- treeEntries, next, err = p.fetchPaginatedRepositoryFileList(ctx, oauthCtx, instanceURL, next)+ treeEntries, next, err = p.fetchPaginatedRepositoryFileList(ctx, oauthCtx, next)if err != nil {return nil, errors.Wrap(err, "fetch paginated list")}@@ -424,21 +335,12 @@ func (p *Provider) FetchRepositoryFileList(ctx context.Context, oauthCtx *common// fetchPaginatedRepositoryFileList fetches files under a repository tree// recursively in given page. It returns the paginated results along with a// string indicating URL of the next page (if exists).-func (p *Provider) fetchPaginatedRepositoryFileList(ctx context.Context, oauthCtx *common.OauthContext, instanceURL, url string) (_ []*TreeEntry, next string, err error) {+func (p *Provider) fetchPaginatedRepositoryFileList(ctx context.Context, oauthCtx *common.OauthContext, url string) (_ []*TreeEntry, next string, err error) {code, _, body, err := oauth.Get(ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, "", errors.Wrapf(err, "GET %s", url)@@ -489,17 +391,8 @@ func (p *Provider) CreateFile(ctx context.Context, oauthCtx *common.OauthContextctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,&body,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),map[string]string{"Content-Type": w.FormDataContentType(),},@@ -536,16 +429,7 @@ func (p *Provider) ReadFileMeta(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -588,16 +472,7 @@ func (p *Provider) ReadFileContent(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return "", errors.Wrapf(err, "GET %s", url)@@ -636,16 +511,7 @@ func (p *Provider) GetBranch(ctx context.Context, oauthCtx *common.OauthContext,ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -700,17 +566,8 @@ func (p *Provider) CreateBranch(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "POST %s", url)@@ -809,17 +666,8 @@ func (p *Provider) CreatePullRequest(ctx context.Context, oauthCtx *common.Oauthctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return nil, errors.Wrapf(err, "POST %s", url)@@ -886,16 +734,7 @@ func (p *Provider) getPipelineVariable(ctx context.Context, oauthCtx *common.Oauctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -946,17 +785,8 @@ func (p *Provider) createPipelineVariable(ctx context.Context, oauthCtx *common.ctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "POST %s", url)@@ -990,17 +820,8 @@ func (p *Provider) updatePipelineVariable(ctx context.Context, oauthCtx *common.ctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)@@ -1087,17 +908,8 @@ func (p *Provider) CreateWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return "", errors.Wrapf(err, "POST %s", url)@@ -1133,17 +945,8 @@ func (p *Provider) PatchWebhook(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)@@ -1170,16 +973,7 @@ func (p *Provider) DeleteWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return errors.Wrapf(err, "DELETE %s", url)@@ -1196,61 +990,3 @@ func (p *Provider) DeleteWebhook(ctx context.Context, oauthCtx *common.OauthCont}return nil}--// oauthContext is the request context for refreshing OAuth token.-type oauthContext struct {- ClientID string- ClientSecret string- RefreshToken string- GrantType string-}--type refreshOAuthResponse struct {- AccessToken string `json:"access_token"`- RefreshToken string `json:"refresh_token"`- ExpiresIn int64 `json:"expires_in"`- // token_type, scope are not used.-}--func tokenRefresher(instanceURL string, oauthCtx oauthContext, refresher common.TokenRefresher) oauth.TokenRefresher {- return func(ctx context.Context, client *http.Client, oldToken *string) error {- params := &url.Values{}- params.Set("grant_type", "refresh_token")- params.Set("refresh_token", oauthCtx.RefreshToken)-- url := fmt.Sprintf("%s/site/oauth2/access_token", instanceURL)- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(params.Encode()))- if err != nil {- return errors.Wrapf(err, "construct POST %s", url)- }- digested := base64.StdEncoding.EncodeToString([]byte(oauthCtx.ClientID + ":" + oauthCtx.ClientSecret))- req.Header.Set("Authorization", "Basic "+digested)- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")-- resp, err := client.Do(req)- if err != nil {- return errors.Wrapf(err, "POST %s", url)- }-- body, err := io.ReadAll(resp.Body)- if err != nil {- return errors.Wrapf(err, "read body of POST %s", url)- }- defer func() { _ = resp.Body.Close() }()-- if resp.StatusCode != http.StatusOK {- return errors.Errorf("non-200 POST %s status code %d with body %q", url, resp.StatusCode, body)- }-- var r refreshOAuthResponse- if err = json.Unmarshal(body, &r); err != nil {- return errors.Wrapf(err, "unmarshal body from POST %s", url)- }-- // Update the old token to new value for retries.- *oldToken = r.AccessToken-- expireAt := time.Now().Add(time.Duration(r.ExpiresIn) * time.Second).Unix()- return refresher(r.AccessToken, r.RefreshToken, expireAt)- }-}diff --git a/backend/plugin/vcs/bitbucket/bitbucket_test.go b/backend/plugin/vcs/bitbucket/bitbucket_test.goindex 64ebb59b10..1a0775e03d 100644--- a/backend/plugin/vcs/bitbucket/bitbucket_test.go+++ b/backend/plugin/vcs/bitbucket/bitbucket_test.go@@ -12,55 +12,8 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/vcs"- "github.com/bytebase/bytebase/backend/plugin/vcs/internal/oauth")-func TestProvider_ExchangeOAuthToken(t *testing.T) {- p := newMockProvider(func(r *http.Request) (*http.Response, error) {- assert.Equal(t, "/site/oauth2/access_token", r.URL.Path)- assert.Equal(t, "Basic dGVzdF9jbGllbnRfaWQ6dGVzdF9jbGllbnRfc2VjcmV0", r.Header.Get("Authorization"))-- require.NoError(t, r.ParseForm())- assert.Equal(t, "authorization_code", r.PostForm.Get("grant_type"))- assert.Equal(t, "test_code", r.PostForm.Get("code"))- return &http.Response{- StatusCode: http.StatusOK,- Body: io.NopCloser(strings.NewReader(`-{- "access_token": "de6780bc506a0446309bd9362820ba8aed28aa506c71eedbe1c5c4f9dd350e54",- "token_type": "bearer",- "expires_in": 3600,- "refresh_token": "8257e65c97202ed1726cf9571600918f3bffb2544b26e00a61df9897668c33a1"-}-`)),- }, nil- },- )-- ctx := context.Background()- got, err := p.ExchangeOAuthToken(ctx, "",- &common.OAuthExchange{- ClientID: "test_client_id",- ClientSecret: "test_client_secret",- Code: "test_code",- RedirectURL: "http://localhost:3000",- },- )- require.NoError(t, err)-- // We use time.Now() to compute the values of CreatedAt and ExpiresTs so there- // is no point to assert.- got.CreatedAt = 0- got.ExpiresTs = 0-- want := &vcs.OAuthToken{- AccessToken: "de6780bc506a0446309bd9362820ba8aed28aa506c71eedbe1c5c4f9dd350e54",- RefreshToken: "8257e65c97202ed1726cf9571600918f3bffb2544b26e00a61df9897668c33a1",- ExpiresIn: 3600,- }- assert.Equal(t, want, got)-}-func TestProvider_FetchCommitByID(t *testing.T) {p := newMockProvider(func(r *http.Request) (*http.Response, error) {assert.Equal(t, "/2.0/repositories/bitbucket/geordi/commit/f7591a1", r.URL.Path)@@ -867,58 +820,6 @@ func TestProvider_DeleteWebhook(t *testing.T) {require.NoError(t, err)}-func TestOAuth_RefreshToken(t *testing.T) {- ctx := context.Background()- client := &http.Client{- Transport: &common.MockRoundTripper{- MockRoundTrip: func(r *http.Request) (*http.Response, error) {- token := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")- if token == "expired" {- return &http.Response{- StatusCode: http.StatusUnauthorized,- Body: io.NopCloser(strings.NewReader(`- {"error":"invalid_grant","error_description":"The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}- `)),- }, nil- }-- return &http.Response{- StatusCode: http.StatusOK,- Body: io.NopCloser(strings.NewReader(`-{- "access_token": "ghu_16C7e42F292c6912E7710c838347Ae178B4a",- "expires_in": 3600,- "refresh_token": "ghr_1B4a2e77838347a7E420ce178F2E7c6912E169246c34E1ccbF66C46812d16D5B1A9Dc86A1498"-}-`)),- }, nil- },- },- }- token := "expired"-- calledRefresher := false- refresher := func(_, _ string, _ int64) error {- calledRefresher = true- return nil- }-- _, _, _, err := oauth.Get(- ctx,- client,- "https://https://api.bitbucket.org/2.0/user",- &token,- tokenRefresher(- bitbucketCloudURL,- oauthContext{},- refresher,- ),- )- require.NoError(t, err)- assert.Equal(t, "ghu_16C7e42F292c6912E7710c838347Ae178B4a", token)- assert.True(t, calledRefresher)-}-func newMockProvider(mockRoundTrip func(r *http.Request) (*http.Response, error)) vcs.Provider {return newProvider(vcs.ProviderConfig{diff --git a/backend/plugin/vcs/bitbucket/sql_review.go b/backend/plugin/vcs/bitbucket/sql_review.goindex f8d402caa8..eb69a7aef8 100644--- a/backend/plugin/vcs/bitbucket/sql_review.go+++ b/backend/plugin/vcs/bitbucket/sql_review.go@@ -62,7 +62,7 @@ func getSQLReviewStep(endpoint string) string {// EnableSQLReviewCI enables the pipeline.//// Docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-config-put.-func EnableSQLReviewCI(ctx context.Context, oauthCtx *common.OauthContext, apiURL, instanceURL, repositoryID string) error {+func EnableSQLReviewCI(ctx context.Context, oauthCtx *common.OauthContext, apiURL, repositoryID string) error {body, err := json.Marshal(pipelineConfig{Enabled: true,@@ -78,17 +78,8 @@ func EnableSQLReviewCI(ctx context.Context, oauthCtx *common.OauthContext, apiURctx,client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)diff --git a/backend/plugin/vcs/github/github.go b/backend/plugin/vcs/github/github.goindex 5b887193b9..0c7a06ba1a 100644--- a/backend/plugin/vcs/github/github.go+++ b/backend/plugin/vcs/github/github.go@@ -8,7 +8,6 @@ import ("encoding/base64""encoding/json""fmt"- "io""log/slog""net/http""net/url"@@ -234,16 +233,7 @@ func (p *Provider) FetchCommitByID(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrap(err, "GET")@@ -279,16 +269,7 @@ func (p *Provider) GetDiffFileList(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -328,65 +309,6 @@ func (p *Provider) GetDiffFileList(ctx context.Context, oauthCtx *common.OauthCoreturn ret, nil}-// oauthResponse is a GitHub OAuth response.-type oauthResponse struct {- AccessToken string `json:"access_token" `- Error string `json:"error,omitempty"`- ErrorDescription string `json:"error_description,omitempty"`-}--// toVCSOAuthToken converts the response to *vcs.OAuthToken.-func (o oauthResponse) toVCSOAuthToken() *vcs.OAuthToken {- oauthToken := &vcs.OAuthToken{- AccessToken: o.AccessToken,- // GitHub OAuth token never expires- }- return oauthToken-}--// ExchangeOAuthToken exchanges OAuth content with the provided authorization code.-func (p *Provider) ExchangeOAuthToken(ctx context.Context, instanceURL string, oauthExchange *common.OAuthExchange) (*vcs.OAuthToken, error) {- urlParams := &url.Values{}- urlParams.Set("client_id", oauthExchange.ClientID)- urlParams.Set("client_secret", oauthExchange.ClientSecret)- urlParams.Set("code", oauthExchange.Code)- urlParams.Set("redirect_uri", oauthExchange.RedirectURL)- url := fmt.Sprintf("%s/login/oauth/access_token?%s", instanceURL, urlParams.Encode())-- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, nil)- if err != nil {- urlParams.Set("client_secret", "**redacted**")- redactedURL := fmt.Sprintf("%s/login/oauth/access_token?%s", instanceURL, urlParams.Encode())- return nil, errors.Wrapf(err, "construct POST %s", redactedURL)- }-- // GitHub returns URL-encoded parameters as the response format by default,- // we need to ask for a JSON response explicitly.- req.Header.Set("Accept", "application/json")-- resp, err := p.client.Do(req)- if err != nil {- return nil, errors.Wrap(err, "failed to exchange OAuth token")- }-- body, err := io.ReadAll(resp.Body)- if err != nil {- return nil, errors.Wrapf(err, "failed to read OAuth response body, code %v", resp.StatusCode)- }- defer func() {- _ = resp.Body.Close()- }()-- oauthResp := new(oauthResponse)- if err := json.Unmarshal(body, oauthResp); err != nil {- return nil, errors.Wrapf(err, "failed to unmarshal OAuth response body, code %v", resp.StatusCode)- }- if oauthResp.Error != "" {- return nil, errors.Errorf("failed to exchange OAuth token, error: %v, error_description: %v", oauthResp.Error, oauthResp.ErrorDescription)- }- return oauthResp.toVCSOAuthToken(), nil-}-// FetchAllRepositoryList fetches all repositories where the authenticated user// has admin permissions, which is required to create webhook in the repository.//@@ -437,16 +359,7 @@ func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, oauthCtx *cctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, false, errors.Wrapf(err, "GET %s", url)@@ -488,16 +401,7 @@ func (p *Provider) FetchRepositoryFileList(ctx context.Context, oauthCtx *commonctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -565,17 +469,8 @@ func (p *Provider) CreateFile(ctx context.Context, oauthCtx *common.OauthContextctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)@@ -614,16 +509,7 @@ func (p *Provider) ReadFileMeta(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -671,16 +557,7 @@ func (p *Provider) getLastCommitID(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return "", errors.Wrapf(err, "GET %s", url)@@ -714,16 +591,7 @@ func (p *Provider) ReadFileContent(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,map[string]string{"Accept": "application/vnd.github.raw",},@@ -819,16 +687,7 @@ func (p *Provider) listPaginatedPullRequestFile(ctx context.Context, oauthCtx *cctx,p.client,requestURL,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", requestURL)@@ -876,16 +735,7 @@ func (p *Provider) GetBranch(ctx context.Context, oauthCtx *common.OauthContext,ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -936,17 +786,8 @@ func (p *Provider) CreateBranch(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "GET %s", url)@@ -984,17 +825,8 @@ func (p *Provider) CreatePullRequest(ctx context.Context, oauthCtx *common.Oauthctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return nil, errors.Wrapf(err, "POST %s", url)@@ -1056,17 +888,8 @@ func (p *Provider) UpsertEnvironmentVariable(ctx context.Context, oauthCtx *commctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)@@ -1148,16 +971,7 @@ func (p *Provider) getRepositoryPublicKey(ctx context.Context, oauthCtx *common.ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -1190,17 +1004,8 @@ func (p *Provider) CreateWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return "", errors.Wrapf(err, "POST %s", url)@@ -1236,17 +1041,8 @@ func (p *Provider) PatchWebhook(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PATCH %s", url)@@ -1273,16 +1069,7 @@ func (p *Provider) DeleteWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return errors.Wrapf(err, "DELETE %s", url)@@ -1300,70 +1087,6 @@ func (p *Provider) DeleteWebhook(ctx context.Context, oauthCtx *common.OauthContreturn nil}-// oauthContext is the request context for refreshing oauth token.-type oauthContext struct {- ClientID string- ClientSecret string- RefreshToken string- GrantType string-}--type refreshOAuthResponse struct {- AccessToken string `json:"access_token"`- RefreshToken string `json:"refresh_token"`- ExpiresIn string `json:"expires_in"`- CreatedAt int64 `json:"created_at"`- // token_type, scope are not used.-}--func tokenRefresher(instanceURL string, oauthCtx oauthContext, refresher common.TokenRefresher) oauth.TokenRefresher {- return func(ctx context.Context, client *http.Client, oldToken *string) error {- params := &url.Values{}- params.Set("client_id", oauthCtx.ClientID)- params.Set("client_secret", oauthCtx.ClientSecret)- params.Set("refresh_token", oauthCtx.RefreshToken)- params.Set("grant_type", "refresh_token")-- url := fmt.Sprintf("%s/login/oauth/access_token", instanceURL)- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(params.Encode()))- if err != nil {- return errors.Wrapf(err, "construct POST %s", url)- }-- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")- resp, err := client.Do(req)- if err != nil {- return errors.Wrapf(err, "POST %s", url)- }-- body, err := io.ReadAll(resp.Body)- if err != nil {- return errors.Wrapf(err, "read body of POST %s", url)- }- defer resp.Body.Close()-- if resp.StatusCode != http.StatusOK {- return errors.Errorf("non-200 POST %s status code %d with body %q", url, resp.StatusCode, body)- }-- var r refreshOAuthResponse- if err = json.Unmarshal(body, &r); err != nil {- return errors.Wrapf(err, "unmarshal body from POST %s", url)- }-- // Update the old token to new value for retries.- *oldToken = r.AccessToken-- // OAuth token never expires for traditional GitHub OAuth (i.e. not a GitHub App)- var expireAt int64- if r.ExpiresIn != "" {- expiresIn, _ := strconv.ParseInt(r.ExpiresIn, 10, 64)- expireAt = r.CreatedAt + expiresIn- }- return refresher(r.AccessToken, r.RefreshToken, expireAt)- }-}-// ToVCS returns the push event in VCS format.func (p WebhookPushEvent) ToVCS() vcs.PushEvent {var commitList []vcs.Commitdiff --git a/backend/plugin/vcs/github/github_test.go b/backend/plugin/vcs/github/github_test.goindex fdc19eb49f..9c5f0b92d8 100644--- a/backend/plugin/vcs/github/github_test.go+++ b/backend/plugin/vcs/github/github_test.go@@ -13,7 +13,6 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/vcs"- "github.com/bytebase/bytebase/backend/plugin/vcs/internal/oauth")func TestProvider_FetchCommitByID(t *testing.T) {@@ -74,44 +73,6 @@ func TestProvider_FetchCommitByID(t *testing.T) {assert.Equal(t, want, got)}-func TestProvider_ExchangeOAuthToken(t *testing.T) {- p := newMockProvider(func(r *http.Request) (*http.Response, error) {- assert.Equal(t, "/login/oauth/access_token", r.URL.Path)- assert.Equal(t, "client_id=test_client_id&client_secret=test_client_secret&code=test_code&redirect_uri=http%3A%2F%2Flocalhost%3A3000", r.URL.RawQuery)- assert.Equal(t, "application/json", r.Header.Get("Accept"))- return &http.Response{- StatusCode: http.StatusOK,- // Example response taken from https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#response- Body: io.NopCloser(strings.NewReader(`-{- "access_token":"gho_16C7e42F292c6912E7710c838347Ae178B4a",- "scope":"repo,gist",- "token_type":"bearer"-}-`)),- }, nil- },- )-- ctx := context.Background()- got, err := p.ExchangeOAuthToken(- ctx,- githubComURL,- &common.OAuthExchange{- ClientID: "test_client_id",- ClientSecret: "test_client_secret",- Code: "test_code",- RedirectURL: "http://localhost:3000",- },- )- require.NoError(t, err)-- want := &vcs.OAuthToken{- AccessToken: "gho_16C7e42F292c6912E7710c838347Ae178B4a",- }- assert.Equal(t, want, got)-}-func TestProvider_FetchAllRepositoryList(t *testing.T) {p := newMockProvider(func(r *http.Request) (*http.Response, error) {assert.Equal(t, "/user/repos", r.URL.Path)@@ -711,62 +672,6 @@ func TestProvider_DeleteWebhook(t *testing.T) {require.NoError(t, err)}-func TestOAuth_RefreshToken(t *testing.T) {- ctx := context.Background()- client := &http.Client{- Transport: &common.MockRoundTripper{- MockRoundTrip: func(r *http.Request) (*http.Response, error) {- token := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")- if token == "expired" {- return &http.Response{- StatusCode: http.StatusBadRequest,- Body: io.NopCloser(strings.NewReader(`- {"error":"invalid_grant","error_description":"The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}- `)),- }, nil- }-- return &http.Response{- StatusCode: http.StatusOK,- // Example response taken from https://docs.github.com/en/developers/apps/building-github-apps/refreshing-user-to-server-access-tokens#renewing-a-user-token-with-a-refresh-token- Body: io.NopCloser(strings.NewReader(`-{- "access_token": "ghu_16C7e42F292c6912E7710c838347Ae178B4a",- "expires_in": "28800",- "refresh_token": "ghr_1B4a2e77838347a7E420ce178F2E7c6912E169246c34E1ccbF66C46812d16D5B1A9Dc86A1498",- "refresh_token_expires_in": "15811200",- "scope": "",- "token_type": "bearer"-}-`)),- }, nil- },- },- }- token := "expired"-- calledRefresher := false- refresher := func(_, _ string, _ int64) error {- calledRefresher = true- return nil- }-- _, _, _, err := oauth.Get(- ctx,- client,- "https://api.github.com/users/octocat",- &token,- tokenRefresher(- githubComURL,- oauthContext{},- refresher,- ),- )- require.NoError(t, err)- assert.Equal(t, "ghu_16C7e42F292c6912E7710c838347Ae178B4a", token)- assert.True(t, calledRefresher)-}-func TestProvider_GetBranch(t *testing.T) {p := newMockProvider(func(r *http.Request) (*http.Response, error) {assert.Equal(t, "GET", r.Method)diff --git a/backend/plugin/vcs/gitlab/gitlab.go b/backend/plugin/vcs/gitlab/gitlab.goindex 1b48e50295..209bc6c694 100644--- a/backend/plugin/vcs/gitlab/gitlab.go+++ b/backend/plugin/vcs/gitlab/gitlab.go@@ -6,11 +6,9 @@ import ("context""encoding/json""fmt"- "io""net/http""net/url""strconv"- "strings""time""github.com/pkg/errors"@@ -164,74 +162,6 @@ func (*Provider) APIURL(instanceURL string) string {return fmt.Sprintf("%s/%s", instanceURL, apiPath)}-// oauthResponse is a GitLab OAuth response.-type oauthResponse struct {- AccessToken string `json:"access_token" `- RefreshToken string `json:"refresh_token"`- ExpiresIn int64 `json:"expires_in"`- CreatedAt int64 `json:"created_at"`- ExpiresTs int64 `json:"expires_ts"`- Error string `json:"error,omitempty"`- ErrorDescription string `json:"error_description,omitempty"`-}--// toVCSOAuthToken converts the response to *vcs.OAuthToken.-func (o oauthResponse) toVCSOAuthToken() *vcs.OAuthToken {- oauthToken := &vcs.OAuthToken{- AccessToken: o.AccessToken,- RefreshToken: o.RefreshToken,- ExpiresIn: o.ExpiresIn,- CreatedAt: o.CreatedAt,- ExpiresTs: o.ExpiresTs,- }- // For GitLab, as of 13.12, the default config won't expire the access token,- // thus this field is 0. See https://gitlab.com/gitlab-org/gitlab/-/issues/21745.- if oauthToken.ExpiresIn != 0 {- oauthToken.ExpiresTs = oauthToken.CreatedAt + oauthToken.ExpiresIn- }- return oauthToken-}--// ExchangeOAuthToken exchanges OAuth content with the provided authorization code.-func (p *Provider) ExchangeOAuthToken(ctx context.Context, instanceURL string, oauthExchange *common.OAuthExchange) (*vcs.OAuthToken, error) {- urlParams := &url.Values{}- urlParams.Set("client_id", oauthExchange.ClientID)- urlParams.Set("client_secret", oauthExchange.ClientSecret)- urlParams.Set("code", oauthExchange.Code)- urlParams.Set("redirect_uri", oauthExchange.RedirectURL)- urlParams.Set("grant_type", "authorization_code")- url := fmt.Sprintf("%s/oauth/token?%s", instanceURL, urlParams.Encode())-- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, nil)- if err != nil {- urlParams.Set("client_secret", "**redacted**")- redactedURL := fmt.Sprintf("%s/oauth/token?%s", instanceURL, urlParams.Encode())- return nil, errors.Wrapf(err, "construct POST %s", redactedURL)- }-- resp, err := p.client.Do(req)- if err != nil {- return nil, errors.Wrap(err, "failed to exchange OAuth token")- }-- body, err := io.ReadAll(resp.Body)- if err != nil {- return nil, errors.Wrapf(err, "failed to read OAuth response body, code %v", resp.StatusCode)- }- defer func() {- _ = resp.Body.Close()- }()-- oauthResp := new(oauthResponse)- if err := json.Unmarshal(body, oauthResp); err != nil {- return nil, errors.Wrapf(err, "failed to unmarshal OAuth response body, code %v", resp.StatusCode)- }- if oauthResp.Error != "" {- return nil, errors.Errorf("failed to exchange OAuth token, error: %v, error_description: %v", oauthResp.Error, oauthResp.ErrorDescription)- }- return oauthResp.toVCSOAuthToken(), nil-}-// FetchAllRepositoryList fetches all repositories where the authenticated user// has a maintainer role, which is required to create webhook in the project.//@@ -277,16 +207,7 @@ func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, oauthCtx *cctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, false, errors.Wrapf(err, "GET %s", url)@@ -321,16 +242,7 @@ func (p *Provider) FetchCommitByID(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrap(err, "GET")@@ -364,16 +276,7 @@ func (p *Provider) GetDiffFileList(ctx context.Context, oauthCtx *common.OauthCoctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -455,16 +358,7 @@ func (p *Provider) fetchPaginatedRepositoryFileList(ctx context.Context, oauthCtctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, false, errors.Wrapf(err, "GET %s", url)@@ -514,17 +408,8 @@ func (p *Provider) CreateFile(ctx context.Context, oauthCtx *common.OauthContextctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "POST %s", url)@@ -565,17 +450,8 @@ func (p *Provider) OverwriteFile(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)@@ -641,16 +517,7 @@ func (p *Provider) ListPullRequestFile(ctx context.Context, oauthCtx *common.Oauctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -712,16 +579,7 @@ func (p *Provider) GetBranch(ctx context.Context, oauthCtx *common.OauthContext,ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -767,17 +625,8 @@ func (p *Provider) CreateBranch(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "GET %s", url)@@ -823,17 +672,8 @@ func (p *Provider) CreatePullRequest(ctx context.Context, oauthCtx *common.Oauthctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -888,16 +728,7 @@ func (p *Provider) getEnvironmentVariable(ctx context.Context, oauthCtx *common.ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -940,17 +771,8 @@ func (p *Provider) createEnvironmentVariable(ctx context.Context, oauthCtx *commctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "POST %s", url)@@ -985,17 +807,8 @@ func (p *Provider) updateEnvironmentVariable(ctx context.Context, oauthCtx *commctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(body),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)@@ -1021,17 +834,8 @@ func (p *Provider) CreateWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return "", errors.Wrapf(err, "POST %s", url)@@ -1072,17 +876,8 @@ func (p *Provider) PatchWebhook(ctx context.Context, oauthCtx *common.OauthContectx,p.client,url,- &oauthCtx.AccessToken,+ oauthCtx.AccessToken,bytes.NewReader(payload),- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),)if err != nil {return errors.Wrapf(err, "PUT %s", url)@@ -1109,16 +904,7 @@ func (p *Provider) DeleteWebhook(ctx context.Context, oauthCtx *common.OauthContctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return errors.Wrapf(err, "DELETE %s", url)@@ -1149,16 +935,7 @@ func (p *Provider) readFile(ctx context.Context, oauthCtx *common.OauthContext,ctx,p.client,url,- &oauthCtx.AccessToken,- tokenRefresher(- instanceURL,- oauthContext{- ClientID: oauthCtx.ClientID,- ClientSecret: oauthCtx.ClientSecret,- RefreshToken: oauthCtx.RefreshToken,- },- oauthCtx.Refresher,- ),+ oauthCtx.AccessToken,)if err != nil {return nil, errors.Wrapf(err, "GET %s", url)@@ -1181,70 +958,6 @@ func (p *Provider) readFile(ctx context.Context, oauthCtx *common.OauthContext,}, nil}-// oauthContext is the request context for refreshing oauth token.-type oauthContext struct {- ClientID string- ClientSecret string- RefreshToken string- GrantType string-}--type refreshOauthResponse struct {- AccessToken string `json:"access_token"`- RefreshToken string `json:"refresh_token"`- ExpiresIn int64 `json:"expires_in"`- CreatedAt int64 `json:"created_at"`- // token_type, scope are not used.-}--func tokenRefresher(instanceURL string, oauthCtx oauthContext, refresher common.TokenRefresher) oauth.TokenRefresher {- return func(ctx context.Context, client *http.Client, oldToken *string) error {- params := &url.Values{}- params.Set("client_id", oauthCtx.ClientID)- params.Set("client_secret", oauthCtx.ClientSecret)- params.Set("refresh_token", oauthCtx.RefreshToken)- params.Set("grant_type", "refresh_token")-- url := fmt.Sprintf("%s/oauth/token", instanceURL)- req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(params.Encode()))- if err != nil {- return errors.Wrapf(err, "construct POST %s", url)- }-- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")- resp, err := client.Do(req)- if err != nil {- return errors.Wrapf(err, "POST %s", url)- }- defer resp.Body.Close()-- body, err := io.ReadAll(resp.Body)- if err != nil {- return errors.Wrapf(err, "read body of POST %s", url)- }-- if resp.StatusCode != http.StatusOK {- return errors.Errorf("non-200 POST %s status code %d with body %q", url, resp.StatusCode, body)- }-- var r refreshOauthResponse- if err := json.Unmarshal(body, &r); err != nil {- return errors.Wrapf(err, "unmarshal body from POST %s", url)- }-- // Update the old token to new value for retries.- *oldToken = r.AccessToken-- // For GitLab, as of 13.12, the default config won't expire the access token,- // thus this field is 0. See https://gitlab.com/gitlab-org/gitlab/-/issues/21745.- var expireAt int64- if r.ExpiresIn != 0 {- expireAt = r.CreatedAt + r.ExpiresIn- }- return refresher(r.AccessToken, r.RefreshToken, expireAt)- }-}-// ToVCS returns the push event in VCS format.func (p WebhookPushEvent) ToVCS() (vcs.PushEvent, error) {var commitList []vcs.Commitdiff --git a/backend/plugin/vcs/gitlab/gitlab_test.go b/backend/plugin/vcs/gitlab/gitlab_test.goindex a2b95202cd..20ac4b8512 100644--- a/backend/plugin/vcs/gitlab/gitlab_test.go+++ b/backend/plugin/vcs/gitlab/gitlab_test.go@@ -13,7 +13,6 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/vcs"- "github.com/bytebase/bytebase/backend/plugin/vcs/internal/oauth")func TestProvider_FetchCommitByID(t *testing.T) {@@ -69,47 +68,6 @@ func TestProvider_FetchCommitByID(t *testing.T) {assert.Equal(t, want, got)}-func TestProvider_ExchangeOAuthToken(t *testing.T) {- p := newMockProvider(func(r *http.Request) (*http.Response, error) {- assert.Equal(t, "/oauth/token", r.URL.Path)- assert.Equal(t, "client_id=test_client_id&client_secret=test_client_secret&code=test_code&grant_type=authorization_code&redirect_uri=http%3A%2F%2Flocalhost%3A3000", r.URL.RawQuery)- return &http.Response{- StatusCode: http.StatusOK,- // Example response taken from https://docs.gitlab.com/ee/api/oauth2.html#authorization-code-flow- Body: io.NopCloser(strings.NewReader(`-{- "access_token": "de6780bc506a0446309bd9362820ba8aed28aa506c71eedbe1c5c4f9dd350e54",- "token_type": "bearer",- "expires_in": 7200,- "refresh_token": "8257e65c97202ed1726cf9571600918f3bffb2544b26e00a61df9897668c33a1",- "created_at": 1607635748-}-`)),- }, nil- },- )-- ctx := context.Background()- got, err := p.ExchangeOAuthToken(ctx, "",- &common.OAuthExchange{- ClientID: "test_client_id",- ClientSecret: "test_client_secret",- Code: "test_code",- RedirectURL: "http://localhost:3000",- },- )- require.NoError(t, err)-- want := &vcs.OAuthToken{- AccessToken: "de6780bc506a0446309bd9362820ba8aed28aa506c71eedbe1c5c4f9dd350e54",- RefreshToken: "8257e65c97202ed1726cf9571600918f3bffb2544b26e00a61df9897668c33a1",- ExpiresIn: 7200,- CreatedAt: 1607635748,- ExpiresTs: 1607642948,- }- assert.Equal(t, want, got)-}-func TestProvider_FetchAllRepositoryList(t *testing.T) {p := newMockProvider(func(r *http.Request) (*http.Response, error) {assert.Equal(t, "/api/v4/projects", r.URL.Path)@@ -424,61 +382,6 @@ func TestProvider_DeleteWebhook(t *testing.T) {require.NoError(t, err)}-func TestOAuth_RefreshToken(t *testing.T) {- ctx := context.Background()- client := &http.Client{- Transport: &common.MockRoundTripper{- MockRoundTrip: func(r *http.Request) (*http.Response, error) {- token := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")- if token == "expired" {- return &http.Response{- StatusCode: http.StatusBadRequest,- Body: io.NopCloser(strings.NewReader(`- {"error":"invalid_grant","error_description":"The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}- `)),- }, nil- }-- return &http.Response{- StatusCode: http.StatusOK,- // Example response taken from https://docs.gitlab.com/ee/api/oauth2.html#authorization-code-with-proof-key-for-code-exchange-pkce- Body: io.NopCloser(strings.NewReader(`-{- "access_token": "de6780bc506a0446309bd9362820ba8aed28aa506c71eedbe1c5c4f9dd350e54",- "token_type": "bearer",- "expires_in": 7200,- "refresh_token": "8257e65c97202ed1726cf9571600918f3bffb2544b26e00a61df9897668c33a1",- "created_at": 1607635748-}-`)),- }, nil- },- },- }- token := "expired"-- calledRefresher := false- refresher := func(_, _ string, _ int64) error {- calledRefresher = true- return nil- }-- _, _, _, err := oauth.Get(- ctx,- client,- "https://gitlab.example.com/api/v4/users/octocat",- &token,- tokenRefresher(- "https://gitlab.example.com",- oauthContext{},- refresher,- ),- )- require.NoError(t, err)- assert.Equal(t, "de6780bc506a0446309bd9362820ba8aed28aa506c71eedbe1c5c4f9dd350e54", token)- assert.True(t, calledRefresher)-}-func TestProvider_GetBranch(t *testing.T) {p := newMockProvider(func(r *http.Request) (*http.Response, error) {assert.Equal(t, "GET", r.Method)diff --git a/backend/plugin/vcs/internal/oauth/oauth.go b/backend/plugin/vcs/internal/oauth/oauth.goindex 65e75d44fb..98842ad337 100644--- a/backend/plugin/vcs/internal/oauth/oauth.go+++ b/backend/plugin/vcs/internal/oauth/oauth.go@@ -16,16 +16,12 @@ import ("github.com/bytebase/bytebase/backend/common/log")-// TokenRefresher is a function to refresh the OAuth token and assign back to-// the old token upon a successful refresh.-type TokenRefresher func(ctx context.Context, client *http.Client, oldToken *string) error--func requester(ctx context.Context, client *http.Client, method, url string, token *string, body io.Reader) func() (*http.Response, error) {+func requester(ctx context.Context, client *http.Client, method, url string, token string, body io.Reader) func() (*http.Response, error) {//nolint:bodyclosereturn requesterWithHeader(ctx, client, method, url, token, body, nil)}-func requesterWithHeader(ctx context.Context, client *http.Client, method, url string, token *string, body io.Reader, header map[string]string) func() (*http.Response, error) {+func requesterWithHeader(ctx context.Context, client *http.Client, method, url string, token string, body io.Reader, header map[string]string) func() (*http.Response, error) {// The body may be read multiple times but io.Reader is meant to be read once,// so we read the body first and build the reader every time.var bodyBytes []byte@@ -45,7 +41,7 @@ func requesterWithHeader(ctx context.Context, client *http.Client, method, url s}req.Header.Set("Content-Type", "application/json")- req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", *token))+ req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))for k, v := range header {req.Header.Set(k, v)}@@ -60,92 +56,79 @@ func requesterWithHeader(ctx context.Context, client *http.Client, method, url s// Post makes a HTTP POST request to the given URL using the token. It refreshes// token and retries the request in the case of the token has expired.-func Post(ctx context.Context, client *http.Client, url string, token *string, body io.Reader, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {- return PostWithHeader(ctx, client, url, token, body, tokenRefresher, nil)+func Post(ctx context.Context, client *http.Client, url string, token string, body io.Reader) (code int, header http.Header, respBody string, err error) {+ return PostWithHeader(ctx, client, url, token, body, nil)}// PostWithHeader makes a HTTP POST request to the given URL using the token and// additional header. It refreshes token and retries the request in the case of// the token has expired.-func PostWithHeader(ctx context.Context, client *http.Client, url string, token *string, body io.Reader, tokenRefresher TokenRefresher, header map[string]string) (code int, _ http.Header, respBody string, err error) {+func PostWithHeader(ctx context.Context, client *http.Client, url string, token string, body io.Reader, header map[string]string) (code int, _ http.Header, respBody string, err error) {//nolint:bodyclose- return retry(ctx, client, token, tokenRefresher, requesterWithHeader(ctx, client, http.MethodPost, url, token, body, header))+ return retry(ctx, requesterWithHeader(ctx, client, http.MethodPost, url, token, body, header))}// Get makes a HTTP GET request to the given URL using the token. It refreshes// token and retries the request in the case of the token has expired.-func Get(ctx context.Context, client *http.Client, url string, token *string, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {+func Get(ctx context.Context, client *http.Client, url string, token string) (code int, header http.Header, respBody string, err error) {//nolint:bodyclose- return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodGet, url, token, nil))+ return retry(ctx, requester(ctx, client, http.MethodGet, url, token, nil))}// GetWithHeader makes a HTTP GET request to the given URL using the token and// additional header. It refreshes token and retries the request in the case of// the token has expired.-func GetWithHeader(ctx context.Context, client *http.Client, url string, token *string, tokenRefresher TokenRefresher, header map[string]string) (code int, _ http.Header, respBody string, err error) {+func GetWithHeader(ctx context.Context, client *http.Client, url string, token string, header map[string]string) (code int, _ http.Header, respBody string, err error) {//nolint:bodyclose- return retry(ctx, client, token, tokenRefresher, requesterWithHeader(ctx, client, http.MethodGet, url, token, nil, header))+ return retry(ctx, requesterWithHeader(ctx, client, http.MethodGet, url, token, nil, header))}// Put makes a HTTP PUT request to the given URL using the token. It refreshes// token and retries the request in the case of the token has expired.-func Put(ctx context.Context, client *http.Client, url string, token *string, body io.Reader, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {+func Put(ctx context.Context, client *http.Client, url string, token string, body io.Reader) (code int, header http.Header, respBody string, err error) {//nolint:bodyclose- return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodPut, url, token, body))+ return retry(ctx, requester(ctx, client, http.MethodPut, url, token, body))}// Patch makes a HTTP PATCH request to the given URL using the token. It// refreshes token and retries the request in the case of the token has expired.-func Patch(ctx context.Context, client *http.Client, url string, token *string, body io.Reader, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {+func Patch(ctx context.Context, client *http.Client, url string, token string, body io.Reader) (code int, header http.Header, respBody string, err error) {//nolint:bodyclose- return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodPatch, url, token, body))+ return retry(ctx, requester(ctx, client, http.MethodPatch, url, token, body))}// Delete makes a HTTP DELETE request to the given URL using the token. It refreshes// token and retries the request in the case of the token has expired.-func Delete(ctx context.Context, client *http.Client, url string, token *string, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {+func Delete(ctx context.Context, client *http.Client, url string, token string) (code int, header http.Header, respBody string, err error) {//nolint:bodyclose- return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodDelete, url, token, nil))+ return retry(ctx, requester(ctx, client, http.MethodDelete, url, token, nil))}-const maxRetries = 3--func retry(ctx context.Context, client *http.Client, token *string, tokenRefresher TokenRefresher, f func() (*http.Response, error)) (code int, header http.Header, respBody string, err error) {- var resp *http.Response- var body []byte- for retries := 0; retries < maxRetries; retries++ {- select {- case <-ctx.Done():- return 0, nil, "", ctx.Err()- default:- }+func retry(ctx context.Context, f func() (*http.Response, error)) (code int, header http.Header, respBody string, err error) {+ // TODO(d): handle timeout retries.+ select {+ case <-ctx.Done():+ return 0, nil, "", ctx.Err()+ default:+ }- resp, err = f()- if err != nil {- return 0, nil, "", err- }+ resp, err := f()+ if err != nil {+ return 0, nil, "", err+ }- body, err := io.ReadAll(resp.Body)- if err != nil {- return 0, nil, "", errors.Wrapf(err, "read response body with status code %d", resp.StatusCode)- }- if err := resp.Body.Close(); err != nil {- slog.Warn("failed to close resp body", log.BBError(err))- }+ body, err := io.ReadAll(resp.Body)+ if err != nil {+ return 0, nil, "", errors.Wrapf(err, "read response body with status code %d", resp.StatusCode)+ }+ if err := resp.Body.Close(); err != nil {+ slog.Warn("failed to close resp body", log.BBError(err))+ }- if err = getOAuthErrorDetails(resp.StatusCode, body); err != nil {- if _, ok := err.(*oauthError); ok {- // Refresh the token- if err := tokenRefresher(ctx, client, token); err != nil {- return 0, nil, "", err- }- continue- }- return 0, nil, "", errors.Errorf("got unexpected OAuth error %T", err)- }- return resp.StatusCode, resp.Header, string(body), nil+ if err = getOAuthErrorDetails(resp.StatusCode, body); err != nil {+ return 0, nil, "", errors.Errorf("got unexpected OAuth error %T", err)}- return 0, nil, "", errors.Errorf("retries exceeded for OAuth refresher with status code %d and body %q", resp.StatusCode, string(body))+ return resp.StatusCode, resp.Header, string(body), nil}type oauthError struct {diff --git a/backend/plugin/vcs/internal/oauth/oauth_test.go b/backend/plugin/vcs/internal/oauth/oauth_test.goindex 014df5e3d0..cc1243cadc 100644--- a/backend/plugin/vcs/internal/oauth/oauth_test.go+++ b/backend/plugin/vcs/internal/oauth/oauth_test.go@@ -2,7 +2,6 @@ package oauthimport ("context"- "fmt""io""net/http""strings"@@ -31,7 +30,7 @@ func TestPost(t *testing.T) {},}token := "token"- _, _, _, err := Post(ctx, client, "", &token, strings.NewReader("POST body"), nil)+ _, _, _, err := Post(ctx, client, "", token, strings.NewReader("POST body"))require.NoError(t, err)}@@ -48,7 +47,7 @@ func TestGet(t *testing.T) {},}token := "token"- _, _, _, err := Get(ctx, client, "", &token, nil)+ _, _, _, err := Get(ctx, client, "", token)require.NoError(t, err)}@@ -69,7 +68,7 @@ func TestPut(t *testing.T) {},}token := "token"- _, _, _, err := Put(ctx, client, "", &token, strings.NewReader("PUT body"), nil)+ _, _, _, err := Put(ctx, client, "", token, strings.NewReader("PUT body"))require.NoError(t, err)}@@ -90,7 +89,7 @@ func TestPatch(t *testing.T) {},}token := "token"- _, _, _, err := Patch(ctx, client, "", &token, strings.NewReader("PATCH body"), nil)+ _, _, _, err := Patch(ctx, client, "", token, strings.NewReader("PATCH body"))require.NoError(t, err)}@@ -107,28 +106,6 @@ func TestDelete(t *testing.T) {},}token := "token"- _, _, _, err := Delete(ctx, client, "", &token, nil)+ _, _, _, err := Delete(ctx, client, "", token)require.NoError(t, err)}--func TestRetry_Exceeded(t *testing.T) {- ctx := context.Background()- token := "expired"-- _, _, _, err := retry(ctx, nil, &token,- func(_ context.Context, _ *http.Client, _ *string) error {- return nil- },- func() (*http.Response, error) {- return &http.Response{- StatusCode: http.StatusBadRequest,- Body: io.NopCloser(strings.NewReader(`-{"error":"invalid_token","error_description":"Token is expired. You can either do re-authorization or token refresh."}-`)),- }, nil- },- )- wantErr := `retries exceeded for OAuth refresher with status code 400 and body ""`- gotErr := fmt.Sprintf("%v", err)- assert.Equal(t, wantErr, gotErr)-}diff --git a/backend/plugin/vcs/vcs.go b/backend/plugin/vcs/vcs.goindex 9a507c0aad..aa9cca6d4d 100644--- a/backend/plugin/vcs/vcs.go+++ b/backend/plugin/vcs/vcs.go@@ -214,12 +214,6 @@ type Provider interface {// Returns the API URL for a given VCS instance URLAPIURL(instanceURL string) string- // Exchange oauth token with the provided code- //- // instanceURL: VCS instance URL- // oauthExchange: api message for exchanging oauth token- ExchangeOAuthToken(ctx context.Context, instanceURL string, oauthExchange *common.OAuthExchange) (*OAuthToken, error)-// Fetch the commit data by id//// oauthCtx: OAuth context to fetch commitdiff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.goindex 26700b8649..e833947e71 100644--- a/backend/runner/taskrun/executor.go+++ b/backend/runner/taskrun/executor.go@@ -685,11 +685,7 @@ func writeBackLatestSchema(writebackBranch, latestSchemaFile string, schema string, bytebaseURL string,) (string, error) {oauthContext := &common.OauthContext{- ClientID: vcs.ApplicationID,- ClientSecret: vcs.Secret,- AccessToken: repository.AccessToken,- RefreshToken: repository.RefreshToken,- Refresher: utils.RefreshToken(ctx, storage, repository.WebURL),+ AccessToken: vcs.AccessToken,}schemaFileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,diff --git a/backend/store/repository.go b/backend/store/repository.goindex 9e70a481cc..fa30be995c 100644--- a/backend/store/repository.go+++ b/backend/store/repository.go@@ -29,7 +29,6 @@ type RepositoryMessage struct {BaseDirectory stringFilePathTemplate stringSchemaPathTemplate string- SheetPathTemplate stringEnableSQLReviewCI boolEnableCD boolExternalID string@@ -37,9 +36,6 @@ type RepositoryMessage struct {WebhookURLHost stringWebhookEndpointID stringWebhookSecretToken string- AccessToken string- ExpiresTs int64- RefreshToken string}// FindRepositoryMessage is the message for finding repositories.@@ -61,12 +57,8 @@ type PatchRepositoryMessage struct {BaseDirectory *stringFilePathTemplate *stringSchemaPathTemplate *string- SheetPathTemplate *stringEnableSQLReviewCI *boolEnableCD *bool- AccessToken *string- ExpiresTs *int64- RefreshToken *string}// CreateRepositoryV2 creates the repository.@@ -213,20 +205,16 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repobase_directory,file_path_template,schema_path_template,- sheet_path_template,enable_sql_review_ci,enable_cd,external_id,external_webhook_id,webhook_url_host,webhook_endpoint_id,- webhook_secret_token,- access_token,- expires_ts,- refresh_token+ webhook_secret_token)- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22)- RETURNING id, vcs_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, enable_cd, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)+ RETURNING id, vcs_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, enable_sql_review_ci, enable_cd, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token`if err := tx.QueryRowContext(ctx, query,creatorID,@@ -240,7 +228,6 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repocreate.BaseDirectory,create.FilePathTemplate,create.SchemaPathTemplate,- create.SheetPathTemplate,false, /* EnableSQLReviewCI */true, /* EnableCD */create.ExternalID,@@ -248,9 +235,6 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repocreate.WebhookURLHost,create.WebhookEndpointID,create.WebhookSecretToken,- create.AccessToken,- create.ExpiresTs,- create.RefreshToken,).Scan(&repository.UID,&repository.VCSUID,@@ -261,7 +245,6 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repo&repository.BaseDirectory,&repository.FilePathTemplate,&repository.SchemaPathTemplate,- &repository.SheetPathTemplate,&repository.EnableSQLReviewCI,&repository.EnableCD,&repository.ExternalID,@@ -269,9 +252,6 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repo&repository.WebhookURLHost,&repository.WebhookEndpointID,&repository.WebhookSecretToken,- &repository.AccessToken,- &repository.ExpiresTs,- &repository.RefreshToken,); err != nil {if err == sql.ErrNoRows {return nil, common.FormatDBErrorEmptyRowWithQuery(query)@@ -312,17 +292,13 @@ func (*Store) listRepositoryImplV2(ctx context.Context, tx *Tx, find *FindReposibase_directory,file_path_template,schema_path_template,- sheet_path_template,enable_sql_review_ci,enable_cd,external_id,external_webhook_id,webhook_url_host,webhook_endpoint_id,- webhook_secret_token,- access_token,- expires_ts,- refresh_token+ webhook_secret_tokenFROM repositoryLEFT JOIN project ON project.id = repository.project_idWHERE `+strings.Join(where, " AND "),@@ -348,7 +324,6 @@ func (*Store) listRepositoryImplV2(ctx context.Context, tx *Tx, find *FindReposi&repository.BaseDirectory,&repository.FilePathTemplate,&repository.SchemaPathTemplate,- &repository.SheetPathTemplate,&repository.EnableSQLReviewCI,&repository.EnableCD,&repository.ExternalID,@@ -356,9 +331,6 @@ func (*Store) listRepositoryImplV2(ctx context.Context, tx *Tx, find *FindReposi&repository.WebhookURLHost,&repository.WebhookEndpointID,&repository.WebhookSecretToken,- &repository.AccessToken,- &repository.ExpiresTs,- &repository.RefreshToken,); err != nil {return nil, err}@@ -389,18 +361,6 @@ func (*Store) patchRepositoryImplV2(ctx context.Context, tx *Tx, patch *PatchRepif v := patch.SchemaPathTemplate; v != nil {set, args = append(set, fmt.Sprintf("schema_path_template = $%d", len(args)+1)), append(args, *v)}- if v := patch.SheetPathTemplate; v != nil {- set, args = append(set, fmt.Sprintf("sheet_path_template = $%d", len(args)+1)), append(args, *v)- }- if v := patch.AccessToken; v != nil {- set, args = append(set, fmt.Sprintf("access_token = $%d", len(args)+1)), append(args, *v)- }- if v := patch.ExpiresTs; v != nil {- set, args = append(set, fmt.Sprintf("expires_ts = $%d", len(args)+1)), append(args, *v)- }- if v := patch.RefreshToken; v != nil {- set, args = append(set, fmt.Sprintf("refresh_token = $%d", len(args)+1)), append(args, *v)- }if v := patch.EnableSQLReviewCI; v != nil {set, args = append(set, fmt.Sprintf("enable_sql_review_ci = $%d", len(args)+1)), append(args, *v)}@@ -437,16 +397,12 @@ func (*Store) patchRepositoryImplV2(ctx context.Context, tx *Tx, patch *PatchRepbase_directory,file_path_template,schema_path_template,- sheet_path_template,enable_sql_review_ci,external_id,external_webhook_id,webhook_url_host,webhook_endpoint_id,- webhook_secret_token,- access_token,- expires_ts,- refresh_token+ webhook_secret_token`,args...,).Scan(@@ -460,16 +416,12 @@ func (*Store) patchRepositoryImplV2(ctx context.Context, tx *Tx, patch *PatchRep&repository.BaseDirectory,&repository.FilePathTemplate,&repository.SchemaPathTemplate,- &repository.SheetPathTemplate,&repository.EnableSQLReviewCI,&repository.ExternalID,&repository.ExternalWebhookID,&repository.WebhookURLHost,&repository.WebhookEndpointID,&repository.WebhookSecretToken,- &repository.AccessToken,- &repository.ExpiresTs,- &repository.RefreshToken,); err != nil {if err == sql.ErrNoRows {return nil, &common.Error{Code: common.NotFound, Err: errors.Errorf("repository ID not found: %d", patch.UID)}diff --git a/backend/store/vcs.go b/backend/store/vcs.goindex 7ffce367e2..7f89238332 100644--- a/backend/store/vcs.go+++ b/backend/store/vcs.go@@ -22,10 +22,8 @@ type VCSProviderMessage struct {InstanceURL string// Name is the name of the external version control.Name string- // Secret is the secret for the external version control.- Secret string- // ApplicationID is the ID of the application.- ApplicationID string+ // AccessToken is the access token for the external version control.+ AccessToken string// Output only fields.//@@ -37,10 +35,8 @@ type VCSProviderMessage struct {type UpdateVCSProviderMessage struct {// Name is the name of the external version control.Name *string- // Secret is the secret for the external version control.- Secret *string- // ApplicationID is the ID of the application.- ApplicationID *string+ // AccessToken is the secret for the external version control.+ AccessToken *string}type findVCSProviderMessage struct {@@ -116,11 +112,10 @@ func (s *Store) CreateVCSProviderV2(ctx context.Context, principalUID int, creattype,instance_url,api_url,- application_id,- secret+ access_token)- VALUES ($1, $2, $3, $4, $5, $6, $7, $8)- RETURNING id, name, type, instance_url, api_url, application_id, secret+ VALUES ($1, $2, $3, $4, $5, $6, $7)+ RETURNING id, name, type, instance_url, api_url, access_token`var vcsProvider VCSProviderMessageif err := tx.QueryRowContext(ctx, query,@@ -130,16 +125,14 @@ func (s *Store) CreateVCSProviderV2(ctx context.Context, principalUID int, creatcreate.Type,create.InstanceURL,create.APIURL,- create.ApplicationID,- create.Secret,+ create.AccessToken,).Scan(&vcsProvider.ID,&vcsProvider.Name,&vcsProvider.Type,&vcsProvider.InstanceURL,&vcsProvider.APIURL,- &vcsProvider.ApplicationID,- &vcsProvider.Secret,+ &vcsProvider.AccessToken,); err != nil {if err == sql.ErrNoRows {return nil, common.FormatDBErrorEmptyRowWithQuery(query)@@ -162,11 +155,8 @@ func (s *Store) UpdateVCSProviderV2(ctx context.Context, principalUID int, vcsPrif v := update.Name; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}- if v := update.ApplicationID; v != nil {- set, args = append(set, fmt.Sprintf("application_id = $%d", len(args)+1)), append(args, *v)- }- if v := update.Secret; v != nil {- set, args = append(set, fmt.Sprintf("secret = $%d", len(args)+1)), append(args, *v)+ if v := update.AccessToken; v != nil {+ set, args = append(set, fmt.Sprintf("access_token = $%d", len(args)+1)), append(args, *v)}args = append(args, vcsProviderUID)@@ -182,7 +172,7 @@ func (s *Store) UpdateVCSProviderV2(ctx context.Context, principalUID int, vcsPrUPDATE vcsSET `+strings.Join(set, ", ")+`WHERE id = $%d- RETURNING id, name, type, instance_url, api_url, application_id, secret+ RETURNING id, name, type, instance_url, api_url, access_token`, len(args)),args...,).Scan(@@ -191,8 +181,7 @@ func (s *Store) UpdateVCSProviderV2(ctx context.Context, principalUID int, vcsPr&vcsProvider.Type,&vcsProvider.InstanceURL,&vcsProvider.APIURL,- &vcsProvider.ApplicationID,- &vcsProvider.Secret,+ &vcsProvider.AccessToken,); err != nil {if err == sql.ErrNoRows {return nil, &common.Error{Code: common.NotFound, Err: errors.Errorf("vcs ID not found: %d", vcsProviderUID)}@@ -241,8 +230,7 @@ func (*Store) findVCSProvidersImplV2(ctx context.Context, tx *Tx, find *findVCSPtype,instance_url,api_url,- application_id,- secret+ access_tokenFROM vcsWHERE `+strings.Join(where, " AND "),args...,@@ -260,8 +248,7 @@ func (*Store) findVCSProvidersImplV2(ctx context.Context, tx *Tx, find *findVCSP&vcsProvider.Type,&vcsProvider.InstanceURL,&vcsProvider.APIURL,- &vcsProvider.ApplicationID,- &vcsProvider.Secret,+ &vcsProvider.AccessToken,); err != nil {return nil, err}diff --git a/backend/tests/schema_update_test.go b/backend/tests/schema_update_test.goindex a88c117675..14ae5fcf1a 100644--- a/backend/tests/schema_update_test.go+++ b/backend/tests/schema_update_test.go@@ -144,7 +144,7 @@ func TestSchemaAndDataUpdate(t *testing.T) {}}-func TestVCS(t *testing.T) {+func TestSimpleVCS(t *testing.T) {tests := []struct {name stringvcsProviderCreator fake.VCSProviderCreator@@ -304,12 +304,10 @@ func TestVCS(t *testing.T) {// Create a VCS.evcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: t.Name(),- Type: test.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testApplicationID",- Secret: "testApplicationSecret",+ Title: t.Name(),+ Type: test.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testApplicationSecret",},})a.NoError(err)@@ -331,8 +329,6 @@ func TestVCS(t *testing.T) {FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalId: test.externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})@@ -663,12 +659,10 @@ func TestVCS_SDL_POSTGRES(t *testing.T) {// Create a VCSevcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: t.Name(),- Type: test.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testApplicationID",- Secret: "testApplicationSecret",+ Title: t.Name(),+ Type: test.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testApplicationSecret",},})a.NoError(err)@@ -690,8 +684,6 @@ func TestVCS_SDL_POSTGRES(t *testing.T) {FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalId: test.externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})@@ -1104,12 +1096,10 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {// Create a VCS.evcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: t.Name(),- Type: test.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testApplicationID",- Secret: "testApplicationSecret",+ Title: t.Name(),+ Type: test.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testApplicationSecret",},})a.NoError(err)@@ -1131,8 +1121,6 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {FilePathTemplate: test.filePathTemplate,SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalId: externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})@@ -1335,12 +1323,10 @@ func TestVCS_SQL_Review(t *testing.T) {// Create a VCS.evcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: t.Name(),- Type: test.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testApplicationID",- Secret: "testApplicationSecret",+ Title: t.Name(),+ Type: test.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testApplicationSecret",},})a.NoError(err)@@ -1380,8 +1366,6 @@ func TestVCS_SQL_Review(t *testing.T) {FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalId: test.externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})@@ -1581,12 +1565,10 @@ func TestBranchNameInVCSSetupAndUpdate(t *testing.T) {// Create a VCS.evcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: "testName",- Type: vcsTest.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testID",- Secret: "testSecret",+ Title: "testName",+ Type: vcsTest.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testSecret",},})a.NoError(err)@@ -1616,8 +1598,6 @@ func TestBranchNameInVCSSetupAndUpdate(t *testing.T) {FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: "",ExternalId: vcsTest.externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})@@ -2136,12 +2116,10 @@ func TestVCS_SDL_MySQL(t *testing.T) {// Create a VCSevcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: t.Name(),- Type: test.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testApplicationID",- Secret: "testApplicationSecret",+ Title: t.Name(),+ Type: test.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testApplicationSecret",},})a.NoError(err)@@ -2178,8 +2156,6 @@ func TestVCS_SDL_MySQL(t *testing.T) {FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalId: test.externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})diff --git a/backend/tests/tenant_test.go b/backend/tests/tenant_test.goindex 429b699ffa..25430737d7 100644--- a/backend/tests/tenant_test.go+++ b/backend/tests/tenant_test.go@@ -285,12 +285,10 @@ func TestTenantVCS(t *testing.T) {// Create a VCS.evcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: t.Name(),- Type: test.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testApplicationID",- Secret: "testApplicationSecret",+ Title: t.Name(),+ Type: test.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testApplicationSecret",},})a.NoError(err)@@ -327,8 +325,6 @@ func TestTenantVCS(t *testing.T) {FilePathTemplate: "{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: ".LATEST.sql",ExternalId: test.externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})@@ -601,12 +597,10 @@ func TestTenantVCS_YAML(t *testing.T) {// Create a VCS.evcs, err := ctl.evcsClient.CreateVCSProvider(ctx, &v1pb.CreateVCSProviderRequest{VcsProvider: &v1pb.VCSProvider{- Title: t.Name(),- Type: test.vcsType,- Url: ctl.vcsURL,- ApiUrl: ctl.vcsProvider.APIURL(ctl.vcsURL),- ApplicationId: "testApplicationID",- Secret: "testApplicationSecret",+ Title: t.Name(),+ Type: test.vcsType,+ Url: ctl.vcsURL,+ AccessToken: "testApplicationSecret",},})a.NoError(err)@@ -641,8 +635,6 @@ func TestTenantVCS_YAML(t *testing.T) {FilePathTemplate: "{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: ".LATEST.sql",ExternalId: test.externalID,- AccessToken: "accessToken1",- RefreshToken: "refreshToken1",},AllowMissing: true,})diff --git a/backend/utils/utils.go b/backend/utils/utils.goindex d988201ea7..2e17e31663 100644--- a/backend/utils/utils.go+++ b/backend/utils/utils.go@@ -158,19 +158,6 @@ func GetDatabaseMatrixFromDeploymentSchedule(schedule *api.DeploymentSchedule, dreturn matrix, nil}-// RefreshToken is a token refresher that stores the latest access token configuration to repository.-func RefreshToken(ctx context.Context, s *store.Store, webURL string) common.TokenRefresher {- return func(token, refreshToken string, expiresTs int64) error {- _, err := s.PatchRepositoryV2(ctx, &store.PatchRepositoryMessage{- WebURL: &webURL,- AccessToken: &token,- ExpiresTs: &expiresTs,- RefreshToken: &refreshToken,- }, api.SystemBotID)- return err- }-}-// GetTaskSheetID gets the sheetID of a task.func GetTaskSheetID(taskPayload string) (int, error) {var taskSheetID struct {diff --git a/frontend/src/components/RepositorySelectionPanel.vue b/frontend/src/components/RepositorySelectionPanel.vueindex 267925c908..3bb60bed9d 100644--- a/frontend/src/components/RepositorySelectionPanel.vue+++ b/frontend/src/components/RepositorySelectionPanel.vue@@ -40,11 +40,10 @@ export default { name: "RepositorySelectionPanel" };</script><script setup lang="ts">-import { reactive, computed, onMounted, nextTick } from "vue";+import { reactive, computed, onMounted } from "vue";import { ExternalRepositoryInfo, ProjectRepositoryConfig } from "@/types";import { pushNotification, useCurrentUserV1, useVCSV1Store } from "@/store";import {- OAuthToken,VCSProvider_Type,SearchVCSProviderProjectsResponse_Project,} from "@/types/proto/v1/vcs_provider_service";@@ -59,7 +58,6 @@ const props = defineProps<{ config: ProjectRepositoryConfig }>();const emit = defineEmits<{(event: "next"): void;- (event: "set-token", payload: OAuthToken): void;(event: "set-repository", payload: ExternalRepositoryInfo): void;}>();@@ -75,17 +73,7 @@ onMounted(() => {});const prepareRepositoryList = () => {- vcsV1Store- .exchangeToken({- vcsName: props.config.vcs.name,- code: props.config.code,- })- .then((token: OAuthToken) => {- emit("set-token", token);- nextTick(() => {- refreshRepositoryList();- });- });+ refreshRepositoryList();};const refreshRepositoryList = async () => {@@ -104,9 +92,7 @@ const refreshRepositoryList = async () => {}const projects = await vcsV1Store.listVCSExternalProjects(- props.config.vcs.name,- props.config.token.accessToken,- props.config.token.refreshToken+ props.config.vcs.name);state.repositoryList = projects;};diff --git a/frontend/src/components/RepositorySetupWizard.vue b/frontend/src/components/RepositorySetupWizard.vueindex 2353934593..72bfe4ea55 100644--- a/frontend/src/components/RepositorySetupWizard.vue+++ b/frontend/src/components/RepositorySetupWizard.vue@@ -34,7 +34,6 @@<RepositorySelectionPanel:config="state.config"@next="next()"- @set-token="setToken"@set-repository="setRepository"/></template>@@ -145,7 +144,6 @@ import {SchemaChange,} from "@/types/proto/v1/project_service";import {- OAuthToken,ProjectGitOpsInfo,VCSProvider,VCSProvider_Type,@@ -219,10 +217,6 @@ const state = reactive<LocalState>({config: {vcs: {} as VCSProvider,code: "",- token: OAuthToken.fromPartial({- accessToken: "",- refreshToken: "",- }),repositoryInfo: {externalId: "",name: "",@@ -325,9 +319,6 @@ const tryFinishSetup = async () => {schemaPathTemplate: state.config.repositoryConfig.schemaPathTemplate,sheetPathTemplate: state.config.repositoryConfig.sheetPathTemplate,externalId: externalId,- accessToken: state.config.token.accessToken,- expiresTime: state.config.token.expiresTime,- refreshToken: state.config.token.refreshToken,enableSqlReviewCi: false,};await repositoryV1Store.upsertRepository(@@ -381,10 +372,6 @@ const setCode = (code: string) => {state.config.code = code;};-const setToken = (token: OAuthToken) => {- state.config.token = token;-};-const setVCS = (vcs: VCSProvider) => {state.config.vcs = vcs;};diff --git a/frontend/src/components/RepositoryVCSProviderPanel.vue b/frontend/src/components/RepositoryVCSProviderPanel.vueindex 0ca68ece65..1f7f962afe 100644--- a/frontend/src/components/RepositoryVCSProviderPanel.vue+++ b/frontend/src/components/RepositoryVCSProviderPanel.vue@@ -36,15 +36,10 @@ export default { name: "RepositoryVCSProviderPanel" };</script><script setup lang="ts">-import { reactive, computed, watchEffect, onUnmounted, onMounted } from "vue";-import isEmpty from "lodash-es/isEmpty";-import { OAuthWindowEventPayload, openWindowForOAuth } from "@/types";+import { reactive, computed, watchEffect } from "vue";import { hasWorkspacePermissionV2 } from "@/utils";-import { pushNotification, useCurrentUserV1, useVCSV1Store } from "@/store";-import {- VCSProvider,- VCSProvider_Type,-} from "@/types/proto/v1/vcs_provider_service";+import { useCurrentUserV1, useVCSV1Store } from "@/store";+import { VCSProvider } from "@/types/proto/v1/vcs_provider_service";interface LocalState {selectedVCS?: VCSProvider;@@ -67,31 +62,10 @@ const prepareVCSList = () => {watchEffect(prepareVCSList);-onMounted(() => {- window.addEventListener("bb.oauth.link-vcs-repository", eventListener, false);-});-onUnmounted(() => {- window.removeEventListener("bb.oauth.link-vcs-repository", eventListener);-});-const vcsList = computed(() => {return vcsV1Store.getVCSList();});-const eventListener = (event: Event) => {- const payload = (event as CustomEvent).detail as OAuthWindowEventPayload;- if (isEmpty(payload.error)) {- emit("set-code", payload.code);- emit("next");- } else {- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: payload.error,- });- }-};-const canManageVCSProvider = computed(() => {return hasWorkspacePermissionV2(currentUserV1.value, "bb.vcsProviders.list");});@@ -99,20 +73,6 @@ const canManageVCSProvider = computed(() => {const selectVCS = (vcs: VCSProvider) => {state.selectedVCS = vcs;emit("set-vcs", vcs);-- let authorizeUrl = `${vcs.url}/oauth/authorize`;- if (vcs.type === VCSProvider_Type.GITHUB) {- authorizeUrl = `${vcs.url}/login/oauth/authorize`;- } else if (vcs.type === VCSProvider_Type.BITBUCKET) {- authorizeUrl = `https://bitbucket.org/site/oauth2/authorize`;- } else if (vcs.type === VCSProvider_Type.AZURE_DEVOPS) {- authorizeUrl = "https://app.vssps.visualstudio.com/oauth2/authorize";- }- openWindowForOAuth(- authorizeUrl,- vcs.applicationId,- "bb.oauth.link-vcs-repository",- vcs.type- );+ emit("next");};</script>diff --git a/frontend/src/components/VCS/VCSCard.vue b/frontend/src/components/VCS/VCSCard.vueindex 81f804194e..a4fae80467 100644--- a/frontend/src/components/VCS/VCSCard.vue+++ b/frontend/src/components/VCS/VCSCard.vue@@ -23,14 +23,6 @@{{ vcs.url }}</dd></div>- <div class="grid grid-cols-4 gap-4 px-4 py-2 items-center">- <dt class="text-sm font-medium text-control-light">- {{ $t("common.application") }} ID- </dt>- <dd class="mt-1 flex text-sm text-main col-span-2">- {{ vcs.applicationId }}- </dd>- </div></dl></div></div>diff --git a/frontend/src/components/VCS/VCSProviderConfirmPanel.vue b/frontend/src/components/VCS/VCSProviderConfirmPanel.vuedeleted file mode 100644index 06c378846e..0000000000--- a/frontend/src/components/VCS/VCSProviderConfirmPanel.vue+++ /dev/null@@ -1,82 +0,0 @@-<template>- <div class="m-4 flex justify-center">- <dl- class="divide-y divide-block-border border border-block-border shadow rounded-lg"- >- <div class="px-4 py-4 sm:px-6">- <h3 class="text-lg leading-6 font-medium text-main">- {{ $t("gitops.setting.add-git-provider.confirm.confirm-info") }}- </h3>- <p class="mt-1 textinfolabel">- {{- $t("gitops.setting.add-git-provider.confirm.confirm-description")- }}- </p>- </div>- <div class="grid grid-cols-4 gap-4 px-4 py-2">- <dt class="text-sm font-medium text-control-light text-right">- {{ $t("common.type") }}- </dt>- <dd class="col-start-2 col-span-3 text-sm text-main">- <div- v-if="vcsWithUIType"- class="flex flex-row items-center space-x-2"- >- <VCSIcon custom-class="h-6" :type="vcsWithUIType.type" />- <div class="whitespace-nowrap">- {{ vcsWithUIType.title }}- </div>- </div>- </dd>- </div>- <div class="grid grid-cols-4 gap-4 px-4 py-2">- <dt class="text-sm font-medium text-control-light text-right">- {{ $t("common.name") }}- </dt>- <dd class="col-start-2 col-span-3 text-sm text-main">- {{ config.name }}- </dd>- </div>- <div class="grid grid-cols-4 gap-4 px-4 py-2">- <dt class="text-sm font-medium text-control-light text-right">- {{ $t("common.instance") }} URL- </dt>- <dd class="col-start-2 col-span-3 text-sm text-main">- {{ config.instanceUrl }}- </dd>- </div>- <div class="grid grid-cols-4 gap-4 px-4 py-2">- <dt class="text-sm font-medium text-control-light text-right">- {{ $t("common.application") }} ID- </dt>- <dd class="col-start-2 col-span-3 text-sm text-main">- {{ config.applicationId }}- </dd>- </div>- <div class="grid grid-cols-4 gap-4 px-4 py-2">- <dt class="text-sm font-medium text-control-light text-right">- Secret- </dt>- <dd class="col-start-2 col-span-3 text-sm text-main break-all">- {{ config.secret }}- </dd>- </div>- </dl>- </div>-</template>--<script lang="ts" setup>-import { computed } from "vue";-import { VCSConfig } from "@/types";-import { vcsListByUIType } from "./utils";--const props = defineProps<{- config: VCSConfig;-}>();--const vcsWithUIType = computed(() => {- return vcsListByUIType.value.find(- (data) => data.uiType === props.config.uiType- );-});-</script>diff --git a/frontend/src/components/VCS/VCSProviderOAuthPanel.vue b/frontend/src/components/VCS/VCSProviderOAuthPanel.vueindex f906aa4bed..e57b48f678 100644--- a/frontend/src/components/VCS/VCSProviderOAuthPanel.vue+++ b/frontend/src/components/VCS/VCSProviderOAuthPanel.vue@@ -518,80 +518,31 @@</template></ol><div>- <div class="textlabel">- {{ $t("common.application") }} ID <span class="text-red-600">*</span>- </div>- <BBTextField- class="mt-2 w-full"- :placeholder="'ex. 5333b60a6c9f234272dac2ee6b3422aaf224e0a66def54e0d243b77bexa8edda'"- :value="config.applicationId"- @update:value="changeApplicationId($event)"- />- <p v-if="state.showApplicationIdError" class="mt-2 text-sm text-error">- {{ applicationIdErrorDescription }}- </p><div class="mt-4 textlabel">- {{ secretField }} <span class="text-red-600">*</span>+ Access Token <span class="text-red-600">*</span></div><BBTextFieldclass="mt-2 w-full":placeholder="'ex. b9e0efc7a233403799b42620c60ff98c146895a27b6219912a215f4e2251cc3a'"- :value="config.secret"- @update:value="changeSecret($event)"+ :value="config.accessToken"+ @update:value="changeAccessToken($event)"/>- <p v-if="state.showSecretError" class="mt-2 text-sm text-error">- {{ secretErrorDescription }}- </p></div></div></template><script lang="ts" setup>-import { isEmpty } from "lodash-es";-import { computed, onUnmounted, reactive } from "vue";+import { computed } from "vue";import { useI18n } from "vue-i18n";import { pushNotification } from "@/store";-import {- isValidVCSApplicationIdOrSecret,- TEXT_VALIDATION_DELAY,- VCSConfig,- redirectUrl,-} from "@/types";-import { VCSProvider_Type } from "@/types/proto/v1/vcs_provider_service";+import { VCSConfig, redirectUrl } from "@/types";import { toClipboard } from "@/utils";-interface LocalState {- applicationIdValidationTimer?: ReturnType<typeof setTimeout>;- showApplicationIdError: boolean;- secretValidationTimer?: ReturnType<typeof setTimeout>;- showSecretError: boolean;-}-const props = defineProps<{config: VCSConfig;}>();const { t } = useI18n();-const state = reactive<LocalState>({- showApplicationIdError:- !isEmpty(props.config.applicationId) &&- !isValidVCSApplicationIdOrSecret(- props.config.type,- props.config.applicationId- ),- showSecretError:- !isEmpty(props.config.secret) &&- !isValidVCSApplicationIdOrSecret(props.config.type, props.config.secret),-});--onUnmounted(() => {- if (state.applicationIdValidationTimer) {- clearInterval(state.applicationIdValidationTimer);- }- if (state.secretValidationTimer) {- clearInterval(state.secretValidationTimer);- }-});const createOAuthApplicationUrl = computed((): string => {if (props.config.uiType == "GITLAB_SELF_HOST") {@@ -626,112 +577,8 @@ const copyRedirectURI = () => {});};-const changeApplicationId = (value: string) => {- // eslint-disable-next-line vue/no-mutating-props- props.config.applicationId = value;-- if (state.applicationIdValidationTimer) {- clearInterval(state.applicationIdValidationTimer);- }- // If text becomes valid, we immediately clear the error.- // otherwise, we delay TEXT_VALIDATION_DELAY to do the validation in case there is continous keystroke.- if (- isValidVCSApplicationIdOrSecret(- props.config.type,- props.config.applicationId- )- ) {- state.showApplicationIdError = false;- } else {- state.applicationIdValidationTimer = setTimeout(() => {- // If error is already displayed, we hide the error only if there is valid input.- // Otherwise, we hide the error if input is either empty or valid.- if (state.showApplicationIdError) {- state.showApplicationIdError = !isValidVCSApplicationIdOrSecret(- props.config.type,- props.config.applicationId- );- } else {- state.showApplicationIdError =- !isValidVCSApplicationIdOrSecret(- props.config.type,- props.config.applicationId- ) &&- !isValidVCSApplicationIdOrSecret(- props.config.type,- props.config.applicationId- );- }- }, TEXT_VALIDATION_DELAY);- }-};--const changeSecret = (value: string) => {+const changeAccessToken = (value: string) => {// eslint-disable-next-line vue/no-mutating-props- props.config.secret = value;-- if (state.secretValidationTimer) {- clearInterval(state.secretValidationTimer);- }- // If text becomes valid, we immediately clear the error.- // otherwise, we delay TEXT_VALIDATION_DELAY to do the validation in case there is continous keystroke.- if (isValidVCSApplicationIdOrSecret(props.config.type, props.config.secret)) {- state.showSecretError = false;- } else {- state.secretValidationTimer = setTimeout(() => {- // If error is already displayed, we hide the error only if there is valid input.- // Otherwise, we hide the error if input is either empty or valid.- if (state.showSecretError) {- state.showSecretError = !isValidVCSApplicationIdOrSecret(- props.config.type,- props.config.secret- );- } else {- state.showSecretError =- !isEmpty(props.config.secret) &&- !isValidVCSApplicationIdOrSecret(- props.config.type,- props.config.secret- );- }- }, TEXT_VALIDATION_DELAY);- }+ props.config.accessToken = value;};--const applicationIdErrorDescription = computed((): string => {- if (props.config.type === VCSProvider_Type.GITLAB) {- return t(- "gitops.setting.add-git-provider.oauth-info.gitlab-application-id-error"- );- } else if (props.config.type === VCSProvider_Type.GITHUB) {- return t(- "gitops.setting.add-git-provider.oauth-info.github-application-id-error"- );- } else if (props.config.type === VCSProvider_Type.BITBUCKET) {- return t(- "gitops.setting.add-git-provider.oauth-info.bitbucket-application-id-error"- );- }- return "";-});--const secretErrorDescription = computed((): string => {- if (props.config.type === VCSProvider_Type.GITLAB) {- return t("gitops.setting.add-git-provider.oauth-info.gitlab-secret-error");- } else if (props.config.type === VCSProvider_Type.GITHUB) {- return t("gitops.setting.add-git-provider.oauth-info.github-secret-error");- } else if (props.config.type === VCSProvider_Type.BITBUCKET) {- return t(- "gitops.setting.add-git-provider.oauth-info.bitbucket-secret-error"- );- }- return "";-});--const secretField = computed(() => {- if (props.config.type === VCSProvider_Type.AZURE_DEVOPS) {- return "Client Secret";- }- return "Secret";-});</script>diff --git a/frontend/src/components/VCS/VCSSetupWizard.vue b/frontend/src/components/VCS/VCSSetupWizard.vueindex 1388b11a46..9bd29945dc 100644--- a/frontend/src/components/VCS/VCSSetupWizard.vue+++ b/frontend/src/components/VCS/VCSSetupWizard.vue@@ -22,34 +22,22 @@<template #1><VCSProviderOAuthPanel :config="state.config" /></template>- <template #2>- <VCSProviderConfirmPanel :config="state.config" />- </template></StepTab></template><script lang="ts" setup>-import isEmpty from "lodash-es/isEmpty";-import { reactive, computed, onUnmounted, onMounted } from "vue";+import { reactive, computed } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { StepTab } from "@/components/v2";import { WORKSPACE_ROUTE_GITOPS } from "@/router/dashboard/workspaceRoutes";import { pushNotification, useVCSV1Store } from "@/store";+import { VCSConfig } from "@/types";import {- isValidVCSApplicationIdOrSecret,- VCSConfig,- openWindowForOAuth,- OAuthWindowEventPayload,-} from "@/types";-import {- OAuthToken,VCSProvider,VCSProvider_Type,} from "@/types/proto/v1/vcs_provider_service";-import { isUrl } from "@/utils";import VCSProviderBasicInfoPanel from "./VCSProviderBasicInfoPanel.vue";-import VCSProviderConfirmPanel from "./VCSProviderConfirmPanel.vue";import VCSProviderOAuthPanel from "./VCSProviderOAuthPanel.vue";withDefaults(@@ -61,14 +49,11 @@ withDefaults(});-const BASIC_INFO_STEP = 0;-const OAUTH_INFO_STEP = 1;-const CONFIRM_STEP = 2;+const CONFIRM_STEP = 1;interface LocalState {config: VCSConfig;currentStep: number;- oAuthResultCallback?: (token: OAuthToken | undefined) => void;}const { t } = useI18n();@@ -77,7 +62,6 @@ const vcsV1Store = useVCSV1Store();const stepList = [{ title: t("gitops.setting.add-git-provider.basic-info.self") },- { title: t("gitops.setting.add-git-provider.oauth-info.self") },{ title: t("common.confirm") },];@@ -87,61 +71,12 @@ const state = reactive<LocalState>({uiType: "GITLAB_SELF_HOST",name: t("gitops.setting.add-git-provider.gitlab-self-host"),instanceUrl: "",- applicationId: "",- secret: "",+ accessToken: "",},currentStep: 0,});-onMounted(() => {- window.addEventListener("bb.oauth.register-vcs", eventListener, false);-});--onUnmounted(() => {- window.removeEventListener("bb.oauth.register-vcs", eventListener);-});--const eventListener = (event: Event) => {- const payload = (event as CustomEvent).detail as OAuthWindowEventPayload;- if (isEmpty(payload.error)) {- if (- state.config.type === VCSProvider_Type.GITLAB ||- state.config.type === VCSProvider_Type.GITHUB ||- state.config.type === VCSProvider_Type.BITBUCKET ||- state.config.type === VCSProvider_Type.AZURE_DEVOPS- ) {- vcsV1Store- .exchangeToken({- vcsType: state.config.type,- instanceUrl: state.config.instanceUrl,- clientId: state.config.applicationId,- clientSecret: state.config.secret,- code: payload.code,- })- .then((token: OAuthToken) => {- state.oAuthResultCallback!(token);- })- .catch(() => {- state.oAuthResultCallback!(undefined);- });- }- } else {- state.oAuthResultCallback!(undefined);- }-};-const allowNext = computed((): boolean => {- if (state.currentStep == BASIC_INFO_STEP) {- return isUrl(state.config.instanceUrl);- } else if (state.currentStep == OAUTH_INFO_STEP) {- return (- isValidVCSApplicationIdOrSecret(- state.config.type,- state.config.applicationId- ) &&- isValidVCSApplicationIdOrSecret(state.config.type, state.config.secret)- );- }return true;});@@ -187,59 +122,7 @@ const showAttention = computed((): boolean => {});const tryChangeStep = (nextStepIndex: number) => {- // If we are trying to move from OAuth step to Confirm step, we first verify- // the OAuth info is correct. We achieve this by:- // 1. Kicking of the OAuth workflow to verify the current user can login to the GitLab instance and the application id is correct.- // 2. If step 1 succeeds, we will get a code, we use this code together with the secret to exchange for the access token. (see eventListener)- if (- state.currentStep == OAUTH_INFO_STEP &&- nextStepIndex > state.currentStep- ) {- let authorizeUrl = `${state.config.instanceUrl}/oauth/authorize`;- if (state.config.type === VCSProvider_Type.GITHUB) {- authorizeUrl = `${state.config.instanceUrl}/login/oauth/authorize`;- } else if (state.config.type === VCSProvider_Type.BITBUCKET) {- authorizeUrl = `https://bitbucket.org/site/oauth2/authorize`;- } else if (state.config.type === VCSProvider_Type.AZURE_DEVOPS) {- authorizeUrl = "https://app.vssps.visualstudio.com/oauth2/authorize";- }- const newWindow = openWindowForOAuth(- authorizeUrl,- state.config.applicationId,- "bb.oauth.register-vcs",- state.config.type- );- if (newWindow) {- state.oAuthResultCallback = (token: OAuthToken | undefined) => {- if (token) {- state.currentStep = nextStepIndex;- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("gitops.setting.add-git-provider.oauth-info-correct"),- });- } else {- let description = "";- if (state.config.type == VCSProvider_Type.GITLAB) {- // If application id mismatches, the OAuth workflow will stop early.- // So the only possibility to reach here is we have a matching application id, while- // we failed to exchange a token, and it's likely we are requesting with a wrong secret.- description = t(- "gitops.setting.add-git-provider.check-oauth-info-match"- );- }- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: "Failed to setup OAuth",- description: description,- });- }- };- }- } else {- state.currentStep = nextStepIndex;- }+ state.currentStep = nextStepIndex;};const tryFinishSetup = () => {@@ -249,9 +132,7 @@ const tryFinishSetup = () => {title: state.config.name,type: state.config.type,url: state.config.instanceUrl,- applicationId: state.config.applicationId,- secret: state.config.secret,- apiUrl: "",+ accessToken: state.config.accessToken,}).then((vcs: VCSProvider) => {router.push({diff --git a/frontend/src/store/modules/v1/vcs.ts b/frontend/src/store/modules/v1/vcs.tsindex 832848e06c..957b7ba7b6 100644--- a/frontend/src/store/modules/v1/vcs.ts+++ b/frontend/src/store/modules/v1/vcs.ts@@ -12,15 +12,9 @@ import { vcsProviderPrefix } from "./common";export const useVCSV1Store = defineStore("vcs_v1", () => {const vcsMapByName = reactive(new Map<string, VCSProvider>());- const listVCSExternalProjects = async (- vcsName: string,- accessToken: string,- refreshToken: string- ) => {+ const listVCSExternalProjects = async (vcsName: string) => {const resp = await vcsProviderServiceClient.searchVCSProviderProjects({name: vcsName,- accessToken,- refreshToken,});return resp.projects;};@@ -138,10 +132,10 @@ const getUpdateMaskForVCS = (updateMask.push("title");}if (- !isUndefined(update.applicationId) &&- !isEqual(origin.applicationId, update.applicationId)+ !isUndefined(update.accessToken) &&+ !isEqual(origin.accessToken, update.accessToken)) {- updateMask.push("application_id");+ updateMask.push("access_token");}return updateMask;};diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.tsindex f257a51965..17333cf3ab 100644--- a/frontend/src/types/project.ts+++ b/frontend/src/types/project.ts@@ -1,5 +1,5 @@import { SchemaChange } from "@/types/proto/v1/project_service";-import { OAuthToken, VCSProvider } from "@/types/proto/v1/vcs_provider_service";+import { VCSProvider } from "@/types/proto/v1/vcs_provider_service";import { RowStatus } from "./common";import { ProjectId } from "./id";import { Principal } from "./principal";@@ -45,8 +45,6 @@ export type ProjectMember = {export type ProjectRepositoryConfig = {vcs: VCSProvider;- // TODO(zilong): get rid of the token in the frontend.- token: OAuthToken;code: string;repositoryInfo: ExternalRepositoryInfo;repositoryConfig: RepositoryConfig;diff --git a/frontend/src/types/proto/v1/vcs_provider_service.ts b/frontend/src/types/proto/v1/vcs_provider_service.tsindex 25c99b702c..968ad68485 100644--- a/frontend/src/types/proto/v1/vcs_provider_service.ts+++ b/frontend/src/types/proto/v1/vcs_provider_service.ts@@ -3,7 +3,6 @@ import Long from "long";import _m0 from "protobufjs/minimal";import { Empty } from "../google/protobuf/empty";import { FieldMask } from "../google/protobuf/field_mask";-import { Timestamp } from "../google/protobuf/timestamp";export const protobufPackage = "bytebase.v1";@@ -65,8 +64,6 @@ export interface SearchVCSProviderProjectsRequest {* Format: vcsProviders/{vcsProvider}*/name: string;- accessToken: string;- refreshToken: string;}export interface SearchVCSProviderProjectsResponse {@@ -112,12 +109,8 @@ export interface VCSProvider {* For example: github.com, gitlab.com, gitlab.bytebase.com.*/url: string;- /** The API url of the vcs provider. Derived from the url. */- apiUrl: string;- /** The application ID of the vcs provider. Specified by the client. */- applicationId: string;- /** The application secret of the vcs provider. Specified by the client. */- secret: string;+ /** The access token of the vcs provider. */+ accessToken: string;}export enum VCSProvider_Type {@@ -206,43 +199,12 @@ export interface ProjectGitOpsInfo {* If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}.*/schemaPathTemplate: string;- /**- * The file path template for matching the sql files for sheet.- * If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}.- */- sheetPathTemplate: string;/** The reposition external id in target VCS. */externalId: string;/** Set to true to enable SQL review CI for all PR/MRs. */enableSqlReviewCi: boolean;/** The webhook endpoint ID of the repository. */webhookEndpointId: string;- accessToken: string;- expiresTime: Date | undefined;- refreshToken: string;-}--export interface ExchangeTokenRequest {- exchangeToken: ExchangeToken | undefined;-}--export interface ExchangeToken {- /**- * The name of the vcs provider to retrieve the linked projects.- * Format: vcsProviders/{vcsProvider}- */- name: string;- code: string;- type: VCSProvider_Type;- instanceUrl: string;- clientId: string;- clientSecret: string;-}--export interface OAuthToken {- accessToken: string;- refreshToken: string;- expiresTime: Date | undefined;}function createBaseCreateVCSProviderRequest(): CreateVCSProviderRequest {@@ -645,7 +607,7 @@ export const DeleteVCSProviderRequest = {};function createBaseSearchVCSProviderProjectsRequest(): SearchVCSProviderProjectsRequest {- return { name: "", accessToken: "", refreshToken: "" };+ return { name: "" };}export const SearchVCSProviderProjectsRequest = {@@ -653,12 +615,6 @@ export const SearchVCSProviderProjectsRequest = {if (message.name !== "") {writer.uint32(10).string(message.name);}- if (message.accessToken !== "") {- writer.uint32(18).string(message.accessToken);- }- if (message.refreshToken !== "") {- writer.uint32(26).string(message.refreshToken);- }return writer;},@@ -676,20 +632,6 @@ export const SearchVCSProviderProjectsRequest = {message.name = reader.string();continue;- case 2:- if (tag !== 18) {- break;- }-- message.accessToken = reader.string();- continue;- case 3:- if (tag !== 26) {- break;- }-- message.refreshToken = reader.string();- continue;}if ((tag & 7) === 4 || tag === 0) {break;@@ -700,11 +642,7 @@ export const SearchVCSProviderProjectsRequest = {},fromJSON(object: any): SearchVCSProviderProjectsRequest {- return {- name: isSet(object.name) ? globalThis.String(object.name) : "",- accessToken: isSet(object.accessToken) ? globalThis.String(object.accessToken) : "",- refreshToken: isSet(object.refreshToken) ? globalThis.String(object.refreshToken) : "",- };+ return { name: isSet(object.name) ? globalThis.String(object.name) : "" };},toJSON(message: SearchVCSProviderProjectsRequest): unknown {@@ -712,12 +650,6 @@ export const SearchVCSProviderProjectsRequest = {if (message.name !== "") {obj.name = message.name;}- if (message.accessToken !== "") {- obj.accessToken = message.accessToken;- }- if (message.refreshToken !== "") {- obj.refreshToken = message.refreshToken;- }return obj;},@@ -727,8 +659,6 @@ export const SearchVCSProviderProjectsRequest = {fromPartial(object: DeepPartial<SearchVCSProviderProjectsRequest>): SearchVCSProviderProjectsRequest {const message = createBaseSearchVCSProviderProjectsRequest();message.name = object.name ?? "";- message.accessToken = object.accessToken ?? "";- message.refreshToken = object.refreshToken ?? "";return message;},};@@ -1019,7 +949,7 @@ export const ListProjectGitOpsInfoResponse = {};function createBaseVCSProvider(): VCSProvider {- return { name: "", title: "", type: 0, url: "", apiUrl: "", applicationId: "", secret: "" };+ return { name: "", title: "", type: 0, url: "", accessToken: "" };}export const VCSProvider = {@@ -1036,14 +966,8 @@ export const VCSProvider = {if (message.url !== "") {writer.uint32(34).string(message.url);}- if (message.apiUrl !== "") {- writer.uint32(42).string(message.apiUrl);- }- if (message.applicationId !== "") {- writer.uint32(50).string(message.applicationId);- }- if (message.secret !== "") {- writer.uint32(58).string(message.secret);+ if (message.accessToken !== "") {+ writer.uint32(42).string(message.accessToken);}return writer;},@@ -1088,21 +1012,7 @@ export const VCSProvider = {break;}- message.apiUrl = reader.string();- continue;- case 6:- if (tag !== 50) {- break;- }-- message.applicationId = reader.string();- continue;- case 7:- if (tag !== 58) {- break;- }-- message.secret = reader.string();+ message.accessToken = reader.string();continue;}if ((tag & 7) === 4 || tag === 0) {@@ -1119,9 +1029,7 @@ export const VCSProvider = {title: isSet(object.title) ? globalThis.String(object.title) : "",type: isSet(object.type) ? vCSProvider_TypeFromJSON(object.type) : 0,url: isSet(object.url) ? globalThis.String(object.url) : "",- apiUrl: isSet(object.apiUrl) ? globalThis.String(object.apiUrl) : "",- applicationId: isSet(object.applicationId) ? globalThis.String(object.applicationId) : "",- secret: isSet(object.secret) ? globalThis.String(object.secret) : "",+ accessToken: isSet(object.accessToken) ? globalThis.String(object.accessToken) : "",};},@@ -1139,14 +1047,8 @@ export const VCSProvider = {if (message.url !== "") {obj.url = message.url;}- if (message.apiUrl !== "") {- obj.apiUrl = message.apiUrl;- }- if (message.applicationId !== "") {- obj.applicationId = message.applicationId;- }- if (message.secret !== "") {- obj.secret = message.secret;+ if (message.accessToken !== "") {+ obj.accessToken = message.accessToken;}return obj;},@@ -1160,9 +1062,7 @@ export const VCSProvider = {message.title = object.title ?? "";message.type = object.type ?? 0;message.url = object.url ?? "";- message.apiUrl = object.apiUrl ?? "";- message.applicationId = object.applicationId ?? "";- message.secret = object.secret ?? "";+ message.accessToken = object.accessToken ?? "";return message;},};@@ -1178,13 +1078,9 @@ function createBaseProjectGitOpsInfo(): ProjectGitOpsInfo {baseDirectory: "",filePathTemplate: "",schemaPathTemplate: "",- sheetPathTemplate: "",externalId: "",enableSqlReviewCi: false,webhookEndpointId: "",- accessToken: "",- expiresTime: undefined,- refreshToken: "",};}@@ -1217,9 +1113,6 @@ export const ProjectGitOpsInfo = {if (message.schemaPathTemplate !== "") {writer.uint32(74).string(message.schemaPathTemplate);}- if (message.sheetPathTemplate !== "") {- writer.uint32(82).string(message.sheetPathTemplate);- }if (message.externalId !== "") {writer.uint32(90).string(message.externalId);}@@ -1229,15 +1122,6 @@ export const ProjectGitOpsInfo = {if (message.webhookEndpointId !== "") {writer.uint32(106).string(message.webhookEndpointId);}- if (message.accessToken !== "") {- writer.uint32(114).string(message.accessToken);- }- if (message.expiresTime !== undefined) {- Timestamp.encode(toTimestamp(message.expiresTime), writer.uint32(122).fork()).ldelim();- }- if (message.refreshToken !== "") {- writer.uint32(130).string(message.refreshToken);- }return writer;},@@ -1311,13 +1195,6 @@ export const ProjectGitOpsInfo = {message.schemaPathTemplate = reader.string();continue;- case 10:- if (tag !== 82) {- break;- }-- message.sheetPathTemplate = reader.string();- continue;case 11:if (tag !== 90) {break;@@ -1339,27 +1216,6 @@ export const ProjectGitOpsInfo = {message.webhookEndpointId = reader.string();continue;- case 14:- if (tag !== 114) {- break;- }-- message.accessToken = reader.string();- continue;- case 15:- if (tag !== 122) {- break;- }-- message.expiresTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));- continue;- case 16:- if (tag !== 130) {- break;- }-- message.refreshToken = reader.string();- continue;}if ((tag & 7) === 4 || tag === 0) {break;@@ -1380,13 +1236,9 @@ export const ProjectGitOpsInfo = {baseDirectory: isSet(object.baseDirectory) ? globalThis.String(object.baseDirectory) : "",filePathTemplate: isSet(object.filePathTemplate) ? globalThis.String(object.filePathTemplate) : "",schemaPathTemplate: isSet(object.schemaPathTemplate) ? globalThis.String(object.schemaPathTemplate) : "",- sheetPathTemplate: isSet(object.sheetPathTemplate) ? globalThis.String(object.sheetPathTemplate) : "",externalId: isSet(object.externalId) ? globalThis.String(object.externalId) : "",enableSqlReviewCi: isSet(object.enableSqlReviewCi) ? globalThis.Boolean(object.enableSqlReviewCi) : false,webhookEndpointId: isSet(object.webhookEndpointId) ? globalThis.String(object.webhookEndpointId) : "",- accessToken: isSet(object.accessToken) ? globalThis.String(object.accessToken) : "",- expiresTime: isSet(object.expiresTime) ? fromJsonTimestamp(object.expiresTime) : undefined,- refreshToken: isSet(object.refreshToken) ? globalThis.String(object.refreshToken) : "",};},@@ -1419,9 +1271,6 @@ export const ProjectGitOpsInfo = {if (message.schemaPathTemplate !== "") {obj.schemaPathTemplate = message.schemaPathTemplate;}- if (message.sheetPathTemplate !== "") {- obj.sheetPathTemplate = message.sheetPathTemplate;- }if (message.externalId !== "") {obj.externalId = message.externalId;}@@ -1431,15 +1280,6 @@ export const ProjectGitOpsInfo = {if (message.webhookEndpointId !== "") {obj.webhookEndpointId = message.webhookEndpointId;}- if (message.accessToken !== "") {- obj.accessToken = message.accessToken;- }- if (message.expiresTime !== undefined) {- obj.expiresTime = message.expiresTime.toISOString();- }- if (message.refreshToken !== "") {- obj.refreshToken = message.refreshToken;- }return obj;},@@ -1457,295 +1297,9 @@ export const ProjectGitOpsInfo = {message.baseDirectory = object.baseDirectory ?? "";message.filePathTemplate = object.filePathTemplate ?? "";message.schemaPathTemplate = object.schemaPathTemplate ?? "";- message.sheetPathTemplate = object.sheetPathTemplate ?? "";message.externalId = object.externalId ?? "";message.enableSqlReviewCi = object.enableSqlReviewCi ?? false;message.webhookEndpointId = object.webhookEndpointId ?? "";- message.accessToken = object.accessToken ?? "";- message.expiresTime = object.expiresTime ?? undefined;- message.refreshToken = object.refreshToken ?? "";- return message;- },-};--function createBaseExchangeTokenRequest(): ExchangeTokenRequest {- return { exchangeToken: undefined };-}--export const ExchangeTokenRequest = {- encode(message: ExchangeTokenRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {- if (message.exchangeToken !== undefined) {- ExchangeToken.encode(message.exchangeToken, writer.uint32(10).fork()).ldelim();- }- return writer;- },-- decode(input: _m0.Reader | Uint8Array, length?: number): ExchangeTokenRequest {- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);- let end = length === undefined ? reader.len : reader.pos + length;- const message = createBaseExchangeTokenRequest();- while (reader.pos < end) {- const tag = reader.uint32();- switch (tag >>> 3) {- case 1:- if (tag !== 10) {- break;- }-- message.exchangeToken = ExchangeToken.decode(reader, reader.uint32());- continue;- }- if ((tag & 7) === 4 || tag === 0) {- break;- }- reader.skipType(tag & 7);- }- return message;- },-- fromJSON(object: any): ExchangeTokenRequest {- return { exchangeToken: isSet(object.exchangeToken) ? ExchangeToken.fromJSON(object.exchangeToken) : undefined };- },-- toJSON(message: ExchangeTokenRequest): unknown {- const obj: any = {};- if (message.exchangeToken !== undefined) {- obj.exchangeToken = ExchangeToken.toJSON(message.exchangeToken);- }- return obj;- },-- create(base?: DeepPartial<ExchangeTokenRequest>): ExchangeTokenRequest {- return ExchangeTokenRequest.fromPartial(base ?? {});- },- fromPartial(object: DeepPartial<ExchangeTokenRequest>): ExchangeTokenRequest {- const message = createBaseExchangeTokenRequest();- message.exchangeToken = (object.exchangeToken !== undefined && object.exchangeToken !== null)- ? ExchangeToken.fromPartial(object.exchangeToken)- : undefined;- return message;- },-};--function createBaseExchangeToken(): ExchangeToken {- return { name: "", code: "", type: 0, instanceUrl: "", clientId: "", clientSecret: "" };-}--export const ExchangeToken = {- encode(message: ExchangeToken, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {- if (message.name !== "") {- writer.uint32(10).string(message.name);- }- if (message.code !== "") {- writer.uint32(18).string(message.code);- }- if (message.type !== 0) {- writer.uint32(24).int32(message.type);- }- if (message.instanceUrl !== "") {- writer.uint32(34).string(message.instanceUrl);- }- if (message.clientId !== "") {- writer.uint32(42).string(message.clientId);- }- if (message.clientSecret !== "") {- writer.uint32(50).string(message.clientSecret);- }- return writer;- },-- decode(input: _m0.Reader | Uint8Array, length?: number): ExchangeToken {- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);- let end = length === undefined ? reader.len : reader.pos + length;- const message = createBaseExchangeToken();- while (reader.pos < end) {- const tag = reader.uint32();- switch (tag >>> 3) {- case 1:- if (tag !== 10) {- break;- }-- message.name = reader.string();- continue;- case 2:- if (tag !== 18) {- break;- }-- message.code = reader.string();- continue;- case 3:- if (tag !== 24) {- break;- }-- message.type = reader.int32() as any;- continue;- case 4:- if (tag !== 34) {- break;- }-- message.instanceUrl = reader.string();- continue;- case 5:- if (tag !== 42) {- break;- }-- message.clientId = reader.string();- continue;- case 6:- if (tag !== 50) {- break;- }-- message.clientSecret = reader.string();- continue;- }- if ((tag & 7) === 4 || tag === 0) {- break;- }- reader.skipType(tag & 7);- }- return message;- },-- fromJSON(object: any): ExchangeToken {- return {- name: isSet(object.name) ? globalThis.String(object.name) : "",- code: isSet(object.code) ? globalThis.String(object.code) : "",- type: isSet(object.type) ? vCSProvider_TypeFromJSON(object.type) : 0,- instanceUrl: isSet(object.instanceUrl) ? globalThis.String(object.instanceUrl) : "",- clientId: isSet(object.clientId) ? globalThis.String(object.clientId) : "",- clientSecret: isSet(object.clientSecret) ? globalThis.String(object.clientSecret) : "",- };- },-- toJSON(message: ExchangeToken): unknown {- const obj: any = {};- if (message.name !== "") {- obj.name = message.name;- }- if (message.code !== "") {- obj.code = message.code;- }- if (message.type !== 0) {- obj.type = vCSProvider_TypeToJSON(message.type);- }- if (message.instanceUrl !== "") {- obj.instanceUrl = message.instanceUrl;- }- if (message.clientId !== "") {- obj.clientId = message.clientId;- }- if (message.clientSecret !== "") {- obj.clientSecret = message.clientSecret;- }- return obj;- },-- create(base?: DeepPartial<ExchangeToken>): ExchangeToken {- return ExchangeToken.fromPartial(base ?? {});- },- fromPartial(object: DeepPartial<ExchangeToken>): ExchangeToken {- const message = createBaseExchangeToken();- message.name = object.name ?? "";- message.code = object.code ?? "";- message.type = object.type ?? 0;- message.instanceUrl = object.instanceUrl ?? "";- message.clientId = object.clientId ?? "";- message.clientSecret = object.clientSecret ?? "";- return message;- },-};--function createBaseOAuthToken(): OAuthToken {- return { accessToken: "", refreshToken: "", expiresTime: undefined };-}--export const OAuthToken = {- encode(message: OAuthToken, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {- if (message.accessToken !== "") {- writer.uint32(10).string(message.accessToken);- }- if (message.refreshToken !== "") {- writer.uint32(18).string(message.refreshToken);- }- if (message.expiresTime !== undefined) {- Timestamp.encode(toTimestamp(message.expiresTime), writer.uint32(122).fork()).ldelim();- }- return writer;- },-- decode(input: _m0.Reader | Uint8Array, length?: number): OAuthToken {- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);- let end = length === undefined ? reader.len : reader.pos + length;- const message = createBaseOAuthToken();- while (reader.pos < end) {- const tag = reader.uint32();- switch (tag >>> 3) {- case 1:- if (tag !== 10) {- break;- }-- message.accessToken = reader.string();- continue;- case 2:- if (tag !== 18) {- break;- }-- message.refreshToken = reader.string();- continue;- case 15:- if (tag !== 122) {- break;- }-- message.expiresTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));- continue;- }- if ((tag & 7) === 4 || tag === 0) {- break;- }- reader.skipType(tag & 7);- }- return message;- },-- fromJSON(object: any): OAuthToken {- return {- accessToken: isSet(object.accessToken) ? globalThis.String(object.accessToken) : "",- refreshToken: isSet(object.refreshToken) ? globalThis.String(object.refreshToken) : "",- expiresTime: isSet(object.expiresTime) ? fromJsonTimestamp(object.expiresTime) : undefined,- };- },-- toJSON(message: OAuthToken): unknown {- const obj: any = {};- if (message.accessToken !== "") {- obj.accessToken = message.accessToken;- }- if (message.refreshToken !== "") {- obj.refreshToken = message.refreshToken;- }- if (message.expiresTime !== undefined) {- obj.expiresTime = message.expiresTime.toISOString();- }- return obj;- },-- create(base?: DeepPartial<OAuthToken>): OAuthToken {- return OAuthToken.fromPartial(base ?? {});- },- fromPartial(object: DeepPartial<OAuthToken>): OAuthToken {- const message = createBaseOAuthToken();- message.accessToken = object.accessToken ?? "";- message.refreshToken = object.refreshToken ?? "";- message.expiresTime = object.expiresTime ?? undefined;return message;},};@@ -1962,95 +1516,6 @@ export const VCSProviderServiceDefinition = {},},},- exchangeToken: {- name: "ExchangeToken",- requestType: ExchangeTokenRequest,- requestStream: false,- responseType: OAuthToken,- responseStream: false,- options: {- _unknownFields: {- 8410: [new Uint8Array([0])],- 578365826: [- new Uint8Array([- 72,- 58,- 14,- 101,- 120,- 99,- 104,- 97,- 110,- 103,- 101,- 95,- 116,- 111,- 107,- 101,- 110,- 34,- 54,- 47,- 118,- 49,- 47,- 123,- 101,- 120,- 99,- 104,- 97,- 110,- 103,- 101,- 95,- 116,- 111,- 107,- 101,- 110,- 46,- 110,- 97,- 109,- 101,- 61,- 118,- 99,- 115,- 80,- 114,- 111,- 118,- 105,- 100,- 101,- 114,- 115,- 47,- 42,- 125,- 58,- 101,- 120,- 99,- 104,- 97,- 110,- 103,- 101,- 84,- 111,- 107,- 101,- 110,- ]),- ],- },- },- },deleteVCSProvider: {name: "DeleteVCSProvider",requestType: DeleteVCSProviderRequest,@@ -2218,32 +1683,6 @@ export type DeepPartial<T> = T extends Builtin ? T: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }: Partial<T>;-function toTimestamp(date: Date): Timestamp {- const seconds = numberToLong(date.getTime() / 1_000);- const nanos = (date.getTime() % 1_000) * 1_000_000;- return { seconds, nanos };-}--function fromTimestamp(t: Timestamp): Date {- let millis = (t.seconds.toNumber() || 0) * 1_000;- millis += (t.nanos || 0) / 1_000_000;- return new globalThis.Date(millis);-}--function fromJsonTimestamp(o: any): Date {- if (o instanceof globalThis.Date) {- return o;- } else if (typeof o === "string") {- return new globalThis.Date(o);- } else {- return fromTimestamp(Timestamp.fromJSON(o));- }-}--function numberToLong(number: number) {- return Long.fromNumber(number);-}-if (_m0.util.Long !== Long) {_m0.util.Long = Long as any;_m0.configure();diff --git a/frontend/src/types/vcs.ts b/frontend/src/types/vcs.tsindex d0d445b4a8..5fd5d2be9f 100644--- a/frontend/src/types/vcs.ts+++ b/frontend/src/types/vcs.ts@@ -19,8 +19,7 @@ export interface VCSConfig {uiType: VCSUIType;name: string;instanceUrl: string;- applicationId: string;- secret: string;+ accessToken: string;}export type VCS = {@@ -32,8 +31,7 @@ export type VCS = {uiType: VCSUIType;instanceUrl: string;apiUrl: string;- applicationId: string;- secret: string;+ accessToken: string;};export type VCSFileCommit = {@@ -68,20 +66,3 @@ export type VCSPushEvent = {fileCommit: VCSFileCommit;commits: VCSCommit[];};--export function isValidVCSApplicationIdOrSecret(- vcsType: VCSProvider_Type,- str: string-): boolean {- if (vcsType == VCSProvider_Type.GITLAB) {- return /^(.{1,}-){0,1}[a-zA-Z0-9_]{64}$/.test(str);- } else if (vcsType == VCSProvider_Type.GITHUB) {- return /^[a-zA-Z0-9_]{20}$|^[a-zA-Z0-9_]{40}$/.test(str);- } else if (vcsType == VCSProvider_Type.BITBUCKET) {- return /^[a-zA-Z0-9_]{18}$|^[a-zA-Z0-9_]{32}$/.test(str);- } else if (vcsType == VCSProvider_Type.AZURE_DEVOPS) {- // TODO: Azure App id is uuid but the secret is random string. We may need to distinguish them.- return /^[a-zA-Z0-9-_.]{1,}$/.test(str);- }- return false;-}diff --git a/frontend/src/views/SettingWorkspaceVCSDetail.vue b/frontend/src/views/SettingWorkspaceVCSDetail.vueindex 9f5558fa3d..1418a01b45 100644--- a/frontend/src/views/SettingWorkspaceVCSDetail.vue+++ b/frontend/src/views/SettingWorkspaceVCSDetail.vue@@ -40,65 +40,10 @@</div><div>- <label for="applicationid" class="textlabel">- {{ $t("common.application") }} ID- </label>- <p class="mt-1 textinfolabel">- <template v-if="vcsUIType == 'GITLAB_SELF_HOST'">- {{- $t(- "gitops.setting.git-provider.gitlab-self-host-application-id-label"- )- }}- <a :href="adminApplicationUrl" target="_blank" class="normal-link">{{- $t("gitops.setting.git-provider.view-in-gitlab")- }}</a>- </template>- <template v-else-if="vcsUIType == 'GITLAB_COM'">- {{- $t("gitops.setting.git-provider.gitlab-com-application-id-label")- }}- <a :href="adminApplicationUrl" target="_blank" class="normal-link">{{- $t("gitops.setting.git-provider.view-in-gitlab")- }}</a>- </template>- <template v-else-if="vcsUIType == 'GITHUB_COM'">- {{ $t("gitops.setting.git-provider.github-application-id-label") }}- </template>- <template v-else-if="vcsUIType == 'AZURE_DEVOPS'">- {{ $t("gitops.setting.git-provider.azure-application-id-label") }}- <a :href="adminApplicationUrl" target="_blank" class="normal-link">{{- $t("gitops.setting.git-provider.view-in-azure")- }}</a>- </template>- </p>- <BBTextField- id="applicationid"- v-model:value="state.applicationId"- name="applicationid"- class="mt-1 w-full"- />- </div>-- <div>- <label for="secret" class="textlabel"> Secret </label>- <p class="mt-1 textinfolabel">- <template v-if="vcsUIType == 'GITLAB_SELF_HOST'">- {{ $t("gitops.setting.git-provider.gitlab-self-host-secret-label") }}- </template>- <template v-else-if="vcsUIType == 'GITLAB_COM'">- {{ $t("gitops.setting.git-provider.gitlab-com-secret-label") }}- </template>- <template v-else-if="vcsUIType == 'GITHUB_COM'">- {{ $t("gitops.setting.git-provider.secret-label-github") }}- </template>- <template v-else-if="vcsUIType == 'AZURE_DEVOPS'">- {{ $t("gitops.setting.git-provider.azure-secret-label") }}- </template>- </p>+ <label for="secret" class="textlabel"> Access Token </label><BBTextFieldid="secret"- v-model:value="state.secret"+ v-model:value="state.accessToken"name="secret"class="mt-1 w-full":placeholder="$t('common.sensitive-placeholder')"@@ -153,7 +98,7 @@<script lang="ts" setup>import isEmpty from "lodash-es/isEmpty";-import { reactive, computed, watchEffect, onMounted, onUnmounted } from "vue";+import { reactive, computed, watchEffect } from "vue";import { useRouter } from "vue-router";import RepositoryTable from "@/components/RepositoryTable.vue";import { vcsListByUIType } from "@/components/VCS/utils";@@ -164,16 +109,8 @@ import {useRepositoryV1Store,useVCSV1Store,} from "@/store";-import {- openWindowForOAuth,- OAuthWindowEventPayload,- VCSUIType,-} from "@/types";-import {- OAuthToken,- VCSProvider,- VCSProvider_Type,-} from "@/types/proto/v1/vcs_provider_service";+import { VCSUIType } from "@/types";+import { VCSProvider } from "@/types/proto/v1/vcs_provider_service";import {idFromSlug,uidFromSlug,@@ -183,9 +120,7 @@ import {interface LocalState {title: string;- applicationId: string;- secret: string;- oAuthResultCallback?: (token: OAuthToken | undefined) => void;+ accessToken: string;}const props = defineProps<{@@ -214,8 +149,7 @@ const vcsWithUIType = computed(() => {const state = reactive<LocalState>({title: vcs.value?.title ?? "",- applicationId: vcs.value?.applicationId ?? "",- secret: "",+ accessToken: "",});const hasUpdateVCSPermission = computed(() => {@@ -226,41 +160,6 @@ const hasDeleteVCSPermission = computed(() => {return hasWorkspacePermissionV2(currentUser.value, "bb.vcsProviders.delete");});-onMounted(() => {- window.addEventListener("bb.oauth.register-vcs", eventListener, false);-});--onUnmounted(() => {- window.removeEventListener("bb.oauth.register-vcs", eventListener);-});--const eventListener = (event: Event) => {- const payload = (event as CustomEvent).detail as OAuthWindowEventPayload;- if (isEmpty(payload.error)) {- if (- vcs.value?.type === VCSProvider_Type.GITLAB ||- vcs.value?.type === VCSProvider_Type.GITHUB ||- vcs.value?.type === VCSProvider_Type.BITBUCKET- ) {- vcsV1Store- .exchangeToken({- code: payload.code,- vcsName: vcs.value.name,- clientId: state.applicationId,- clientSecret: state.secret,- })- .then((token: OAuthToken) => {- state.oAuthResultCallback!(token);- })- .catch(() => {- state.oAuthResultCallback!(undefined);- });- }- } else {- state.oAuthResultCallback!(undefined);- }-};-watchEffect(async () => {const vcs = await vcsV1Store.fetchVCSByUid(uidFromSlug(props.vcsSlug));if (vcs) {@@ -281,28 +180,14 @@ watchEffect(async () => {}});-const adminApplicationUrl = computed(() => {- switch (vcsUIType.value) {- case "AZURE_DEVOPS":- return `https://app.vsaex.visualstudio.com/app/view?clientId=${vcs.value?.applicationId}`;- case "GITLAB_COM":- return "https://gitlab.com/-/profile/applications";- case "GITLAB_SELF_HOST":- return `${vcs.value?.url}/admin/applications`;- default:- return "";- }+const repositoryList = computed(() => {+ return repositoryV1Store.getRepositoryListByVCS(vcs.value?.name ?? "");});-const repositoryList = computed(() =>- repositoryV1Store.getRepositoryListByVCS(vcs.value?.name ?? "")-);-+// TODO(d): existing bug, fix on mount.const allowUpdate = computed(() => {return (- (state.title != vcs.value?.title ||- state.applicationId != vcs.value?.applicationId ||- !isEmpty(state.secret)) &&+ (state.title != vcs.value?.title || !isEmpty(state.accessToken)) &&hasUpdateVCSPermission.value);});@@ -311,97 +196,26 @@ const doUpdate = () => {if (!vcs.value) {return;}+ const vcsPatch: Partial<VCSProvider> = {+ name: vcs.value.name,+ };+ if (state.title != vcs.value.title) {+ vcsPatch.title = state.title;+ }+ if (!isEmpty(state.accessToken)) {+ vcsPatch.accessToken = state.accessToken;+ }- if (- state.applicationId != vcs.value.applicationId ||- !isEmpty(state.secret)- ) {- let authorizeUrl = `${vcs.value.url}/oauth/authorize`;- if (vcs.value.type === VCSProvider_Type.GITHUB) {- authorizeUrl = `https://github.com/login/oauth/authorize`;- } else if (vcs.value.type === VCSProvider_Type.BITBUCKET) {- authorizeUrl = `https://bitbucket.org/site/oauth2/authorize`;- } else if (vcs.value.type === VCSProvider_Type.AZURE_DEVOPS) {- authorizeUrl = "https://app.vssps.visualstudio.com/oauth2/authorize";- }- const newWindow = openWindowForOAuth(- authorizeUrl,- state.applicationId,- "bb.oauth.register-vcs",- vcs.value.type- );- if (newWindow) {- state.oAuthResultCallback = (token: OAuthToken | undefined) => {- if (!vcs.value) {- return;- }- if (token) {- const vcsPatch: Partial<VCSProvider> = {- name: vcs.value.name,- };- if (state.title != vcs.value.title) {- vcsPatch.title = state.title;- }- if (state.applicationId != vcs.value.applicationId) {- vcsPatch.applicationId = state.applicationId;- }- if (!isEmpty(state.secret)) {- vcsPatch.secret = state.secret;- }- vcsV1Store- .updateVCS(vcsPatch)- .then((vcs: VCSProvider | undefined) => {- if (!vcs) {- return;- }- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: `Successfully updated '${vcs.title}'`,- });- });- } else {- // If the application ID mismatches, the OAuth workflow will stop early.- // So the only possibility to reach here is we have a matching application ID, while- // we failed to exchange a token, and it's likely we are requesting with a wrong secret.- let description = "";- if (vcs.value.type == VCSProvider_Type.GITLAB) {- description =- "Please make sure Secret matches the one from your GitLab instance Application.";- } else if (vcs.value.type == VCSProvider_Type.GITHUB) {- description =- "Please make sure Client secret matches the one from your GitHub.com Application.";- } else if (vcs.value.type == VCSProvider_Type.BITBUCKET) {- description =- "Please make sure Secret matches the one from your Bitbucket.org consumer.";- }- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: `Failed to update '${vcs.value.title}'`,- description: description,- });- }- };+ vcsV1Store.updateVCS(vcsPatch).then((updatedVCS: VCSProvider | undefined) => {+ if (!updatedVCS) {+ return;}- } else if (state.title != vcs.value.title) {- const vcsPatch: Partial<VCSProvider> = {- name: vcs.value.name,- title: state.title,- };- vcsV1Store- .updateVCS(vcsPatch)- .then((updatedVCS: VCSProvider | undefined) => {- if (!updatedVCS) {- return;- }- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: `Successfully updated '${updatedVCS.title}'`,- });- });- }+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: `Successfully updated '${updatedVCS.title}'`,+ });+ });};const cancel = () => {diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex c6ac87e70b..63047e40dd 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -337,14 +337,11 @@- [v1/vcs_provider_service.proto](#v1_vcs_provider_service-proto)- [CreateVCSProviderRequest](#bytebase-v1-CreateVCSProviderRequest)- [DeleteVCSProviderRequest](#bytebase-v1-DeleteVCSProviderRequest)- - [ExchangeToken](#bytebase-v1-ExchangeToken)- - [ExchangeTokenRequest](#bytebase-v1-ExchangeTokenRequest)- [GetVCSProviderRequest](#bytebase-v1-GetVCSProviderRequest)- [ListProjectGitOpsInfoRequest](#bytebase-v1-ListProjectGitOpsInfoRequest)- [ListProjectGitOpsInfoResponse](#bytebase-v1-ListProjectGitOpsInfoResponse)- [ListVCSProvidersRequest](#bytebase-v1-ListVCSProvidersRequest)- [ListVCSProvidersResponse](#bytebase-v1-ListVCSProvidersResponse)- - [OAuthToken](#bytebase-v1-OAuthToken)- [ProjectGitOpsInfo](#bytebase-v1-ProjectGitOpsInfo)- [SearchVCSProviderProjectsRequest](#bytebase-v1-SearchVCSProviderProjectsRequest)- [SearchVCSProviderProjectsResponse](#bytebase-v1-SearchVCSProviderProjectsResponse)@@ -5641,41 +5638,6 @@ The policy's `name` field is used to identify the instance to update. Format-<a name="bytebase-v1-ExchangeToken"></a>--### ExchangeToken----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| name | [string](#string) | | The name of the vcs provider to retrieve the linked projects. Format: vcsProviders/{vcsProvider} |-| code | [string](#string) | | |-| type | [VCSProvider.Type](#bytebase-v1-VCSProvider-Type) | | |-| instance_url | [string](#string) | | |-| client_id | [string](#string) | | |-| client_secret | [string](#string) | | |-------<a name="bytebase-v1-ExchangeTokenRequest"></a>--### ExchangeTokenRequest----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| exchange_token | [ExchangeToken](#bytebase-v1-ExchangeToken) | | |------<a name="bytebase-v1-GetVCSProviderRequest"></a>### GetVCSProviderRequest@@ -5753,23 +5715,6 @@ The policy's `name` field is used to identify the instance to update. Format-<a name="bytebase-v1-OAuthToken"></a>--### OAuthToken----| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| access_token | [string](#string) | | |-| refresh_token | [string](#string) | | |-| expires_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |------<a name="bytebase-v1-ProjectGitOpsInfo"></a>### ProjectGitOpsInfo@@ -5787,13 +5732,9 @@ The policy's `name` field is used to identify the instance to update. Format| base_directory | [string](#string) | | The root directory where Bytebase observes the file change. If empty, then it observes the entire repository. || file_path_template | [string](#string) | | Bytebase only observes the file path name matching the template pattern **relative** to the base directory. Required Placeholder: {{DB_NAME}}, {{VERSION}}, {{TYPE]}. Optional Placeholder: {{ENV_ID}}, {{DESCRIPTION}}. Optional Directory Wildcard: '*', '**'. || schema_path_template | [string](#string) | | The file path template for storing the latest schema auto-generated by Bytebase after migration. If empty, then Bytebase won't auto generate it. If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}. |-| sheet_path_template | [string](#string) | | The file path template for matching the sql files for sheet. If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}. || external_id | [string](#string) | | The reposition external id in target VCS. || enable_sql_review_ci | [bool](#bool) | | Set to true to enable SQL review CI for all PR/MRs. || webhook_endpoint_id | [string](#string) | | The webhook endpoint ID of the repository. |-| access_token | [string](#string) | | |-| expires_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |-| refresh_token | [string](#string) | | |@@ -5809,8 +5750,6 @@ The policy's `name` field is used to identify the instance to update. Format| Field | Type | Label | Description || ----- | ---- | ----- | ----------- || name | [string](#string) | | The name of the vcs provider to retrieve the vcs provider repositories. Format: vcsProviders/{vcsProvider} |-| access_token | [string](#string) | | |-| refresh_token | [string](#string) | | |@@ -5878,9 +5817,7 @@ The policy's `name` field is used to identify the instance to update. Format| title | [string](#string) | | The title of the vcs provider. It is used to display in the UI. Specified by the client. || type | [VCSProvider.Type](#bytebase-v1-VCSProvider-Type) | | || url | [string](#string) | | The url of the vcs provider. Specified by the client. For example: github.com, gitlab.com, gitlab.bytebase.com. |-| api_url | [string](#string) | | The API url of the vcs provider. Derived from the url. |-| application_id | [string](#string) | | The application ID of the vcs provider. Specified by the client. |-| secret | [string](#string) | | The application secret of the vcs provider. Specified by the client. |+| access_token | [string](#string) | | The access token of the vcs provider. |@@ -5919,7 +5856,6 @@ The policy's `name` field is used to identify the instance to update. Format| ListVCSProviders | [ListVCSProvidersRequest](#bytebase-v1-ListVCSProvidersRequest) | [ListVCSProvidersResponse](#bytebase-v1-ListVCSProvidersResponse) | || CreateVCSProvider | [CreateVCSProviderRequest](#bytebase-v1-CreateVCSProviderRequest) | [VCSProvider](#bytebase-v1-VCSProvider) | || UpdateVCSProvider | [UpdateVCSProviderRequest](#bytebase-v1-UpdateVCSProviderRequest) | [VCSProvider](#bytebase-v1-VCSProvider) | |-| ExchangeToken | [ExchangeTokenRequest](#bytebase-v1-ExchangeTokenRequest) | [OAuthToken](#bytebase-v1-OAuthToken) | || DeleteVCSProvider | [DeleteVCSProviderRequest](#bytebase-v1-DeleteVCSProviderRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | || SearchVCSProviderProjects | [SearchVCSProviderProjectsRequest](#bytebase-v1-SearchVCSProviderProjectsRequest) | [SearchVCSProviderProjectsResponse](#bytebase-v1-SearchVCSProviderProjectsResponse) | || ListProjectGitOpsInfo | [ListProjectGitOpsInfoRequest](#bytebase-v1-ListProjectGitOpsInfoRequest) | [ListProjectGitOpsInfoResponse](#bytebase-v1-ListProjectGitOpsInfoResponse) | |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex c506342832..07ed19951d 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -1461,14 +1461,6 @@<a href="#bytebase.v1.DeleteVCSProviderRequest"><span class="badge">M</span>DeleteVCSProviderRequest</a></li>- <li>- <a href="#bytebase.v1.ExchangeToken"><span class="badge">M</span>ExchangeToken</a>- </li>-- <li>- <a href="#bytebase.v1.ExchangeTokenRequest"><span class="badge">M</span>ExchangeTokenRequest</a>- </li>-<li><a href="#bytebase.v1.GetVCSProviderRequest"><span class="badge">M</span>GetVCSProviderRequest</a></li>@@ -1489,10 +1481,6 @@<a href="#bytebase.v1.ListVCSProvidersResponse"><span class="badge">M</span>ListVCSProvidersResponse</a></li>- <li>- <a href="#bytebase.v1.OAuthToken"><span class="badge">M</span>OAuthToken</a>- </li>-<li><a href="#bytebase.v1.ProjectGitOpsInfo"><span class="badge">M</span>ProjectGitOpsInfo</a></li>@@ -16217,90 +16205,6 @@ Format: vcsProviders/{vcsProvider} </p></td>- <h3 id="bytebase.v1.ExchangeToken">ExchangeToken</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>name</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The name of the vcs provider to retrieve the linked projects.-Format: vcsProviders/{vcsProvider} </p></td>- </tr>-- <tr>- <td>code</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>type</td>- <td><a href="#bytebase.v1.VCSProvider.Type">VCSProvider.Type</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>instance_url</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>client_id</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>client_secret</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>------ <h3 id="bytebase.v1.ExchangeTokenRequest">ExchangeTokenRequest</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>exchange_token</td>- <td><a href="#bytebase.v1.ExchangeToken">ExchangeToken</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>-----<h3 id="bytebase.v1.GetVCSProviderRequest">GetVCSProviderRequest</h3><p></p>@@ -16441,44 +16345,6 @@ If this field is omitted, there are no subsequent pages. </p></td>- <h3 id="bytebase.v1.OAuthToken">OAuthToken</h3>- <p></p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>access_token</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>refresh_token</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>expires_time</td>- <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>- <td></td>- <td><p> </p></td>- </tr>-- </tbody>- </table>-----<h3 id="bytebase.v1.ProjectGitOpsInfo">ProjectGitOpsInfo</h3><p></p>@@ -16558,14 +16424,6 @@ If empty, then Bytebase won't auto generate it.If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}. </p></td></tr>- <tr>- <td>sheet_path_template</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The file path template for matching the sql files for sheet.-If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}. </p></td>- </tr>-<tr><td>external_id</td><td><a href="#string">string</a></td>@@ -16587,27 +16445,6 @@ If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}},<td><p>The webhook endpoint ID of the repository. </p></td></tr>- <tr>- <td>access_token</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>expires_time</td>- <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>refresh_token</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-</tbody></table>@@ -16633,20 +16470,6 @@ If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}},Format: vcsProviders/{vcsProvider} </p></td></tr>- <tr>- <td>access_token</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>refresh_token</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p> </p></td>- </tr>-</tbody></table>@@ -16795,24 +16618,10 @@ For example: github.com, gitlab.com, gitlab.bytebase.com. </p></td></tr><tr>- <td>api_url</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The API url of the vcs provider. Derived from the url. </p></td>- </tr>-- <tr>- <td>application_id</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The application ID of the vcs provider. Specified by the client. </p></td>- </tr>-- <tr>- <td>secret</td>+ <td>access_token</td><td><a href="#string">string</a></td><td></td>- <td><p>The application secret of the vcs provider. Specified by the client. </p></td>+ <td><p>The access token of the vcs provider. </p></td></tr></tbody>@@ -16905,13 +16714,6 @@ For example: github.com, gitlab.com, gitlab.bytebase.com. </p></td><td><p></p></td></tr>- <tr>- <td>ExchangeToken</td>- <td><a href="#bytebase.v1.ExchangeTokenRequest">ExchangeTokenRequest</a></td>- <td><a href="#bytebase.v1.OAuthToken">OAuthToken</a></td>- <td><p></p></td>- </tr>-<tr><td>DeleteVCSProvider</td><td><a href="#bytebase.v1.DeleteVCSProviderRequest">DeleteVCSProviderRequest</a></td>@@ -16993,16 +16795,6 @@ For example: github.com, gitlab.com, gitlab.bytebase.com. </p></td>- <tr>- <td>ExchangeToken</td>- <td>POST</td>- <td>/v1/{exchange_token.name=vcsProviders/*}:exchangeToken</td>- <td>exchange_token</td>- </tr>----<tr><td>DeleteVCSProvider</td><td>DELETE</td>diff --git a/proto/generated-go/v1/vcs_provider_service.pb.go b/proto/generated-go/v1/vcs_provider_service.pb.goindex 1394fd6111..be0d068462 100644--- a/proto/generated-go/v1/vcs_provider_service.pb.go+++ b/proto/generated-go/v1/vcs_provider_service.pb.go@@ -12,7 +12,6 @@ import (protoimpl "google.golang.org/protobuf/runtime/protoimpl"emptypb "google.golang.org/protobuf/types/known/emptypb"fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"- timestamppb "google.golang.org/protobuf/types/known/timestamppb"reflect "reflect"sync "sync")@@ -409,9 +408,7 @@ type SearchVCSProviderProjectsRequest struct {// The name of the vcs provider to retrieve the vcs provider repositories.// Format: vcsProviders/{vcsProvider}- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`- RefreshToken string `protobuf:"bytes,3,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`}func (x *SearchVCSProviderProjectsRequest) Reset() {@@ -453,20 +450,6 @@ func (x *SearchVCSProviderProjectsRequest) GetName() string {return ""}-func (x *SearchVCSProviderProjectsRequest) GetAccessToken() string {- if x != nil {- return x.AccessToken- }- return ""-}--func (x *SearchVCSProviderProjectsRequest) GetRefreshToken() string {- if x != nil {- return x.RefreshToken- }- return ""-}-type SearchVCSProviderProjectsResponse struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -626,12 +609,8 @@ type VCSProvider struct {// The url of the vcs provider. Specified by the client.// For example: github.com, gitlab.com, gitlab.bytebase.com.Url string `protobuf:"bytes,4,opt,name=url,proto3" json:"url,omitempty"`- // The API url of the vcs provider. Derived from the url.- ApiUrl string `protobuf:"bytes,5,opt,name=api_url,json=apiUrl,proto3" json:"api_url,omitempty"`- // The application ID of the vcs provider. Specified by the client.- ApplicationId string `protobuf:"bytes,6,opt,name=application_id,json=applicationId,proto3" json:"application_id,omitempty"`- // The application secret of the vcs provider. Specified by the client.- Secret string `protobuf:"bytes,7,opt,name=secret,proto3" json:"secret,omitempty"`+ // The access token of the vcs provider.+ AccessToken string `protobuf:"bytes,5,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`}func (x *VCSProvider) Reset() {@@ -694,23 +673,9 @@ func (x *VCSProvider) GetUrl() string {return ""}-func (x *VCSProvider) GetApiUrl() string {+func (x *VCSProvider) GetAccessToken() string {if x != nil {- return x.ApiUrl- }- return ""-}--func (x *VCSProvider) GetApplicationId() string {- if x != nil {- return x.ApplicationId- }- return ""-}--func (x *VCSProvider) GetSecret() string {- if x != nil {- return x.Secret+ return x.AccessToken}return ""}@@ -744,18 +709,12 @@ type ProjectGitOpsInfo struct {// If empty, then Bytebase won't auto generate it.// If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}.SchemaPathTemplate string `protobuf:"bytes,9,opt,name=schema_path_template,json=schemaPathTemplate,proto3" json:"schema_path_template,omitempty"`- // The file path template for matching the sql files for sheet.- // If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}.- SheetPathTemplate string `protobuf:"bytes,10,opt,name=sheet_path_template,json=sheetPathTemplate,proto3" json:"sheet_path_template,omitempty"`// The reposition external id in target VCS.ExternalId string `protobuf:"bytes,11,opt,name=external_id,json=externalId,proto3" json:"external_id,omitempty"`// Set to true to enable SQL review CI for all PR/MRs.EnableSqlReviewCi bool `protobuf:"varint,12,opt,name=enable_sql_review_ci,json=enableSqlReviewCi,proto3" json:"enable_sql_review_ci,omitempty"`// The webhook endpoint ID of the repository.- WebhookEndpointId string `protobuf:"bytes,13,opt,name=webhook_endpoint_id,json=webhookEndpointId,proto3" json:"webhook_endpoint_id,omitempty"`- AccessToken string `protobuf:"bytes,14,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`- ExpiresTime *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=expires_time,json=expiresTime,proto3" json:"expires_time,omitempty"`- RefreshToken string `protobuf:"bytes,16,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`+ WebhookEndpointId string `protobuf:"bytes,13,opt,name=webhook_endpoint_id,json=webhookEndpointId,proto3" json:"webhook_endpoint_id,omitempty"`}func (x *ProjectGitOpsInfo) Reset() {@@ -853,13 +812,6 @@ func (x *ProjectGitOpsInfo) GetSchemaPathTemplate() string {return ""}-func (x *ProjectGitOpsInfo) GetSheetPathTemplate() string {- if x != nil {- return x.SheetPathTemplate- }- return ""-}-func (x *ProjectGitOpsInfo) GetExternalId() string {if x != nil {return x.ExternalId@@ -881,226 +833,6 @@ func (x *ProjectGitOpsInfo) GetWebhookEndpointId() string {return ""}-func (x *ProjectGitOpsInfo) GetAccessToken() string {- if x != nil {- return x.AccessToken- }- return ""-}--func (x *ProjectGitOpsInfo) GetExpiresTime() *timestamppb.Timestamp {- if x != nil {- return x.ExpiresTime- }- return nil-}--func (x *ProjectGitOpsInfo) GetRefreshToken() string {- if x != nil {- return x.RefreshToken- }- return ""-}--type ExchangeTokenRequest struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- ExchangeToken *ExchangeToken `protobuf:"bytes,1,opt,name=exchange_token,json=exchangeToken,proto3" json:"exchange_token,omitempty"`-}--func (x *ExchangeTokenRequest) Reset() {- *x = ExchangeTokenRequest{}- if protoimpl.UnsafeEnabled {- mi := &file_v1_vcs_provider_service_proto_msgTypes[12]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)- }-}--func (x *ExchangeTokenRequest) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ExchangeTokenRequest) ProtoMessage() {}--func (x *ExchangeTokenRequest) ProtoReflect() protoreflect.Message {- mi := &file_v1_vcs_provider_service_proto_msgTypes[12]- if protoimpl.UnsafeEnabled && x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ExchangeTokenRequest.ProtoReflect.Descriptor instead.-func (*ExchangeTokenRequest) Descriptor() ([]byte, []int) {- return file_v1_vcs_provider_service_proto_rawDescGZIP(), []int{12}-}--func (x *ExchangeTokenRequest) GetExchangeToken() *ExchangeToken {- if x != nil {- return x.ExchangeToken- }- return nil-}--type ExchangeToken struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- // The name of the vcs provider to retrieve the linked projects.- // Format: vcsProviders/{vcsProvider}- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`- Type VCSProvider_Type `protobuf:"varint,3,opt,name=type,proto3,enum=bytebase.v1.VCSProvider_Type" json:"type,omitempty"`- InstanceUrl string `protobuf:"bytes,4,opt,name=instance_url,json=instanceUrl,proto3" json:"instance_url,omitempty"`- ClientId string `protobuf:"bytes,5,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`- ClientSecret string `protobuf:"bytes,6,opt,name=client_secret,json=clientSecret,proto3" json:"client_secret,omitempty"`-}--func (x *ExchangeToken) Reset() {- *x = ExchangeToken{}- if protoimpl.UnsafeEnabled {- mi := &file_v1_vcs_provider_service_proto_msgTypes[13]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)- }-}--func (x *ExchangeToken) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ExchangeToken) ProtoMessage() {}--func (x *ExchangeToken) ProtoReflect() protoreflect.Message {- mi := &file_v1_vcs_provider_service_proto_msgTypes[13]- if protoimpl.UnsafeEnabled && x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ExchangeToken.ProtoReflect.Descriptor instead.-func (*ExchangeToken) Descriptor() ([]byte, []int) {- return file_v1_vcs_provider_service_proto_rawDescGZIP(), []int{13}-}--func (x *ExchangeToken) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *ExchangeToken) GetCode() string {- if x != nil {- return x.Code- }- return ""-}--func (x *ExchangeToken) GetType() VCSProvider_Type {- if x != nil {- return x.Type- }- return VCSProvider_TYPE_UNSPECIFIED-}--func (x *ExchangeToken) GetInstanceUrl() string {- if x != nil {- return x.InstanceUrl- }- return ""-}--func (x *ExchangeToken) GetClientId() string {- if x != nil {- return x.ClientId- }- return ""-}--func (x *ExchangeToken) GetClientSecret() string {- if x != nil {- return x.ClientSecret- }- return ""-}--type OAuthToken struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`- RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`- ExpiresTime *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=expires_time,json=expiresTime,proto3" json:"expires_time,omitempty"`-}--func (x *OAuthToken) Reset() {- *x = OAuthToken{}- if protoimpl.UnsafeEnabled {- mi := &file_v1_vcs_provider_service_proto_msgTypes[14]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)- }-}--func (x *OAuthToken) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*OAuthToken) ProtoMessage() {}--func (x *OAuthToken) ProtoReflect() protoreflect.Message {- mi := &file_v1_vcs_provider_service_proto_msgTypes[14]- if protoimpl.UnsafeEnabled && x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use OAuthToken.ProtoReflect.Descriptor instead.-func (*OAuthToken) Descriptor() ([]byte, []int) {- return file_v1_vcs_provider_service_proto_rawDescGZIP(), []int{14}-}--func (x *OAuthToken) GetAccessToken() string {- if x != nil {- return x.AccessToken- }- return ""-}--func (x *OAuthToken) GetRefreshToken() string {- if x != nil {- return x.RefreshToken- }- return ""-}--func (x *OAuthToken) GetExpiresTime() *timestamppb.Timestamp {- if x != nil {- return x.ExpiresTime- }- return nil-}-type SearchVCSProviderProjectsResponse_Project struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -1119,7 +851,7 @@ type SearchVCSProviderProjectsResponse_Project struct {func (x *SearchVCSProviderProjectsResponse_Project) Reset() {*x = SearchVCSProviderProjectsResponse_Project{}if protoimpl.UnsafeEnabled {- mi := &file_v1_vcs_provider_service_proto_msgTypes[15]+ mi := &file_v1_vcs_provider_service_proto_msgTypes[12]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1132,7 +864,7 @@ func (x *SearchVCSProviderProjectsResponse_Project) String() string {func (*SearchVCSProviderProjectsResponse_Project) ProtoMessage() {}func (x *SearchVCSProviderProjectsResponse_Project) ProtoReflect() protoreflect.Message {- mi := &file_v1_vcs_provider_service_proto_msgTypes[15]+ mi := &file_v1_vcs_provider_service_proto_msgTypes[12]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1191,246 +923,183 @@ var file_v1_vcs_provider_service_proto_rawDesc = []byte{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, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70,- 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5c, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x43,- 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,- 0x12, 0x40, 0x0a, 0x0c, 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,- 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,- 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0b, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64,- 0x65, 0x72, 0x22, 0x30, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76,+ 0x6f, 0x74, 0x6f, 0x22, 0x5c, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x43, 0x53,+ 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,+ 0x40, 0x0a, 0x0c, 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18,+ 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,+ 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x42,+ 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0b, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65,+ 0x72, 0x22, 0x30, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69,+ 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61,+ 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e,+ 0x61, 0x6d, 0x65, 0x22, 0x55, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72,+ 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b,+ 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,+ 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70,+ 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,+ 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x81, 0x01, 0x0a, 0x18, 0x4c,+ 0x69, 0x73, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52,+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0d, 0x76, 0x63, 0x73, 0x5f, 0x70,+ 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53,+ 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x0c, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f,+ 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70,+ 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,+ 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x9e,+ 0x01, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76,+ 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x0c, 0x76,+ 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,+ 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,+ 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x42, 0x03, 0xe0, 0x41, 0x02,+ 0x52, 0x0b, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x40, 0x0a,+ 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01,+ 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,+ 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x42, 0x03,+ 0xe0, 0x41, 0x02, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22,+ 0x33, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76,0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04, 0x6e,0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04,- 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x55, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x43, 0x53, 0x50,- 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,- 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01,- 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a,- 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,- 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x81, 0x01, 0x0a, 0x18,- 0x4c, 0x69, 0x73, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73,- 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0d, 0x76, 0x63, 0x73, 0x5f,- 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,- 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43,- 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x0c, 0x76, 0x63, 0x73, 0x50, 0x72,- 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f,- 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,- 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22,- 0x9e, 0x01, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f,- 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x0c,- 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01,- 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,- 0x2e, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x42, 0x03, 0xe0, 0x41,- 0x02, 0x52, 0x0b, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x40,- 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20,- 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,- 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x42,- 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b,- 0x22, 0x33, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f,- 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04,- 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52,- 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8d, 0x01, 0x0a, 0x20, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,- 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65,- 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61,- 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e,- 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f,- 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0b,- 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x28, 0x0a, 0x0d, 0x72,- 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01,- 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68,- 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xdd, 0x01, 0x0a, 0x21, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,- 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65,- 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x08, 0x70,- 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e,- 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72,- 0x63, 0x68, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f,- 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x72,- 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x1a,- 0x64, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,- 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69,- 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65,- 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01,- 0x28, 0x09, 0x52, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x70, 0x61, 0x74, 0x68, 0x12, 0x17, 0x0a, 0x07,- 0x77, 0x65, 0x62, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x77,- 0x65, 0x62, 0x55, 0x72, 0x6c, 0x22, 0x37, 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f,- 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,- 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,- 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x6f,- 0x0a, 0x1d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74,- 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,- 0x4e, 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x67, 0x69, 0x74, 0x6f, 0x70,- 0x73, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62,- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65,- 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x11, 0x70, 0x72,- 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74, 0x6f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x22,- 0xce, 0x02, 0x0a, 0x0b, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12,- 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0,- 0x41, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c,- 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x05, 0x74, 0x69,- 0x74, 0x6c, 0x65, 0x12, 0x36, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,- 0x0e, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,- 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x54, 0x79, 0x70, 0x65,- 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x03, 0x75,- 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x03, 0x75,- 0x72, 0x6c, 0x12, 0x1c, 0x0a, 0x07, 0x61, 0x70, 0x69, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20,- 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x06, 0x61, 0x70, 0x69, 0x55, 0x72, 0x6c,- 0x12, 0x2a, 0x0a, 0x0e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f,- 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0d, 0x61,- 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x06,- 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41,- 0x04, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, 0x55, 0x0a, 0x04, 0x54, 0x79, 0x70,- 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43,- 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x48, 0x55,- 0x42, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x4c, 0x41, 0x42, 0x10, 0x02, 0x12,- 0x0d, 0x0a, 0x09, 0x42, 0x49, 0x54, 0x42, 0x55, 0x43, 0x4b, 0x45, 0x54, 0x10, 0x03, 0x12, 0x10,- 0x0a, 0x0c, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x44, 0x45, 0x56, 0x4f, 0x50, 0x53, 0x10, 0x04,- 0x22, 0x8f, 0x05, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f,- 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,- 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,- 0x17, 0x0a, 0x07, 0x76, 0x63, 0x73, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,- 0x52, 0x06, 0x76, 0x63, 0x73, 0x55, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c,- 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1b,- 0x0a, 0x09, 0x66, 0x75, 0x6c, 0x6c, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x50, 0x61, 0x74, 0x68, 0x12, 0x17, 0x0a, 0x07, 0x77,- 0x65, 0x62, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x77, 0x65,- 0x62, 0x55, 0x72, 0x6c, 0x12, 0x23, 0x0a, 0x0d, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x66,- 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x62, 0x72, 0x61,- 0x6e, 0x63, 0x68, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x61, 0x73,- 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x0d, 0x62, 0x61, 0x73, 0x65, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79,- 0x12, 0x31, 0x0a, 0x12, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x74, 0x65,- 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41,- 0x02, 0x52, 0x10, 0x66, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c,- 0x61, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x70, 0x61,- 0x74, 0x68, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x12, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x74, 0x68, 0x54, 0x65, 0x6d,- 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x68, 0x65, 0x65, 0x74, 0x5f, 0x70,- 0x61, 0x74, 0x68, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, 0x01,- 0x28, 0x09, 0x52, 0x11, 0x73, 0x68, 0x65, 0x65, 0x74, 0x50, 0x61, 0x74, 0x68, 0x54, 0x65, 0x6d,- 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61,- 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65,- 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x14, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65,- 0x5f, 0x73, 0x71, 0x6c, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x63, 0x69, 0x18, 0x0c,- 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x71, 0x6c, 0x52,- 0x65, 0x76, 0x69, 0x65, 0x77, 0x43, 0x69, 0x12, 0x33, 0x0a, 0x13, 0x77, 0x65, 0x62, 0x68, 0x6f,- 0x6f, 0x6b, 0x5f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0d,- 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x11, 0x77, 0x65, 0x62, 0x68, 0x6f,- 0x6f, 0x6b, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0c,- 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x0e, 0x20, 0x01,- 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x04, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54,- 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x42, 0x0a, 0x0c, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f,- 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f,- 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d,- 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x03, 0xe0, 0x41, 0x04, 0x52, 0x0b, 0x65, 0x78, 0x70,- 0x69, 0x72, 0x65, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72,- 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x42,- 0x03, 0xe0, 0x41, 0x04, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b,- 0x65, 0x6e, 0x22, 0x59, 0x0a, 0x14, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x6f,- 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x41, 0x0a, 0x0e, 0x65, 0x78,- 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01,- 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,- 0x2e, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x0d,- 0x65, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xcf, 0x01,- 0x0a, 0x0d, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12,- 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,- 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,- 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,- 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e,- 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e,- 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,- 0x52, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x1b, 0x0a,- 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,- 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c,- 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22,- 0xa2, 0x01, 0x0a, 0x0a, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x26,- 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01,- 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73,- 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x28, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73,- 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0,- 0x41, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e,- 0x12, 0x42, 0x0a, 0x0c, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65,- 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,- 0x6d, 0x70, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73,- 0x54, 0x69, 0x6d, 0x65, 0x32, 0xa4, 0x09, 0x0a, 0x12, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76,- 0x69, 0x64, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x78, 0x0a, 0x0e, 0x47,- 0x65, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x22, 0x2e,- 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x56,- 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,- 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,- 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x28, 0xda, 0x41, 0x04,- 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12, 0x19, 0x2f, 0x76, 0x31, 0x2f,- 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65,- 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x7c, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x43, 0x53,- 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x24, 0x2e, 0x62, 0x79, 0x74, 0x65,- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x43, 0x53, 0x50,- 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,- 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69,- 0x73, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65,- 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0xda, 0x41, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02,- 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64,- 0x65, 0x72, 0x73, 0x12, 0x7f, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x43, 0x53,- 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,- 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x43, 0x53,- 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,- 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43,- 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x29, 0xda, 0x41, 0x00, 0x82, 0xd3,- 0xe4, 0x93, 0x02, 0x20, 0x3a, 0x0c, 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64,- 0x65, 0x72, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69,- 0x64, 0x65, 0x72, 0x73, 0x12, 0xad, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56,- 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x62, 0x79, 0x74,- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56,- 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,- 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,- 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x57, 0xda, 0x41, 0x18,- 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2c, 0x75, 0x70, 0x64,- 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x36, 0x3a, 0x0c,- 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x32, 0x26, 0x2f, 0x76,- 0x31, 0x2f, 0x7b, 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e,- 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,- 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x9e, 0x01, 0x0a, 0x0d, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67,- 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x6f, 0x6b,- 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x62, 0x79, 0x74, 0x65,- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b,- 0x65, 0x6e, 0x22, 0x51, 0xda, 0x41, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x48, 0x3a, 0x0e, 0x65,- 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x36, 0x2f,- 0x76, 0x31, 0x2f, 0x7b, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b,- 0x65, 0x6e, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69,- 0x64, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65,- 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x75, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56,- 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x62, 0x79, 0x74,- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56,- 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 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, 0x82, 0xd3, 0xe4, 0x93, 0x02,- 0x1b, 0x2a, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73,- 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xaf, 0x01, 0x0a,- 0x19, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64,- 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x2d, 0x2e, 0x62, 0x79, 0x74,- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x56,- 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,- 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x62, 0x79, 0x74, 0x65,+ 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x20, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x56, 0x43,+ 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,+ 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d,+ 0x65, 0x22, 0xdd, 0x01, 0x0a, 0x21, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x56, 0x43, 0x53, 0x50,+ 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52,+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65,+ 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x62, 0x79, 0x74, 0x65,0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x56, 0x43,0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,- 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x33, 0x82, 0xd3, 0xe4, 0x93, 0x02,- 0x2d, 0x3a, 0x01, 0x2a, 0x22, 0x28, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d,- 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x3a,- 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x9a,- 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69,- 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x29, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,- 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65,- 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75,- 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,- 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74,- 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,- 0x2a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x12, 0x22, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61,- 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f,- 0x2a, 0x7d, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 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,+ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,+ 0x74, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x1a, 0x64, 0x0a, 0x07, 0x50,+ 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,+ 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18,+ 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08,+ 0x66, 0x75, 0x6c, 0x6c, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,+ 0x66, 0x75, 0x6c, 0x6c, 0x70, 0x61, 0x74, 0x68, 0x12, 0x17, 0x0a, 0x07, 0x77, 0x65, 0x62, 0x5f,+ 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x77, 0x65, 0x62, 0x55, 0x72,+ 0x6c, 0x22, 0x37, 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,+ 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,+ 0x74, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42,+ 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x6f, 0x0a, 0x1d, 0x4c, 0x69,+ 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49,+ 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x13, 0x70,+ 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x67, 0x69, 0x74, 0x6f, 0x70, 0x73, 0x5f, 0x69, 0x6e,+ 0x66, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69,+ 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x11, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63,+ 0x74, 0x47, 0x69, 0x74, 0x6f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x8f, 0x02, 0x0a, 0x0b,+ 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x04, 0x6e,+ 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x04,+ 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20,+ 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12,+ 0x36, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53, 0x50,+ 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x42, 0x03, 0xe0, 0x41,+ 0x02, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x04,+ 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x26,+ 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05,+ 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x04, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73,+ 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x55, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14,+ 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49,+ 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x48, 0x55, 0x42, 0x10, 0x01,+ 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x49, 0x54, 0x4c, 0x41, 0x42, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09,+ 0x42, 0x49, 0x54, 0x42, 0x55, 0x43, 0x4b, 0x45, 0x54, 0x10, 0x03, 0x12, 0x10, 0x0a, 0x0c, 0x41,+ 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x44, 0x45, 0x56, 0x4f, 0x50, 0x53, 0x10, 0x04, 0x22, 0xc9, 0x03,+ 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49,+ 0x6e, 0x66, 0x6f, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,+ 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07,+ 0x76, 0x63, 0x73, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76,+ 0x63, 0x73, 0x55, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03,+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x66,+ 0x75, 0x6c, 0x6c, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,+ 0x66, 0x75, 0x6c, 0x6c, 0x50, 0x61, 0x74, 0x68, 0x12, 0x17, 0x0a, 0x07, 0x77, 0x65, 0x62, 0x5f,+ 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x77, 0x65, 0x62, 0x55, 0x72,+ 0x6c, 0x12, 0x23, 0x0a, 0x0d, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x5f, 0x66, 0x69, 0x6c, 0x74,+ 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68,+ 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x64,+ 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,+ 0x62, 0x61, 0x73, 0x65, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x31, 0x0a,+ 0x12, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6c,+ 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x10,+ 0x66, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,+ 0x12, 0x30, 0x0a, 0x14, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f,+ 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12,+ 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61,+ 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69,+ 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61,+ 0x6c, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x14, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x71,+ 0x6c, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x63, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28,+ 0x08, 0x52, 0x11, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x76, 0x69,+ 0x65, 0x77, 0x43, 0x69, 0x12, 0x33, 0x0a, 0x13, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x5f,+ 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28,+ 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x11, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x45,+ 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x32, 0x83, 0x08, 0x0a, 0x12, 0x56, 0x43,+ 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,+ 0x12, 0x78, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64,+ 0x65, 0x72, 0x12, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,+ 0x2e, 0x47, 0x65, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,+ 0x22, 0x28, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12,+ 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72,+ 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x7c, 0x0a, 0x10, 0x4c, 0x69,+ 0x73, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x24,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73,+ 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71,+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,+ 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64,+ 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0xda, 0x41, 0x00,+ 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x63, 0x73, 0x50,+ 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x7f, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61,+ 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x25, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61,+ 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71,+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,+ 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x29,+ 0xda, 0x41, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x3a, 0x0c, 0x76, 0x63, 0x73, 0x5f, 0x70,+ 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x63, 0x73,+ 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0xad, 0x01, 0x0a, 0x11, 0x55, 0x70,+ 0x64, 0x61, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12,+ 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70,+ 0x64, 0x61, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,+ 0x22, 0x57, 0xda, 0x41, 0x18, 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65,+ 0x72, 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4,+ 0x93, 0x02, 0x36, 0x3a, 0x0c, 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65,+ 0x72, 0x32, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x76, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76,+ 0x69, 0x64, 0x65, 0x72, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f,+ 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x75, 0x0a, 0x11, 0x44, 0x65, 0x6c,+ 0x65, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x25,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c,+ 0x65, 0x74, 0x65, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 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, 0x82,+ 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x2a, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65,+ 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d,+ 0x12, 0xaf, 0x01, 0x0a, 0x19, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x56, 0x43, 0x53, 0x50, 0x72,+ 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x2d,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61,+ 0x72, 0x63, 0x68, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72,+ 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72,+ 0x63, 0x68, 0x56, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f,+ 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x33, 0x82,+ 0xd3, 0xe4, 0x93, 0x02, 0x2d, 0x3a, 0x01, 0x2a, 0x22, 0x28, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e,+ 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73,+ 0x2f, 0x2a, 0x7d, 0x3a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,+ 0x74, 0x73, 0x12, 0x9a, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65,+ 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x29, 0x2e, 0x62,+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50,+ 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f,+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,+ 0x74, 0x47, 0x69, 0x74, 0x4f, 0x70, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f,+ 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x12, 0x22, 0x2f, 0x76, 0x31,+ 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x76, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64,+ 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 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 (@@ -1446,7 +1115,7 @@ func file_v1_vcs_provider_service_proto_rawDescGZIP() []byte {}var file_v1_vcs_provider_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)-var file_v1_vcs_provider_service_proto_msgTypes = make([]protoimpl.MessageInfo, 16)+var file_v1_vcs_provider_service_proto_msgTypes = make([]protoimpl.MessageInfo, 13)var file_v1_vcs_provider_service_proto_goTypes = []interface{}{(VCSProvider_Type)(0), // 0: bytebase.v1.VCSProvider.Type(*CreateVCSProviderRequest)(nil), // 1: bytebase.v1.CreateVCSProviderRequest@@ -1461,47 +1130,37 @@ var file_v1_vcs_provider_service_proto_goTypes = []interface{}{(*ListProjectGitOpsInfoResponse)(nil), // 10: bytebase.v1.ListProjectGitOpsInfoResponse(*VCSProvider)(nil), // 11: bytebase.v1.VCSProvider(*ProjectGitOpsInfo)(nil), // 12: bytebase.v1.ProjectGitOpsInfo- (*ExchangeTokenRequest)(nil), // 13: bytebase.v1.ExchangeTokenRequest- (*ExchangeToken)(nil), // 14: bytebase.v1.ExchangeToken- (*OAuthToken)(nil), // 15: bytebase.v1.OAuthToken- (*SearchVCSProviderProjectsResponse_Project)(nil), // 16: bytebase.v1.SearchVCSProviderProjectsResponse.Project- (*fieldmaskpb.FieldMask)(nil), // 17: google.protobuf.FieldMask- (*timestamppb.Timestamp)(nil), // 18: google.protobuf.Timestamp- (*emptypb.Empty)(nil), // 19: google.protobuf.Empty+ (*SearchVCSProviderProjectsResponse_Project)(nil), // 13: bytebase.v1.SearchVCSProviderProjectsResponse.Project+ (*fieldmaskpb.FieldMask)(nil), // 14: google.protobuf.FieldMask+ (*emptypb.Empty)(nil), // 15: google.protobuf.Empty}var file_v1_vcs_provider_service_proto_depIdxs = []int32{11, // 0: bytebase.v1.CreateVCSProviderRequest.vcs_provider:type_name -> bytebase.v1.VCSProvider11, // 1: bytebase.v1.ListVCSProvidersResponse.vcs_providers:type_name -> bytebase.v1.VCSProvider11, // 2: bytebase.v1.UpdateVCSProviderRequest.vcs_provider:type_name -> bytebase.v1.VCSProvider- 17, // 3: bytebase.v1.UpdateVCSProviderRequest.update_mask:type_name -> google.protobuf.FieldMask- 16, // 4: bytebase.v1.SearchVCSProviderProjectsResponse.projects:type_name -> bytebase.v1.SearchVCSProviderProjectsResponse.Project+ 14, // 3: bytebase.v1.UpdateVCSProviderRequest.update_mask:type_name -> google.protobuf.FieldMask+ 13, // 4: bytebase.v1.SearchVCSProviderProjectsResponse.projects:type_name -> bytebase.v1.SearchVCSProviderProjectsResponse.Project12, // 5: bytebase.v1.ListProjectGitOpsInfoResponse.project_gitops_info:type_name -> bytebase.v1.ProjectGitOpsInfo0, // 6: bytebase.v1.VCSProvider.type:type_name -> bytebase.v1.VCSProvider.Type- 18, // 7: bytebase.v1.ProjectGitOpsInfo.expires_time:type_name -> google.protobuf.Timestamp- 14, // 8: bytebase.v1.ExchangeTokenRequest.exchange_token:type_name -> bytebase.v1.ExchangeToken- 0, // 9: bytebase.v1.ExchangeToken.type:type_name -> bytebase.v1.VCSProvider.Type- 18, // 10: bytebase.v1.OAuthToken.expires_time:type_name -> google.protobuf.Timestamp- 2, // 11: bytebase.v1.VCSProviderService.GetVCSProvider:input_type -> bytebase.v1.GetVCSProviderRequest- 3, // 12: bytebase.v1.VCSProviderService.ListVCSProviders:input_type -> bytebase.v1.ListVCSProvidersRequest- 1, // 13: bytebase.v1.VCSProviderService.CreateVCSProvider:input_type -> bytebase.v1.CreateVCSProviderRequest- 5, // 14: bytebase.v1.VCSProviderService.UpdateVCSProvider:input_type -> bytebase.v1.UpdateVCSProviderRequest- 13, // 15: bytebase.v1.VCSProviderService.ExchangeToken:input_type -> bytebase.v1.ExchangeTokenRequest- 6, // 16: bytebase.v1.VCSProviderService.DeleteVCSProvider:input_type -> bytebase.v1.DeleteVCSProviderRequest- 7, // 17: bytebase.v1.VCSProviderService.SearchVCSProviderProjects:input_type -> bytebase.v1.SearchVCSProviderProjectsRequest- 9, // 18: bytebase.v1.VCSProviderService.ListProjectGitOpsInfo:input_type -> bytebase.v1.ListProjectGitOpsInfoRequest- 11, // 19: bytebase.v1.VCSProviderService.GetVCSProvider:output_type -> bytebase.v1.VCSProvider- 4, // 20: bytebase.v1.VCSProviderService.ListVCSProviders:output_type -> bytebase.v1.ListVCSProvidersResponse- 11, // 21: bytebase.v1.VCSProviderService.CreateVCSProvider:output_type -> bytebase.v1.VCSProvider- 11, // 22: bytebase.v1.VCSProviderService.UpdateVCSProvider:output_type -> bytebase.v1.VCSProvider- 15, // 23: bytebase.v1.VCSProviderService.ExchangeToken:output_type -> bytebase.v1.OAuthToken- 19, // 24: bytebase.v1.VCSProviderService.DeleteVCSProvider:output_type -> google.protobuf.Empty- 8, // 25: bytebase.v1.VCSProviderService.SearchVCSProviderProjects:output_type -> bytebase.v1.SearchVCSProviderProjectsResponse- 10, // 26: bytebase.v1.VCSProviderService.ListProjectGitOpsInfo:output_type -> bytebase.v1.ListProjectGitOpsInfoResponse- 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+ 2, // 7: bytebase.v1.VCSProviderService.GetVCSProvider:input_type -> bytebase.v1.GetVCSProviderRequest+ 3, // 8: bytebase.v1.VCSProviderService.ListVCSProviders:input_type -> bytebase.v1.ListVCSProvidersRequest+ 1, // 9: bytebase.v1.VCSProviderService.CreateVCSProvider:input_type -> bytebase.v1.CreateVCSProviderRequest+ 5, // 10: bytebase.v1.VCSProviderService.UpdateVCSProvider:input_type -> bytebase.v1.UpdateVCSProviderRequest+ 6, // 11: bytebase.v1.VCSProviderService.DeleteVCSProvider:input_type -> bytebase.v1.DeleteVCSProviderRequest+ 7, // 12: bytebase.v1.VCSProviderService.SearchVCSProviderProjects:input_type -> bytebase.v1.SearchVCSProviderProjectsRequest+ 9, // 13: bytebase.v1.VCSProviderService.ListProjectGitOpsInfo:input_type -> bytebase.v1.ListProjectGitOpsInfoRequest+ 11, // 14: bytebase.v1.VCSProviderService.GetVCSProvider:output_type -> bytebase.v1.VCSProvider+ 4, // 15: bytebase.v1.VCSProviderService.ListVCSProviders:output_type -> bytebase.v1.ListVCSProvidersResponse+ 11, // 16: bytebase.v1.VCSProviderService.CreateVCSProvider:output_type -> bytebase.v1.VCSProvider+ 11, // 17: bytebase.v1.VCSProviderService.UpdateVCSProvider:output_type -> bytebase.v1.VCSProvider+ 15, // 18: bytebase.v1.VCSProviderService.DeleteVCSProvider:output_type -> google.protobuf.Empty+ 8, // 19: bytebase.v1.VCSProviderService.SearchVCSProviderProjects:output_type -> bytebase.v1.SearchVCSProviderProjectsResponse+ 10, // 20: bytebase.v1.VCSProviderService.ListProjectGitOpsInfo:output_type -> bytebase.v1.ListProjectGitOpsInfoResponse+ 14, // [14:21] is the sub-list for method output_type+ 7, // [7:14] is the sub-list for method input_type+ 7, // [7:7] is the sub-list for extension type_name+ 7, // [7:7] is the sub-list for extension extendee+ 0, // [0:7] is the sub-list for field type_name}func init() { file_v1_vcs_provider_service_proto_init() }@@ -1655,42 +1314,6 @@ func file_v1_vcs_provider_service_proto_init() {}}file_v1_vcs_provider_service_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*ExchangeTokenRequest); i {- case 0:- return &v.state- case 1:- return &v.sizeCache- case 2:- return &v.unknownFields- default:- return nil- }- }- file_v1_vcs_provider_service_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*ExchangeToken); i {- case 0:- return &v.state- case 1:- return &v.sizeCache- case 2:- return &v.unknownFields- default:- return nil- }- }- file_v1_vcs_provider_service_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*OAuthToken); i {- case 0:- return &v.state- case 1:- return &v.sizeCache- case 2:- return &v.unknownFields- default:- return nil- }- }- file_v1_vcs_provider_service_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {switch v := v.(*SearchVCSProviderProjectsResponse_Project); i {case 0:return &v.state@@ -1709,7 +1332,7 @@ func file_v1_vcs_provider_service_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: file_v1_vcs_provider_service_proto_rawDesc,NumEnums: 1,- NumMessages: 16,+ NumMessages: 13,NumExtensions: 0,NumServices: 1,},diff --git a/proto/generated-go/v1/vcs_provider_service.pb.gw.go b/proto/generated-go/v1/vcs_provider_service.pb.gw.goindex 19762d737d..950a4ca81a 100644--- a/proto/generated-go/v1/vcs_provider_service.pb.gw.go+++ b/proto/generated-go/v1/vcs_provider_service.pb.gw.go@@ -245,66 +245,6 @@ func local_request_VCSProviderService_UpdateVCSProvider_0(ctx context.Context, m}-func request_VCSProviderService_ExchangeToken_0(ctx context.Context, marshaler runtime.Marshaler, client VCSProviderServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {- var protoReq ExchangeTokenRequest- var metadata runtime.ServerMetadata-- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.ExchangeToken); err != nil && err != io.EOF {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }-- var (- val string- ok bool- err error- _ = err- )-- val, ok = pathParams["exchange_token.name"]- if !ok {- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "exchange_token.name")- }-- err = runtime.PopulateFieldFromPath(&protoReq, "exchange_token.name", val)- if err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "exchange_token.name", err)- }-- msg, err := client.ExchangeToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))- return msg, metadata, err--}--func local_request_VCSProviderService_ExchangeToken_0(ctx context.Context, marshaler runtime.Marshaler, server VCSProviderServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {- var protoReq ExchangeTokenRequest- var metadata runtime.ServerMetadata-- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.ExchangeToken); err != nil && err != io.EOF {- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)- }-- var (- val string- ok bool- err error- _ = err- )-- val, ok = pathParams["exchange_token.name"]- if !ok {- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "exchange_token.name")- }-- err = runtime.PopulateFieldFromPath(&protoReq, "exchange_token.name", val)- if err != nil {- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "exchange_token.name", err)- }-- msg, err := server.ExchangeToken(ctx, &protoReq)- return msg, metadata, err--}-func request_VCSProviderService_DeleteVCSProvider_0(ctx context.Context, marshaler runtime.Marshaler, client VCSProviderServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {var protoReq DeleteVCSProviderRequestvar metadata runtime.ServerMetadata@@ -575,31 +515,6 @@ func RegisterVCSProviderServiceHandlerServer(ctx context.Context, mux *runtime.S})- mux.Handle("POST", pattern_VCSProviderService_ExchangeToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {- ctx, cancel := context.WithCancel(req.Context())- defer cancel()- var stream runtime.ServerTransportStream- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)- var err error- var annotatedContext context.Context- annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.VCSProviderService/ExchangeToken", runtime.WithHTTPPathPattern("/v1/{exchange_token.name=vcsProviders/*}:exchangeToken"))- if err != nil {- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)- return- }- resp, md, err := local_request_VCSProviderService_ExchangeToken_0(annotatedContext, inboundMarshaler, server, req, pathParams)- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)- if err != nil {- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)- return- }-- forward_VCSProviderService_ExchangeToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)-- })-mux.Handle("DELETE", pattern_VCSProviderService_DeleteVCSProvider_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -804,28 +719,6 @@ func RegisterVCSProviderServiceHandlerClient(ctx context.Context, mux *runtime.S})- mux.Handle("POST", pattern_VCSProviderService_ExchangeToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {- ctx, cancel := context.WithCancel(req.Context())- defer cancel()- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)- var err error- var annotatedContext context.Context- annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.VCSProviderService/ExchangeToken", runtime.WithHTTPPathPattern("/v1/{exchange_token.name=vcsProviders/*}:exchangeToken"))- if err != nil {- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)- return- }- resp, md, err := request_VCSProviderService_ExchangeToken_0(annotatedContext, inboundMarshaler, client, req, pathParams)- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)- if err != nil {- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)- return- }-- forward_VCSProviderService_ExchangeToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)-- })-mux.Handle("DELETE", pattern_VCSProviderService_DeleteVCSProvider_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -904,8 +797,6 @@ var (pattern_VCSProviderService_UpdateVCSProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "vcsProviders", "vcs_provider.name"}, ""))- pattern_VCSProviderService_ExchangeToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "vcsProviders", "exchange_token.name"}, "exchangeToken"))-pattern_VCSProviderService_DeleteVCSProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "vcsProviders", "name"}, ""))pattern_VCSProviderService_SearchVCSProviderProjects_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "vcsProviders", "name"}, "searchProjects"))@@ -922,8 +813,6 @@ var (forward_VCSProviderService_UpdateVCSProvider_0 = runtime.ForwardResponseMessage- forward_VCSProviderService_ExchangeToken_0 = runtime.ForwardResponseMessage-forward_VCSProviderService_DeleteVCSProvider_0 = runtime.ForwardResponseMessageforward_VCSProviderService_SearchVCSProviderProjects_0 = runtime.ForwardResponseMessagediff --git a/proto/generated-go/v1/vcs_provider_service_grpc.pb.go b/proto/generated-go/v1/vcs_provider_service_grpc.pb.goindex c54051cb67..0a2894f022 100644--- a/proto/generated-go/v1/vcs_provider_service_grpc.pb.go+++ b/proto/generated-go/v1/vcs_provider_service_grpc.pb.go@@ -24,7 +24,6 @@ const (VCSProviderService_ListVCSProviders_FullMethodName = "/bytebase.v1.VCSProviderService/ListVCSProviders"VCSProviderService_CreateVCSProvider_FullMethodName = "/bytebase.v1.VCSProviderService/CreateVCSProvider"VCSProviderService_UpdateVCSProvider_FullMethodName = "/bytebase.v1.VCSProviderService/UpdateVCSProvider"- VCSProviderService_ExchangeToken_FullMethodName = "/bytebase.v1.VCSProviderService/ExchangeToken"VCSProviderService_DeleteVCSProvider_FullMethodName = "/bytebase.v1.VCSProviderService/DeleteVCSProvider"VCSProviderService_SearchVCSProviderProjects_FullMethodName = "/bytebase.v1.VCSProviderService/SearchVCSProviderProjects"VCSProviderService_ListProjectGitOpsInfo_FullMethodName = "/bytebase.v1.VCSProviderService/ListProjectGitOpsInfo"@@ -38,7 +37,6 @@ type VCSProviderServiceClient interface {ListVCSProviders(ctx context.Context, in *ListVCSProvidersRequest, opts ...grpc.CallOption) (*ListVCSProvidersResponse, error)CreateVCSProvider(ctx context.Context, in *CreateVCSProviderRequest, opts ...grpc.CallOption) (*VCSProvider, error)UpdateVCSProvider(ctx context.Context, in *UpdateVCSProviderRequest, opts ...grpc.CallOption) (*VCSProvider, error)- ExchangeToken(ctx context.Context, in *ExchangeTokenRequest, opts ...grpc.CallOption) (*OAuthToken, error)DeleteVCSProvider(ctx context.Context, in *DeleteVCSProviderRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)SearchVCSProviderProjects(ctx context.Context, in *SearchVCSProviderProjectsRequest, opts ...grpc.CallOption) (*SearchVCSProviderProjectsResponse, error)ListProjectGitOpsInfo(ctx context.Context, in *ListProjectGitOpsInfoRequest, opts ...grpc.CallOption) (*ListProjectGitOpsInfoResponse, error)@@ -88,15 +86,6 @@ func (c *vCSProviderServiceClient) UpdateVCSProvider(ctx context.Context, in *Upreturn out, nil}-func (c *vCSProviderServiceClient) ExchangeToken(ctx context.Context, in *ExchangeTokenRequest, opts ...grpc.CallOption) (*OAuthToken, error) {- out := new(OAuthToken)- err := c.cc.Invoke(ctx, VCSProviderService_ExchangeToken_FullMethodName, in, out, opts...)- if err != nil {- return nil, err- }- return out, nil-}-func (c *vCSProviderServiceClient) DeleteVCSProvider(ctx context.Context, in *DeleteVCSProviderRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {out := new(emptypb.Empty)err := c.cc.Invoke(ctx, VCSProviderService_DeleteVCSProvider_FullMethodName, in, out, opts...)@@ -132,7 +121,6 @@ type VCSProviderServiceServer interface {ListVCSProviders(context.Context, *ListVCSProvidersRequest) (*ListVCSProvidersResponse, error)CreateVCSProvider(context.Context, *CreateVCSProviderRequest) (*VCSProvider, error)UpdateVCSProvider(context.Context, *UpdateVCSProviderRequest) (*VCSProvider, error)- ExchangeToken(context.Context, *ExchangeTokenRequest) (*OAuthToken, error)DeleteVCSProvider(context.Context, *DeleteVCSProviderRequest) (*emptypb.Empty, error)SearchVCSProviderProjects(context.Context, *SearchVCSProviderProjectsRequest) (*SearchVCSProviderProjectsResponse, error)ListProjectGitOpsInfo(context.Context, *ListProjectGitOpsInfoRequest) (*ListProjectGitOpsInfoResponse, error)@@ -155,9 +143,6 @@ func (UnimplementedVCSProviderServiceServer) CreateVCSProvider(context.Context,func (UnimplementedVCSProviderServiceServer) UpdateVCSProvider(context.Context, *UpdateVCSProviderRequest) (*VCSProvider, error) {return nil, status.Errorf(codes.Unimplemented, "method UpdateVCSProvider not implemented")}-func (UnimplementedVCSProviderServiceServer) ExchangeToken(context.Context, *ExchangeTokenRequest) (*OAuthToken, error) {- return nil, status.Errorf(codes.Unimplemented, "method ExchangeToken not implemented")-}func (UnimplementedVCSProviderServiceServer) DeleteVCSProvider(context.Context, *DeleteVCSProviderRequest) (*emptypb.Empty, error) {return nil, status.Errorf(codes.Unimplemented, "method DeleteVCSProvider not implemented")}@@ -252,24 +237,6 @@ func _VCSProviderService_UpdateVCSProvider_Handler(srv interface{}, ctx context.return interceptor(ctx, in, info, handler)}-func _VCSProviderService_ExchangeToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {- in := new(ExchangeTokenRequest)- if err := dec(in); err != nil {- return nil, err- }- if interceptor == nil {- return srv.(VCSProviderServiceServer).ExchangeToken(ctx, in)- }- info := &grpc.UnaryServerInfo{- Server: srv,- FullMethod: VCSProviderService_ExchangeToken_FullMethodName,- }- handler := func(ctx context.Context, req interface{}) (interface{}, error) {- return srv.(VCSProviderServiceServer).ExchangeToken(ctx, req.(*ExchangeTokenRequest))- }- return interceptor(ctx, in, info, handler)-}-func _VCSProviderService_DeleteVCSProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {in := new(DeleteVCSProviderRequest)if err := dec(in); err != nil {@@ -347,10 +314,6 @@ var VCSProviderService_ServiceDesc = grpc.ServiceDesc{MethodName: "UpdateVCSProvider",Handler: _VCSProviderService_UpdateVCSProvider_Handler,},- {- MethodName: "ExchangeToken",- Handler: _VCSProviderService_ExchangeToken_Handler,- },{MethodName: "DeleteVCSProvider",Handler: _VCSProviderService_DeleteVCSProvider_Handler,diff --git a/proto/v1/vcs_provider_service.proto b/proto/v1/vcs_provider_service.protoindex 2ebd2624da..9de401038d 100644--- a/proto/v1/vcs_provider_service.proto+++ b/proto/v1/vcs_provider_service.proto@@ -7,7 +7,6 @@ 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/timestamp.proto";option go_package = "generated-go/v1";@@ -38,14 +37,6 @@ service VCSProviderService {option (google.api.method_signature) = "vcs_provider,update_mask";}- rpc ExchangeToken(ExchangeTokenRequest) returns (OAuthToken) {- option (google.api.http) = {- post: "/v1/{exchange_token.name=vcsProviders/*}:exchangeToken"- body: "exchange_token"- };- option (google.api.method_signature) = "";- }-rpc DeleteVCSProvider(DeleteVCSProviderRequest) returns (google.protobuf.Empty) {option (google.api.http) = {delete: "/v1/{name=vcsProviders/*}"};}@@ -109,10 +100,6 @@ message SearchVCSProviderProjectsRequest {// The name of the vcs provider to retrieve the vcs provider repositories.// Format: vcsProviders/{vcsProvider}string name = 1 [(google.api.field_behavior) = REQUIRED];-- string access_token = 2 [(google.api.field_behavior) = REQUIRED];-- string refresh_token = 3 [(google.api.field_behavior) = REQUIRED];}message SearchVCSProviderProjectsResponse {@@ -167,14 +154,8 @@ message VCSProvider {// For example: github.com, gitlab.com, gitlab.bytebase.com.string url = 4 [(google.api.field_behavior) = REQUIRED];- // The API url of the vcs provider. Derived from the url.- string api_url = 5 [(google.api.field_behavior) = OUTPUT_ONLY];-- // The application ID of the vcs provider. Specified by the client.- string application_id = 6 [(google.api.field_behavior) = REQUIRED];-- // The application secret of the vcs provider. Specified by the client.- string secret = 7 [(google.api.field_behavior) = INPUT_ONLY];+ // The access token of the vcs provider.+ string access_token = 5 [(google.api.field_behavior) = INPUT_ONLY];}message ProjectGitOpsInfo {@@ -211,10 +192,6 @@ message ProjectGitOpsInfo {// If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}.string schema_path_template = 9;- // The file path template for matching the sql files for sheet.- // If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}.- string sheet_path_template = 10;-// The reposition external id in target VCS.string external_id = 11;@@ -223,38 +200,4 @@ message ProjectGitOpsInfo {// The webhook endpoint ID of the repository.string webhook_endpoint_id = 13 [(google.api.field_behavior) = OUTPUT_ONLY];-- string access_token = 14 [(google.api.field_behavior) = INPUT_ONLY];-- google.protobuf.Timestamp expires_time = 15 [(google.api.field_behavior) = INPUT_ONLY];-- string refresh_token = 16 [(google.api.field_behavior) = INPUT_ONLY];-}--message ExchangeTokenRequest {- ExchangeToken exchange_token = 1;-}--message ExchangeToken {- // The name of the vcs provider to retrieve the linked projects.- // Format: vcsProviders/{vcsProvider}- string name = 1;-- string code = 2;-- VCSProvider.Type type = 3;-- string instance_url = 4;-- string client_id = 5;-- string client_secret = 6;-}--message OAuthToken {- string access_token = 1 [(google.api.field_behavior) = OUTPUT_ONLY];-- string refresh_token = 2 [(google.api.field_behavior) = OUTPUT_ONLY];-- google.protobuf.Timestamp expires_time = 15 [(google.api.field_behavior) = OUTPUT_ONLY];}