From 62185c62f76bf96e9838658ee0fbac96009803b4 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 15:20:32 +0000 Subject: [PATCH 01/16] chore: rename `git_auth` to `external_auth` in our schema We're changing Git auth to be external auth. It will support any OAuth2 or OIDC provider. To split up the larger change I want to contribute the schema changes first, and I'll add the feature itself in another PR. --- cli/cliui/gitauth.go | 2 +- cli/cliui/gitauth_test.go | 6 +- cli/create.go | 4 +- cli/create_test.go | 8 +- cmd/cliui/main.go | 8 +- coderd/apidoc/docs.go | 38 +- coderd/apidoc/swagger.json | 33 +- coderd/database/dbauthz/dbauthz.go | 42 +- coderd/database/dbauthz/dbauthz_test.go | 16 +- coderd/database/dbfake/dbfake.go | 42 +- coderd/database/dbgen/dbgen.go | 4 +- coderd/database/dbgen/dbgen_test.go | 4 +- coderd/database/dbmetrics/dbmetrics.go | 50 +- coderd/database/dbmock/dbmock.go | 114 ++-- coderd/database/dump.sql | 36 +- coderd/database/foreign_key_constraint.go | 4 +- .../migrations/000158_external_auth.down.sql | 0 .../migrations/000158_external_auth.up.sql | 3 + coderd/database/modelmethods.go | 2 +- coderd/database/models.go | 22 +- coderd/database/querier.go | 10 +- coderd/database/queries.sql.go | 632 +++++++++--------- .../queries/{gitauth.sql => externalauth.sql} | 16 +- coderd/database/queries/templateversions.sql | 4 +- coderd/database/unique_constraint.go | 2 +- coderd/gitauth.go | 16 +- coderd/gitauth/config.go | 72 +- coderd/gitauth/config_test.go | 30 +- coderd/gitauth/oauth.go | 46 +- coderd/gitauth_test.go | 66 +- .../provisionerdserver/provisionerdserver.go | 10 +- .../provisionerdserver_test.go | 4 +- coderd/templateversions.go | 8 +- coderd/templateversions_test.go | 14 +- coderd/workspaceagents.go | 14 +- codersdk/templateversions.go | 20 +- codersdk/workspaceagents.go | 25 +- docs/api/schemas.md | 49 +- docs/api/templates.md | 33 +- enterprise/cli/server_dbcrypt_test.go | 6 +- enterprise/dbcrypt/cliutil.go | 8 +- enterprise/dbcrypt/dbcrypt.go | 42 +- enterprise/dbcrypt/dbcrypt_internal_test.go | 28 +- site/src/api/typesGenerated.ts | 28 +- .../CreateWorkspacePage.test.tsx | 10 +- .../CreateWorkspacePageView.tsx | 6 +- site/src/testHelpers/entities.ts | 15 +- 47 files changed, 841 insertions(+), 811 deletions(-) create mode 100644 coderd/database/migrations/000158_external_auth.down.sql create mode 100644 coderd/database/migrations/000158_external_auth.up.sql rename coderd/database/queries/{gitauth.sql => externalauth.sql} (60%) diff --git a/cli/cliui/gitauth.go b/cli/cliui/gitauth.go index 2e9453c1aac9d..7c42160da7230 100644 --- a/cli/cliui/gitauth.go +++ b/cli/cliui/gitauth.go @@ -12,7 +12,7 @@ import ( ) type GitAuthOptions struct { - Fetch func(context.Context) ([]codersdk.TemplateVersionGitAuth, error) + Fetch func(context.Context) ([]codersdk.TemplateVersionExternalAuth, error) FetchInterval time.Duration } diff --git a/cli/cliui/gitauth_test.go b/cli/cliui/gitauth_test.go index 22da1b46ca6f9..3adbfc051032b 100644 --- a/cli/cliui/gitauth_test.go +++ b/cli/cliui/gitauth_test.go @@ -26,11 +26,11 @@ func TestGitAuth(t *testing.T) { Handler: func(inv *clibase.Invocation) error { var fetched atomic.Bool return cliui.GitAuth(inv.Context(), inv.Stdout, cliui.GitAuthOptions{ - Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionGitAuth, error) { + Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) { defer fetched.Store(true) - return []codersdk.TemplateVersionGitAuth{{ + return []codersdk.TemplateVersionExternalAuth{{ ID: "github", - Type: codersdk.GitProviderGitHub, + Type: codersdk.ExternalAuthProviderGitHub, Authenticated: fetched.Load(), AuthenticateURL: "https://example.com/gitauth/github", }}, nil diff --git a/cli/create.go b/cli/create.go index d66e89fc48786..8c5bc6b3e759c 100644 --- a/cli/create.go +++ b/cli/create.go @@ -266,8 +266,8 @@ func prepWorkspaceBuild(inv *clibase.Invocation, client *codersdk.Client, args p } err = cliui.GitAuth(ctx, inv.Stdout, cliui.GitAuthOptions{ - Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionGitAuth, error) { - return client.TemplateVersionGitAuth(ctx, templateVersion.ID) + Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) { + return client.TemplateVersionExternalAuth(ctx, templateVersion.ID) }, }) if err != nil { diff --git a/cli/create_test.go b/cli/create_test.go index 7ad774edcc7cb..08575143cf557 100644 --- a/cli/create_test.go +++ b/cli/create_test.go @@ -610,10 +610,10 @@ func TestCreateWithGitAuth(t *testing.T) { client := coderdtest.New(t, &coderdtest.Options{ GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, IncludeProvisionerDaemon: true, }) diff --git a/cmd/cliui/main.go b/cmd/cliui/main.go index 16137d5733c8e..565815d9448bb 100644 --- a/cmd/cliui/main.go +++ b/cmd/cliui/main.go @@ -332,16 +332,16 @@ func main() { gitlabAuthed.Store(true) }() return cliui.GitAuth(inv.Context(), inv.Stdout, cliui.GitAuthOptions{ - Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionGitAuth, error) { + Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) { count.Add(1) - return []codersdk.TemplateVersionGitAuth{{ + return []codersdk.TemplateVersionExternalAuth{{ ID: "github", - Type: codersdk.GitProviderGitHub, + Type: codersdk.ExternalAuthProviderGitHub, Authenticated: githubAuthed.Load(), AuthenticateURL: "https://example.com/gitauth/github?redirect=" + url.QueryEscape("/gitauth?notify"), }, { ID: "gitlab", - Type: codersdk.GitProviderGitLab, + Type: codersdk.ExternalAuthProviderGitLab, Authenticated: gitlabAuthed.Load(), AuthenticateURL: "https://example.com/gitauth/gitlab?redirect=" + url.QueryEscape("/gitauth?notify"), }}, nil diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index f1a9242c8f2ab..003baf16796b4 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -2799,7 +2799,7 @@ const docTemplate = `{ "schema": { "type": "array", "items": { - "$ref": "#/definitions/codersdk.TemplateVersionGitAuth" + "$ref": "#/definitions/codersdk.TemplateVersionExternalAuth" } } } @@ -8186,6 +8186,23 @@ const docTemplate = `{ "ExperimentDeploymentHealthPage" ] }, + "codersdk.ExternalAuthProvider": { + "type": "string", + "enum": [ + "azure-devops", + "github", + "gitlab", + "bitbucket", + "openid-connect" + ], + "x-enum-varnames": [ + "ExternalAuthProviderAzureDevops", + "ExternalAuthProviderGitHub", + "ExternalAuthProviderGitLab", + "ExternalAuthProviderBitBucket", + "ExternalAuthProviderOpenIDConnect" + ] + }, "codersdk.Feature": { "type": "object", "properties": { @@ -8360,21 +8377,6 @@ const docTemplate = `{ } } }, - "codersdk.GitProvider": { - "type": "string", - "enum": [ - "azure-devops", - "github", - "gitlab", - "bitbucket" - ], - "x-enum-varnames": [ - "GitProviderAzureDevops", - "GitProviderGitHub", - "GitProviderGitLab", - "GitProviderBitBucket" - ] - }, "codersdk.GitSSHKey": { "type": "object", "properties": { @@ -10007,7 +10009,7 @@ const docTemplate = `{ } } }, - "codersdk.TemplateVersionGitAuth": { + "codersdk.TemplateVersionExternalAuth": { "type": "object", "properties": { "authenticate_url": { @@ -10020,7 +10022,7 @@ const docTemplate = `{ "type": "string" }, "type": { - "$ref": "#/definitions/codersdk.GitProvider" + "$ref": "#/definitions/codersdk.ExternalAuthProvider" } } }, diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 52ee8dbf03e8b..ec02780589503 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -2457,7 +2457,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/codersdk.TemplateVersionGitAuth" + "$ref": "#/definitions/codersdk.TemplateVersionExternalAuth" } } } @@ -7334,6 +7334,23 @@ "ExperimentDeploymentHealthPage" ] }, + "codersdk.ExternalAuthProvider": { + "type": "string", + "enum": [ + "azure-devops", + "github", + "gitlab", + "bitbucket", + "openid-connect" + ], + "x-enum-varnames": [ + "ExternalAuthProviderAzureDevops", + "ExternalAuthProviderGitHub", + "ExternalAuthProviderGitLab", + "ExternalAuthProviderBitBucket", + "ExternalAuthProviderOpenIDConnect" + ] + }, "codersdk.Feature": { "type": "object", "properties": { @@ -7508,16 +7525,6 @@ } } }, - "codersdk.GitProvider": { - "type": "string", - "enum": ["azure-devops", "github", "gitlab", "bitbucket"], - "x-enum-varnames": [ - "GitProviderAzureDevops", - "GitProviderGitHub", - "GitProviderGitLab", - "GitProviderBitBucket" - ] - }, "codersdk.GitSSHKey": { "type": "object", "properties": { @@ -9049,7 +9056,7 @@ } } }, - "codersdk.TemplateVersionGitAuth": { + "codersdk.TemplateVersionExternalAuth": { "type": "object", "properties": { "authenticate_url": { @@ -9062,7 +9069,7 @@ "type": "string" }, "type": { - "$ref": "#/definitions/codersdk.GitProvider" + "$ref": "#/definitions/codersdk.ExternalAuthProvider" } } }, diff --git a/coderd/database/dbauthz/dbauthz.go b/coderd/database/dbauthz/dbauthz.go index c751d75eab650..bee782a1aacd8 100644 --- a/coderd/database/dbauthz/dbauthz.go +++ b/coderd/database/dbauthz/dbauthz.go @@ -913,6 +913,17 @@ func (q *querier) GetDeploymentWorkspaceStats(ctx context.Context) (database.Get return q.db.GetDeploymentWorkspaceStats(ctx) } +func (q *querier) GetExternalAuthLink(ctx context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { + return fetch(q.log, q.auth, q.db.GetExternalAuthLink)(ctx, arg) +} + +func (q *querier) GetExternalAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.ExternalAuthLink, error) { + if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceSystem); err != nil { + return nil, err + } + return q.db.GetExternalAuthLinksByUserID(ctx, userID) +} + func (q *querier) GetFileByHashAndCreator(ctx context.Context, arg database.GetFileByHashAndCreatorParams) (database.File, error) { file, err := q.db.GetFileByHashAndCreator(ctx, arg) if err != nil { @@ -952,17 +963,6 @@ func (q *querier) GetFileTemplates(ctx context.Context, fileID uuid.UUID) ([]dat return q.db.GetFileTemplates(ctx, fileID) } -func (q *querier) GetGitAuthLink(ctx context.Context, arg database.GetGitAuthLinkParams) (database.GitAuthLink, error) { - return fetch(q.log, q.auth, q.db.GetGitAuthLink)(ctx, arg) -} - -func (q *querier) GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.GitAuthLink, error) { - if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceSystem); err != nil { - return nil, err - } - return q.db.GetGitAuthLinksByUserID(ctx, userID) -} - func (q *querier) GetGitSSHKey(ctx context.Context, userID uuid.UUID) (database.GitSSHKey, error) { return fetch(q.log, q.auth, q.db.GetGitSSHKey)(ctx, userID) } @@ -1955,12 +1955,12 @@ func (q *querier) InsertDeploymentID(ctx context.Context, value string) error { return q.db.InsertDeploymentID(ctx, value) } -func (q *querier) InsertFile(ctx context.Context, arg database.InsertFileParams) (database.File, error) { - return insert(q.log, q.auth, rbac.ResourceFile.WithOwner(arg.CreatedBy.String()), q.db.InsertFile)(ctx, arg) +func (q *querier) InsertExternalAuthLink(ctx context.Context, arg database.InsertExternalAuthLinkParams) (database.ExternalAuthLink, error) { + return insert(q.log, q.auth, rbac.ResourceUserData.WithOwner(arg.UserID.String()).WithID(arg.UserID), q.db.InsertExternalAuthLink)(ctx, arg) } -func (q *querier) InsertGitAuthLink(ctx context.Context, arg database.InsertGitAuthLinkParams) (database.GitAuthLink, error) { - return insert(q.log, q.auth, rbac.ResourceUserData.WithOwner(arg.UserID.String()).WithID(arg.UserID), q.db.InsertGitAuthLink)(ctx, arg) +func (q *querier) InsertFile(ctx context.Context, arg database.InsertFileParams) (database.File, error) { + return insert(q.log, q.auth, rbac.ResourceFile.WithOwner(arg.CreatedBy.String()), q.db.InsertFile)(ctx, arg) } func (q *querier) InsertGitSSHKey(ctx context.Context, arg database.InsertGitSSHKeyParams) (database.GitSSHKey, error) { @@ -2267,11 +2267,11 @@ func (q *querier) UpdateAPIKeyByID(ctx context.Context, arg database.UpdateAPIKe return update(q.log, q.auth, fetch, q.db.UpdateAPIKeyByID)(ctx, arg) } -func (q *querier) UpdateGitAuthLink(ctx context.Context, arg database.UpdateGitAuthLinkParams) (database.GitAuthLink, error) { - fetch := func(ctx context.Context, arg database.UpdateGitAuthLinkParams) (database.GitAuthLink, error) { - return q.db.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{UserID: arg.UserID, ProviderID: arg.ProviderID}) +func (q *querier) UpdateExternalAuthLink(ctx context.Context, arg database.UpdateExternalAuthLinkParams) (database.ExternalAuthLink, error) { + fetch := func(ctx context.Context, arg database.UpdateExternalAuthLinkParams) (database.ExternalAuthLink, error) { + return q.db.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{UserID: arg.UserID, ProviderID: arg.ProviderID}) } - return updateWithReturn(q.log, q.auth, fetch, q.db.UpdateGitAuthLink)(ctx, arg) + return updateWithReturn(q.log, q.auth, fetch, q.db.UpdateExternalAuthLink)(ctx, arg) } func (q *querier) UpdateGitSSHKey(ctx context.Context, arg database.UpdateGitSSHKeyParams) (database.GitSSHKey, error) { @@ -2485,7 +2485,7 @@ func (q *querier) UpdateTemplateVersionDescriptionByJobID(ctx context.Context, a return q.db.UpdateTemplateVersionDescriptionByJobID(ctx, arg) } -func (q *querier) UpdateTemplateVersionGitAuthProvidersByJobID(ctx context.Context, arg database.UpdateTemplateVersionGitAuthProvidersByJobIDParams) error { +func (q *querier) UpdateTemplateVersionExternalAuthProvidersByJobID(ctx context.Context, arg database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams) error { // An actor is allowed to update the template version git auth providers if they are authorized to update the template. tv, err := q.db.GetTemplateVersionByJobID(ctx, arg.JobID) if err != nil { @@ -2504,7 +2504,7 @@ func (q *querier) UpdateTemplateVersionGitAuthProvidersByJobID(ctx context.Conte if err := q.authorizeContext(ctx, rbac.ActionUpdate, obj); err != nil { return err } - return q.db.UpdateTemplateVersionGitAuthProvidersByJobID(ctx, arg) + return q.db.UpdateTemplateVersionExternalAuthProvidersByJobID(ctx, arg) } func (q *querier) UpdateTemplateWorkspacesLastUsedAt(ctx context.Context, arg database.UpdateTemplateWorkspacesLastUsedAtParams) error { diff --git a/coderd/database/dbauthz/dbauthz_test.go b/coderd/database/dbauthz/dbauthz_test.go index eb9be63f87cac..672b9c8782d14 100644 --- a/coderd/database/dbauthz/dbauthz_test.go +++ b/coderd/database/dbauthz/dbauthz_test.go @@ -832,9 +832,9 @@ func (s *MethodTestSuite) TestTemplate() { TemplateID: uuid.NullUUID{UUID: t1.ID, Valid: true}, JobID: jobID, }) - check.Args(database.UpdateTemplateVersionGitAuthProvidersByJobIDParams{ - JobID: jobID, - GitAuthProviders: []string{}, + check.Args(database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams{ + JobID: jobID, + ExternalAuthProviders: []string{}, }).Asserts(t1, rbac.ActionUpdate).Returns() })) } @@ -954,22 +954,22 @@ func (s *MethodTestSuite) TestUser() { }).Asserts(key, rbac.ActionUpdate).Returns(key) })) s.Run("GetGitAuthLink", s.Subtest(func(db database.Store, check *expects) { - link := dbgen.GitAuthLink(s.T(), db, database.GitAuthLink{}) - check.Args(database.GetGitAuthLinkParams{ + link := dbgen.GitAuthLink(s.T(), db, database.ExternalAuthLink{}) + check.Args(database.GetExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, }).Asserts(link, rbac.ActionRead).Returns(link) })) s.Run("InsertGitAuthLink", s.Subtest(func(db database.Store, check *expects) { u := dbgen.User(s.T(), db, database.User{}) - check.Args(database.InsertGitAuthLinkParams{ + check.Args(database.InsertExternalAuthLinkParams{ ProviderID: uuid.NewString(), UserID: u.ID, }).Asserts(rbac.ResourceUserData.WithOwner(u.ID.String()).WithID(u.ID), rbac.ActionCreate) })) s.Run("UpdateGitAuthLink", s.Subtest(func(db database.Store, check *expects) { - link := dbgen.GitAuthLink(s.T(), db, database.GitAuthLink{}) - check.Args(database.UpdateGitAuthLinkParams{ + link := dbgen.GitAuthLink(s.T(), db, database.ExternalAuthLink{}) + check.Args(database.UpdateExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, OAuthAccessToken: link.OAuthAccessToken, diff --git a/coderd/database/dbfake/dbfake.go b/coderd/database/dbfake/dbfake.go index fcc4f76e2c98b..81b39d183cb06 100644 --- a/coderd/database/dbfake/dbfake.go +++ b/coderd/database/dbfake/dbfake.go @@ -51,7 +51,7 @@ func New() database.Store { organizations: make([]database.Organization, 0), users: make([]database.User, 0), dbcryptKeys: make([]database.DBCryptKey, 0), - gitAuthLinks: make([]database.GitAuthLink, 0), + externalAuthLinks: make([]database.ExternalAuthLink, 0), groups: make([]database.Group, 0), groupMembers: make([]database.GroupMember, 0), auditLogs: make([]database.AuditLog, 0), @@ -125,7 +125,7 @@ type data struct { auditLogs []database.AuditLog dbcryptKeys []database.DBCryptKey files []database.File - gitAuthLinks []database.GitAuthLink + externalAuthLinks []database.ExternalAuthLink gitSSHKey []database.GitSSHKey groupMembers []database.GroupMember groups []database.Group @@ -1507,14 +1507,14 @@ func (q *FakeQuerier) GetFileTemplates(_ context.Context, id uuid.UUID) ([]datab return rows, nil } -func (q *FakeQuerier) GetGitAuthLink(_ context.Context, arg database.GetGitAuthLinkParams) (database.GitAuthLink, error) { +func (q *FakeQuerier) GetExternalAuthLink(_ context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { if err := validateDatabaseType(arg); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } q.mutex.RLock() defer q.mutex.RUnlock() - for _, gitAuthLink := range q.gitAuthLinks { + for _, gitAuthLink := range q.externalAuthLinks { if arg.UserID != gitAuthLink.UserID { continue } @@ -1523,14 +1523,14 @@ func (q *FakeQuerier) GetGitAuthLink(_ context.Context, arg database.GetGitAuthL } return gitAuthLink, nil } - return database.GitAuthLink{}, sql.ErrNoRows + return database.ExternalAuthLink{}, sql.ErrNoRows } -func (q *FakeQuerier) GetGitAuthLinksByUserID(_ context.Context, userID uuid.UUID) ([]database.GitAuthLink, error) { +func (q *FakeQuerier) GetExternalAuthLinksByUserID(_ context.Context, userID uuid.UUID) ([]database.ExternalAuthLink, error) { q.mutex.RLock() defer q.mutex.RUnlock() - gals := make([]database.GitAuthLink, 0) - for _, gal := range q.gitAuthLinks { + gals := make([]database.ExternalAuthLink, 0) + for _, gal := range q.externalAuthLinks { if gal.UserID == userID { gals = append(gals, gal) } @@ -4226,15 +4226,15 @@ func (q *FakeQuerier) InsertFile(_ context.Context, arg database.InsertFileParam return file, nil } -func (q *FakeQuerier) InsertGitAuthLink(_ context.Context, arg database.InsertGitAuthLinkParams) (database.GitAuthLink, error) { +func (q *FakeQuerier) InsertExternalAuthLink(_ context.Context, arg database.InsertExternalAuthLinkParams) (database.ExternalAuthLink, error) { if err := validateDatabaseType(arg); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } q.mutex.Lock() defer q.mutex.Unlock() // nolint:gosimple - gitAuthLink := database.GitAuthLink{ + gitAuthLink := database.ExternalAuthLink{ ProviderID: arg.ProviderID, UserID: arg.UserID, CreatedAt: arg.CreatedAt, @@ -4245,7 +4245,7 @@ func (q *FakeQuerier) InsertGitAuthLink(_ context.Context, arg database.InsertGi OAuthRefreshTokenKeyID: arg.OAuthRefreshTokenKeyID, OAuthExpiry: arg.OAuthExpiry, } - q.gitAuthLinks = append(q.gitAuthLinks, gitAuthLink) + q.externalAuthLinks = append(q.externalAuthLinks, gitAuthLink) return gitAuthLink, nil } @@ -5214,7 +5214,7 @@ func (q *FakeQuerier) RevokeDBCryptKey(_ context.Context, activeKeyDigest string return errForeignKeyConstraint } } - for _, gal := range q.gitAuthLinks { + for _, gal := range q.externalAuthLinks { if (gal.OAuthAccessTokenKeyID.Valid && gal.OAuthAccessTokenKeyID.String == activeKeyDigest) || (gal.OAuthRefreshTokenKeyID.Valid && gal.OAuthRefreshTokenKeyID.String == activeKeyDigest) { return errForeignKeyConstraint @@ -5256,14 +5256,14 @@ func (q *FakeQuerier) UpdateAPIKeyByID(_ context.Context, arg database.UpdateAPI return sql.ErrNoRows } -func (q *FakeQuerier) UpdateGitAuthLink(_ context.Context, arg database.UpdateGitAuthLinkParams) (database.GitAuthLink, error) { +func (q *FakeQuerier) UpdateExternalAuthLink(_ context.Context, arg database.UpdateExternalAuthLinkParams) (database.ExternalAuthLink, error) { if err := validateDatabaseType(arg); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } q.mutex.Lock() defer q.mutex.Unlock() - for index, gitAuthLink := range q.gitAuthLinks { + for index, gitAuthLink := range q.externalAuthLinks { if gitAuthLink.ProviderID != arg.ProviderID { continue } @@ -5276,11 +5276,11 @@ func (q *FakeQuerier) UpdateGitAuthLink(_ context.Context, arg database.UpdateGi gitAuthLink.OAuthRefreshToken = arg.OAuthRefreshToken gitAuthLink.OAuthRefreshTokenKeyID = arg.OAuthRefreshTokenKeyID gitAuthLink.OAuthExpiry = arg.OAuthExpiry - q.gitAuthLinks[index] = gitAuthLink + q.externalAuthLinks[index] = gitAuthLink return gitAuthLink, nil } - return database.GitAuthLink{}, sql.ErrNoRows + return database.ExternalAuthLink{}, sql.ErrNoRows } func (q *FakeQuerier) UpdateGitSSHKey(_ context.Context, arg database.UpdateGitSSHKeyParams) (database.GitSSHKey, error) { @@ -5623,7 +5623,7 @@ func (q *FakeQuerier) UpdateTemplateVersionDescriptionByJobID(_ context.Context, return sql.ErrNoRows } -func (q *FakeQuerier) UpdateTemplateVersionGitAuthProvidersByJobID(_ context.Context, arg database.UpdateTemplateVersionGitAuthProvidersByJobIDParams) error { +func (q *FakeQuerier) UpdateTemplateVersionExternalAuthProvidersByJobID(_ context.Context, arg database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams) error { if err := validateDatabaseType(arg); err != nil { return err } @@ -5635,7 +5635,7 @@ func (q *FakeQuerier) UpdateTemplateVersionGitAuthProvidersByJobID(_ context.Con if templateVersion.JobID != arg.JobID { continue } - templateVersion.GitAuthProviders = arg.GitAuthProviders + templateVersion.ExternalAuthProviders = arg.ExternalAuthProviders templateVersion.UpdatedAt = arg.UpdatedAt q.templateVersions[index] = templateVersion return nil diff --git a/coderd/database/dbgen/dbgen.go b/coderd/database/dbgen/dbgen.go index 61cae7bd5a201..251b9dc7adf2c 100644 --- a/coderd/database/dbgen/dbgen.go +++ b/coderd/database/dbgen/dbgen.go @@ -504,8 +504,8 @@ func UserLink(t testing.TB, db database.Store, orig database.UserLink) database. return link } -func GitAuthLink(t testing.TB, db database.Store, orig database.GitAuthLink) database.GitAuthLink { - link, err := db.InsertGitAuthLink(genCtx, database.InsertGitAuthLinkParams{ +func GitAuthLink(t testing.TB, db database.Store, orig database.ExternalAuthLink) database.ExternalAuthLink { + link, err := db.InsertExternalAuthLink(genCtx, database.InsertExternalAuthLinkParams{ ProviderID: takeFirst(orig.ProviderID, uuid.New().String()), UserID: takeFirst(orig.UserID, uuid.New()), OAuthAccessToken: takeFirst(orig.OAuthAccessToken, uuid.NewString()), diff --git a/coderd/database/dbgen/dbgen_test.go b/coderd/database/dbgen/dbgen_test.go index 9fc7a5f427f8b..ea99d3e1863e5 100644 --- a/coderd/database/dbgen/dbgen_test.go +++ b/coderd/database/dbgen/dbgen_test.go @@ -47,8 +47,8 @@ func TestGenerator(t *testing.T) { t.Run("GitAuthLink", func(t *testing.T) { t.Parallel() db := dbfake.New() - exp := dbgen.GitAuthLink(t, db, database.GitAuthLink{}) - require.Equal(t, exp, must(db.GetGitAuthLink(context.Background(), database.GetGitAuthLinkParams{ + exp := dbgen.GitAuthLink(t, db, database.ExternalAuthLink{}) + require.Equal(t, exp, must(db.GetExternalAuthLink(context.Background(), database.GetExternalAuthLinkParams{ ProviderID: exp.ProviderID, UserID: exp.UserID, }))) diff --git a/coderd/database/dbmetrics/dbmetrics.go b/coderd/database/dbmetrics/dbmetrics.go index 16f65ad84b35d..9f385fec013d5 100644 --- a/coderd/database/dbmetrics/dbmetrics.go +++ b/coderd/database/dbmetrics/dbmetrics.go @@ -363,6 +363,20 @@ func (m metricsStore) GetDeploymentWorkspaceStats(ctx context.Context) (database return row, err } +func (m metricsStore) GetExternalAuthLink(ctx context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { + start := time.Now() + link, err := m.s.GetExternalAuthLink(ctx, arg) + m.queryLatencies.WithLabelValues("GetGitAuthLink").Observe(time.Since(start).Seconds()) + return link, err +} + +func (m metricsStore) GetExternalAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.ExternalAuthLink, error) { + start := time.Now() + r0, r1 := m.s.GetExternalAuthLinksByUserID(ctx, userID) + m.queryLatencies.WithLabelValues("GetGitAuthLinksByUserID").Observe(time.Since(start).Seconds()) + return r0, r1 +} + func (m metricsStore) GetFileByHashAndCreator(ctx context.Context, arg database.GetFileByHashAndCreatorParams) (database.File, error) { start := time.Now() file, err := m.s.GetFileByHashAndCreator(ctx, arg) @@ -384,20 +398,6 @@ func (m metricsStore) GetFileTemplates(ctx context.Context, fileID uuid.UUID) ([ return rows, err } -func (m metricsStore) GetGitAuthLink(ctx context.Context, arg database.GetGitAuthLinkParams) (database.GitAuthLink, error) { - start := time.Now() - link, err := m.s.GetGitAuthLink(ctx, arg) - m.queryLatencies.WithLabelValues("GetGitAuthLink").Observe(time.Since(start).Seconds()) - return link, err -} - -func (m metricsStore) GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.GitAuthLink, error) { - start := time.Now() - r0, r1 := m.s.GetGitAuthLinksByUserID(ctx, userID) - m.queryLatencies.WithLabelValues("GetGitAuthLinksByUserID").Observe(time.Since(start).Seconds()) - return r0, r1 -} - func (m metricsStore) GetGitSSHKey(ctx context.Context, userID uuid.UUID) (database.GitSSHKey, error) { start := time.Now() key, err := m.s.GetGitSSHKey(ctx, userID) @@ -1166,6 +1166,13 @@ func (m metricsStore) InsertDeploymentID(ctx context.Context, value string) erro return err } +func (m metricsStore) InsertExternalAuthLink(ctx context.Context, arg database.InsertExternalAuthLinkParams) (database.ExternalAuthLink, error) { + start := time.Now() + link, err := m.s.InsertExternalAuthLink(ctx, arg) + m.queryLatencies.WithLabelValues("InsertGitAuthLink").Observe(time.Since(start).Seconds()) + return link, err +} + func (m metricsStore) InsertFile(ctx context.Context, arg database.InsertFileParams) (database.File, error) { start := time.Now() file, err := m.s.InsertFile(ctx, arg) @@ -1173,13 +1180,6 @@ func (m metricsStore) InsertFile(ctx context.Context, arg database.InsertFilePar return file, err } -func (m metricsStore) InsertGitAuthLink(ctx context.Context, arg database.InsertGitAuthLinkParams) (database.GitAuthLink, error) { - start := time.Now() - link, err := m.s.InsertGitAuthLink(ctx, arg) - m.queryLatencies.WithLabelValues("InsertGitAuthLink").Observe(time.Since(start).Seconds()) - return link, err -} - func (m metricsStore) InsertGitSSHKey(ctx context.Context, arg database.InsertGitSSHKeyParams) (database.GitSSHKey, error) { start := time.Now() key, err := m.s.InsertGitSSHKey(ctx, arg) @@ -1439,9 +1439,9 @@ func (m metricsStore) UpdateAPIKeyByID(ctx context.Context, arg database.UpdateA return err } -func (m metricsStore) UpdateGitAuthLink(ctx context.Context, arg database.UpdateGitAuthLinkParams) (database.GitAuthLink, error) { +func (m metricsStore) UpdateExternalAuthLink(ctx context.Context, arg database.UpdateExternalAuthLinkParams) (database.ExternalAuthLink, error) { start := time.Now() - link, err := m.s.UpdateGitAuthLink(ctx, arg) + link, err := m.s.UpdateExternalAuthLink(ctx, arg) m.queryLatencies.WithLabelValues("UpdateGitAuthLink").Observe(time.Since(start).Seconds()) return link, err } @@ -1551,9 +1551,9 @@ func (m metricsStore) UpdateTemplateVersionDescriptionByJobID(ctx context.Contex return err } -func (m metricsStore) UpdateTemplateVersionGitAuthProvidersByJobID(ctx context.Context, arg database.UpdateTemplateVersionGitAuthProvidersByJobIDParams) error { +func (m metricsStore) UpdateTemplateVersionExternalAuthProvidersByJobID(ctx context.Context, arg database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams) error { start := time.Now() - err := m.s.UpdateTemplateVersionGitAuthProvidersByJobID(ctx, arg) + err := m.s.UpdateTemplateVersionExternalAuthProvidersByJobID(ctx, arg) m.queryLatencies.WithLabelValues("UpdateTemplateVersionGitAuthProvidersByJobID").Observe(time.Since(start).Seconds()) return err } diff --git a/coderd/database/dbmock/dbmock.go b/coderd/database/dbmock/dbmock.go index 3d64a27aaa351..b2001b8b19640 100644 --- a/coderd/database/dbmock/dbmock.go +++ b/coderd/database/dbmock/dbmock.go @@ -683,6 +683,36 @@ func (mr *MockStoreMockRecorder) GetDeploymentWorkspaceStats(arg0 interface{}) * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeploymentWorkspaceStats", reflect.TypeOf((*MockStore)(nil).GetDeploymentWorkspaceStats), arg0) } +// GetExternalAuthLink mocks base method. +func (m *MockStore) GetExternalAuthLink(arg0 context.Context, arg1 database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetExternalAuthLink", arg0, arg1) + ret0, _ := ret[0].(database.ExternalAuthLink) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetExternalAuthLink indicates an expected call of GetExternalAuthLink. +func (mr *MockStoreMockRecorder) GetExternalAuthLink(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExternalAuthLink", reflect.TypeOf((*MockStore)(nil).GetExternalAuthLink), arg0, arg1) +} + +// GetExternalAuthLinksByUserID mocks base method. +func (m *MockStore) GetExternalAuthLinksByUserID(arg0 context.Context, arg1 uuid.UUID) ([]database.ExternalAuthLink, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetExternalAuthLinksByUserID", arg0, arg1) + ret0, _ := ret[0].([]database.ExternalAuthLink) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetExternalAuthLinksByUserID indicates an expected call of GetExternalAuthLinksByUserID. +func (mr *MockStoreMockRecorder) GetExternalAuthLinksByUserID(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExternalAuthLinksByUserID", reflect.TypeOf((*MockStore)(nil).GetExternalAuthLinksByUserID), arg0, arg1) +} + // GetFileByHashAndCreator mocks base method. func (m *MockStore) GetFileByHashAndCreator(arg0 context.Context, arg1 database.GetFileByHashAndCreatorParams) (database.File, error) { m.ctrl.T.Helper() @@ -728,36 +758,6 @@ func (mr *MockStoreMockRecorder) GetFileTemplates(arg0, arg1 interface{}) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFileTemplates", reflect.TypeOf((*MockStore)(nil).GetFileTemplates), arg0, arg1) } -// GetGitAuthLink mocks base method. -func (m *MockStore) GetGitAuthLink(arg0 context.Context, arg1 database.GetGitAuthLinkParams) (database.GitAuthLink, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetGitAuthLink", arg0, arg1) - ret0, _ := ret[0].(database.GitAuthLink) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetGitAuthLink indicates an expected call of GetGitAuthLink. -func (mr *MockStoreMockRecorder) GetGitAuthLink(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGitAuthLink", reflect.TypeOf((*MockStore)(nil).GetGitAuthLink), arg0, arg1) -} - -// GetGitAuthLinksByUserID mocks base method. -func (m *MockStore) GetGitAuthLinksByUserID(arg0 context.Context, arg1 uuid.UUID) ([]database.GitAuthLink, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetGitAuthLinksByUserID", arg0, arg1) - ret0, _ := ret[0].([]database.GitAuthLink) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetGitAuthLinksByUserID indicates an expected call of GetGitAuthLinksByUserID. -func (mr *MockStoreMockRecorder) GetGitAuthLinksByUserID(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGitAuthLinksByUserID", reflect.TypeOf((*MockStore)(nil).GetGitAuthLinksByUserID), arg0, arg1) -} - // GetGitSSHKey mocks base method. func (m *MockStore) GetGitSSHKey(arg0 context.Context, arg1 uuid.UUID) (database.GitSSHKey, error) { m.ctrl.T.Helper() @@ -2449,34 +2449,34 @@ func (mr *MockStoreMockRecorder) InsertDeploymentID(arg0, arg1 interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertDeploymentID", reflect.TypeOf((*MockStore)(nil).InsertDeploymentID), arg0, arg1) } -// InsertFile mocks base method. -func (m *MockStore) InsertFile(arg0 context.Context, arg1 database.InsertFileParams) (database.File, error) { +// InsertExternalAuthLink mocks base method. +func (m *MockStore) InsertExternalAuthLink(arg0 context.Context, arg1 database.InsertExternalAuthLinkParams) (database.ExternalAuthLink, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "InsertFile", arg0, arg1) - ret0, _ := ret[0].(database.File) + ret := m.ctrl.Call(m, "InsertExternalAuthLink", arg0, arg1) + ret0, _ := ret[0].(database.ExternalAuthLink) ret1, _ := ret[1].(error) return ret0, ret1 } -// InsertFile indicates an expected call of InsertFile. -func (mr *MockStoreMockRecorder) InsertFile(arg0, arg1 interface{}) *gomock.Call { +// InsertExternalAuthLink indicates an expected call of InsertExternalAuthLink. +func (mr *MockStoreMockRecorder) InsertExternalAuthLink(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertFile", reflect.TypeOf((*MockStore)(nil).InsertFile), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertExternalAuthLink", reflect.TypeOf((*MockStore)(nil).InsertExternalAuthLink), arg0, arg1) } -// InsertGitAuthLink mocks base method. -func (m *MockStore) InsertGitAuthLink(arg0 context.Context, arg1 database.InsertGitAuthLinkParams) (database.GitAuthLink, error) { +// InsertFile mocks base method. +func (m *MockStore) InsertFile(arg0 context.Context, arg1 database.InsertFileParams) (database.File, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "InsertGitAuthLink", arg0, arg1) - ret0, _ := ret[0].(database.GitAuthLink) + ret := m.ctrl.Call(m, "InsertFile", arg0, arg1) + ret0, _ := ret[0].(database.File) ret1, _ := ret[1].(error) return ret0, ret1 } -// InsertGitAuthLink indicates an expected call of InsertGitAuthLink. -func (mr *MockStoreMockRecorder) InsertGitAuthLink(arg0, arg1 interface{}) *gomock.Call { +// InsertFile indicates an expected call of InsertFile. +func (mr *MockStoreMockRecorder) InsertFile(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertGitAuthLink", reflect.TypeOf((*MockStore)(nil).InsertGitAuthLink), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertFile", reflect.TypeOf((*MockStore)(nil).InsertFile), arg0, arg1) } // InsertGitSSHKey mocks base method. @@ -3038,19 +3038,19 @@ func (mr *MockStoreMockRecorder) UpdateAPIKeyByID(arg0, arg1 interface{}) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAPIKeyByID", reflect.TypeOf((*MockStore)(nil).UpdateAPIKeyByID), arg0, arg1) } -// UpdateGitAuthLink mocks base method. -func (m *MockStore) UpdateGitAuthLink(arg0 context.Context, arg1 database.UpdateGitAuthLinkParams) (database.GitAuthLink, error) { +// UpdateExternalAuthLink mocks base method. +func (m *MockStore) UpdateExternalAuthLink(arg0 context.Context, arg1 database.UpdateExternalAuthLinkParams) (database.ExternalAuthLink, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateGitAuthLink", arg0, arg1) - ret0, _ := ret[0].(database.GitAuthLink) + ret := m.ctrl.Call(m, "UpdateExternalAuthLink", arg0, arg1) + ret0, _ := ret[0].(database.ExternalAuthLink) ret1, _ := ret[1].(error) return ret0, ret1 } -// UpdateGitAuthLink indicates an expected call of UpdateGitAuthLink. -func (mr *MockStoreMockRecorder) UpdateGitAuthLink(arg0, arg1 interface{}) *gomock.Call { +// UpdateExternalAuthLink indicates an expected call of UpdateExternalAuthLink. +func (mr *MockStoreMockRecorder) UpdateExternalAuthLink(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGitAuthLink", reflect.TypeOf((*MockStore)(nil).UpdateGitAuthLink), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExternalAuthLink", reflect.TypeOf((*MockStore)(nil).UpdateExternalAuthLink), arg0, arg1) } // UpdateGitSSHKey mocks base method. @@ -3268,18 +3268,18 @@ func (mr *MockStoreMockRecorder) UpdateTemplateVersionDescriptionByJobID(arg0, a return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTemplateVersionDescriptionByJobID", reflect.TypeOf((*MockStore)(nil).UpdateTemplateVersionDescriptionByJobID), arg0, arg1) } -// UpdateTemplateVersionGitAuthProvidersByJobID mocks base method. -func (m *MockStore) UpdateTemplateVersionGitAuthProvidersByJobID(arg0 context.Context, arg1 database.UpdateTemplateVersionGitAuthProvidersByJobIDParams) error { +// UpdateTemplateVersionExternalAuthProvidersByJobID mocks base method. +func (m *MockStore) UpdateTemplateVersionExternalAuthProvidersByJobID(arg0 context.Context, arg1 database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateTemplateVersionGitAuthProvidersByJobID", arg0, arg1) + ret := m.ctrl.Call(m, "UpdateTemplateVersionExternalAuthProvidersByJobID", arg0, arg1) ret0, _ := ret[0].(error) return ret0 } -// UpdateTemplateVersionGitAuthProvidersByJobID indicates an expected call of UpdateTemplateVersionGitAuthProvidersByJobID. -func (mr *MockStoreMockRecorder) UpdateTemplateVersionGitAuthProvidersByJobID(arg0, arg1 interface{}) *gomock.Call { +// UpdateTemplateVersionExternalAuthProvidersByJobID indicates an expected call of UpdateTemplateVersionExternalAuthProvidersByJobID. +func (mr *MockStoreMockRecorder) UpdateTemplateVersionExternalAuthProvidersByJobID(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTemplateVersionGitAuthProvidersByJobID", reflect.TypeOf((*MockStore)(nil).UpdateTemplateVersionGitAuthProvidersByJobID), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTemplateVersionExternalAuthProvidersByJobID", reflect.TypeOf((*MockStore)(nil).UpdateTemplateVersionExternalAuthProvidersByJobID), arg0, arg1) } // UpdateTemplateWorkspacesLastUsedAt mocks base method. diff --git a/coderd/database/dump.sql b/coderd/database/dump.sql index fd8529d78af46..4ce61a2b95331 100644 --- a/coderd/database/dump.sql +++ b/coderd/database/dump.sql @@ -333,16 +333,7 @@ COMMENT ON COLUMN dbcrypt_keys.revoked_at IS 'The time at which the key was revo COMMENT ON COLUMN dbcrypt_keys.test IS 'A column used to test the encryption.'; -CREATE TABLE files ( - hash character varying(64) NOT NULL, - created_at timestamp with time zone NOT NULL, - created_by uuid NOT NULL, - mimetype character varying(64) NOT NULL, - data bytea NOT NULL, - id uuid DEFAULT gen_random_uuid() NOT NULL -); - -CREATE TABLE git_auth_links ( +CREATE TABLE external_auth_links ( provider_id text NOT NULL, user_id uuid NOT NULL, created_at timestamp with time zone NOT NULL, @@ -354,9 +345,18 @@ CREATE TABLE git_auth_links ( oauth_refresh_token_key_id text ); -COMMENT ON COLUMN git_auth_links.oauth_access_token_key_id IS 'The ID of the key used to encrypt the OAuth access token. If this is NULL, the access token is not encrypted'; +COMMENT ON COLUMN external_auth_links.oauth_access_token_key_id IS 'The ID of the key used to encrypt the OAuth access token. If this is NULL, the access token is not encrypted'; -COMMENT ON COLUMN git_auth_links.oauth_refresh_token_key_id IS 'The ID of the key used to encrypt the OAuth refresh token. If this is NULL, the refresh token is not encrypted'; +COMMENT ON COLUMN external_auth_links.oauth_refresh_token_key_id IS 'The ID of the key used to encrypt the OAuth refresh token. If this is NULL, the refresh token is not encrypted'; + +CREATE TABLE files ( + hash character varying(64) NOT NULL, + created_at timestamp with time zone NOT NULL, + created_by uuid NOT NULL, + mimetype character varying(64) NOT NULL, + data bytea NOT NULL, + id uuid DEFAULT gen_random_uuid() NOT NULL +); CREATE TABLE gitsshkeys ( user_id uuid NOT NULL, @@ -639,11 +639,11 @@ CREATE TABLE template_versions ( readme character varying(1048576) NOT NULL, job_id uuid NOT NULL, created_by uuid NOT NULL, - git_auth_providers text[], + external_auth_providers text[], message character varying(1048576) DEFAULT ''::character varying NOT NULL ); -COMMENT ON COLUMN template_versions.git_auth_providers IS 'IDs of Git auth providers for a specific template version'; +COMMENT ON COLUMN template_versions.external_auth_providers IS 'IDs of Git auth providers for a specific template version'; COMMENT ON COLUMN template_versions.message IS 'Message describing the changes in this version of the template, similar to a Git commit message. Like a commit message, this should be a short, high-level description of the changes in this version of the template. This message is immutable and should not be updated after the fact.'; @@ -683,7 +683,7 @@ CREATE VIEW template_version_with_user AS template_versions.readme, template_versions.job_id, template_versions.created_by, - template_versions.git_auth_providers, + template_versions.external_auth_providers AS git_auth_providers, template_versions.message, COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url, COALESCE(visible_users.username, ''::text) AS created_by_username @@ -1136,7 +1136,7 @@ ALTER TABLE ONLY files ALTER TABLE ONLY files ADD CONSTRAINT files_pkey PRIMARY KEY (id); -ALTER TABLE ONLY git_auth_links +ALTER TABLE ONLY external_auth_links ADD CONSTRAINT git_auth_links_provider_id_user_id_key UNIQUE (provider_id, user_id); ALTER TABLE ONLY gitsshkeys @@ -1348,10 +1348,10 @@ CREATE TRIGGER trigger_update_users AFTER INSERT OR UPDATE ON users FOR EACH ROW ALTER TABLE ONLY api_keys ADD CONSTRAINT api_keys_user_id_uuid_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; -ALTER TABLE ONLY git_auth_links +ALTER TABLE ONLY external_auth_links ADD CONSTRAINT git_auth_links_oauth_access_token_key_id_fkey FOREIGN KEY (oauth_access_token_key_id) REFERENCES dbcrypt_keys(active_key_digest); -ALTER TABLE ONLY git_auth_links +ALTER TABLE ONLY external_auth_links ADD CONSTRAINT git_auth_links_oauth_refresh_token_key_id_fkey FOREIGN KEY (oauth_refresh_token_key_id) REFERENCES dbcrypt_keys(active_key_digest); ALTER TABLE ONLY gitsshkeys diff --git a/coderd/database/foreign_key_constraint.go b/coderd/database/foreign_key_constraint.go index 9bab83c9d04e2..c2e81fd3bf817 100644 --- a/coderd/database/foreign_key_constraint.go +++ b/coderd/database/foreign_key_constraint.go @@ -7,8 +7,8 @@ type ForeignKeyConstraint string // ForeignKeyConstraint enums. const ( ForeignKeyAPIKeysUserIDUUID ForeignKeyConstraint = "api_keys_user_id_uuid_fkey" // ALTER TABLE ONLY api_keys ADD CONSTRAINT api_keys_user_id_uuid_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; - ForeignKeyGitAuthLinksOauthAccessTokenKeyID ForeignKeyConstraint = "git_auth_links_oauth_access_token_key_id_fkey" // ALTER TABLE ONLY git_auth_links ADD CONSTRAINT git_auth_links_oauth_access_token_key_id_fkey FOREIGN KEY (oauth_access_token_key_id) REFERENCES dbcrypt_keys(active_key_digest); - ForeignKeyGitAuthLinksOauthRefreshTokenKeyID ForeignKeyConstraint = "git_auth_links_oauth_refresh_token_key_id_fkey" // ALTER TABLE ONLY git_auth_links ADD CONSTRAINT git_auth_links_oauth_refresh_token_key_id_fkey FOREIGN KEY (oauth_refresh_token_key_id) REFERENCES dbcrypt_keys(active_key_digest); + ForeignKeyGitAuthLinksOauthAccessTokenKeyID ForeignKeyConstraint = "git_auth_links_oauth_access_token_key_id_fkey" // ALTER TABLE ONLY external_auth_links ADD CONSTRAINT git_auth_links_oauth_access_token_key_id_fkey FOREIGN KEY (oauth_access_token_key_id) REFERENCES dbcrypt_keys(active_key_digest); + ForeignKeyGitAuthLinksOauthRefreshTokenKeyID ForeignKeyConstraint = "git_auth_links_oauth_refresh_token_key_id_fkey" // ALTER TABLE ONLY external_auth_links ADD CONSTRAINT git_auth_links_oauth_refresh_token_key_id_fkey FOREIGN KEY (oauth_refresh_token_key_id) REFERENCES dbcrypt_keys(active_key_digest); ForeignKeyGitSSHKeysUserID ForeignKeyConstraint = "gitsshkeys_user_id_fkey" // ALTER TABLE ONLY gitsshkeys ADD CONSTRAINT gitsshkeys_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id); ForeignKeyGroupMembersGroupID ForeignKeyConstraint = "group_members_group_id_fkey" // ALTER TABLE ONLY group_members ADD CONSTRAINT group_members_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE; ForeignKeyGroupMembersUserID ForeignKeyConstraint = "group_members_user_id_fkey" // ALTER TABLE ONLY group_members ADD CONSTRAINT group_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; diff --git a/coderd/database/migrations/000158_external_auth.down.sql b/coderd/database/migrations/000158_external_auth.down.sql new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/coderd/database/migrations/000158_external_auth.up.sql b/coderd/database/migrations/000158_external_auth.up.sql new file mode 100644 index 0000000000000..3fe17b2660100 --- /dev/null +++ b/coderd/database/migrations/000158_external_auth.up.sql @@ -0,0 +1,3 @@ +ALTER TABLE template_versions RENAME COLUMN git_auth_providers TO external_auth_providers; + +ALTER TABLE git_auth_links RENAME TO external_auth_links; diff --git a/coderd/database/modelmethods.go b/coderd/database/modelmethods.go index ddf7041307a8c..98eca86de3c3e 100644 --- a/coderd/database/modelmethods.go +++ b/coderd/database/modelmethods.go @@ -250,7 +250,7 @@ func (u GitSSHKey) RBACObject() rbac.Object { return rbac.ResourceUserData.WithID(u.UserID).WithOwner(u.UserID.String()) } -func (u GitAuthLink) RBACObject() rbac.Object { +func (u ExternalAuthLink) RBACObject() rbac.Object { // I assume UserData is ok? return rbac.ResourceUserData.WithID(u.UserID).WithOwner(u.UserID.String()) } diff --git a/coderd/database/models.go b/coderd/database/models.go index 41615f8af2a09..4ad2878174e9a 100644 --- a/coderd/database/models.go +++ b/coderd/database/models.go @@ -1537,16 +1537,7 @@ type DBCryptKey struct { Test string `db:"test" json:"test"` } -type File struct { - Hash string `db:"hash" json:"hash"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - CreatedBy uuid.UUID `db:"created_by" json:"created_by"` - Mimetype string `db:"mimetype" json:"mimetype"` - Data []byte `db:"data" json:"data"` - ID uuid.UUID `db:"id" json:"id"` -} - -type GitAuthLink struct { +type ExternalAuthLink struct { ProviderID string `db:"provider_id" json:"provider_id"` UserID uuid.UUID `db:"user_id" json:"user_id"` CreatedAt time.Time `db:"created_at" json:"created_at"` @@ -1560,6 +1551,15 @@ type GitAuthLink struct { OAuthRefreshTokenKeyID sql.NullString `db:"oauth_refresh_token_key_id" json:"oauth_refresh_token_key_id"` } +type File struct { + Hash string `db:"hash" json:"hash"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + CreatedBy uuid.UUID `db:"created_by" json:"created_by"` + Mimetype string `db:"mimetype" json:"mimetype"` + Data []byte `db:"data" json:"data"` + ID uuid.UUID `db:"id" json:"id"` +} + type GitSSHKey struct { UserID uuid.UUID `db:"user_id" json:"user_id"` CreatedAt time.Time `db:"created_at" json:"created_at"` @@ -1858,7 +1858,7 @@ type TemplateVersionTable struct { JobID uuid.UUID `db:"job_id" json:"job_id"` CreatedBy uuid.UUID `db:"created_by" json:"created_by"` // IDs of Git auth providers for a specific template version - GitAuthProviders []string `db:"git_auth_providers" json:"git_auth_providers"` + ExternalAuthProviders []string `db:"external_auth_providers" json:"external_auth_providers"` // Message describing the changes in this version of the template, similar to a Git commit message. Like a commit message, this should be a short, high-level description of the changes in this version of the template. This message is immutable and should not be updated after the fact. Message string `db:"message" json:"message"` } diff --git a/coderd/database/querier.go b/coderd/database/querier.go index 7cfba57762245..04b7a4a4eedad 100644 --- a/coderd/database/querier.go +++ b/coderd/database/querier.go @@ -77,12 +77,12 @@ type sqlcQuerier interface { GetDeploymentID(ctx context.Context) (string, error) GetDeploymentWorkspaceAgentStats(ctx context.Context, createdAt time.Time) (GetDeploymentWorkspaceAgentStatsRow, error) GetDeploymentWorkspaceStats(ctx context.Context) (GetDeploymentWorkspaceStatsRow, error) + GetExternalAuthLink(ctx context.Context, arg GetExternalAuthLinkParams) (ExternalAuthLink, error) + GetExternalAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]ExternalAuthLink, error) GetFileByHashAndCreator(ctx context.Context, arg GetFileByHashAndCreatorParams) (File, error) GetFileByID(ctx context.Context, id uuid.UUID) (File, error) // Get all templates that use a file. GetFileTemplates(ctx context.Context, fileID uuid.UUID) ([]GetFileTemplatesRow, error) - GetGitAuthLink(ctx context.Context, arg GetGitAuthLinkParams) (GitAuthLink, error) - GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]GitAuthLink, error) GetGitSSHKey(ctx context.Context, userID uuid.UUID) (GitSSHKey, error) GetGroupByID(ctx context.Context, id uuid.UUID) (Group, error) GetGroupByOrgAndName(ctx context.Context, arg GetGroupByOrgAndNameParams) (Group, error) @@ -234,8 +234,8 @@ type sqlcQuerier interface { InsertDBCryptKey(ctx context.Context, arg InsertDBCryptKeyParams) error InsertDERPMeshKey(ctx context.Context, value string) error InsertDeploymentID(ctx context.Context, value string) error + InsertExternalAuthLink(ctx context.Context, arg InsertExternalAuthLinkParams) (ExternalAuthLink, error) InsertFile(ctx context.Context, arg InsertFileParams) (File, error) - InsertGitAuthLink(ctx context.Context, arg InsertGitAuthLinkParams) (GitAuthLink, error) InsertGitSSHKey(ctx context.Context, arg InsertGitSSHKeyParams) (GitSSHKey, error) InsertGroup(ctx context.Context, arg InsertGroupParams) (Group, error) InsertGroupMember(ctx context.Context, arg InsertGroupMemberParams) error @@ -282,7 +282,7 @@ type sqlcQuerier interface { // released when the transaction ends. TryAcquireLock(ctx context.Context, pgTryAdvisoryXactLock int64) (bool, error) UpdateAPIKeyByID(ctx context.Context, arg UpdateAPIKeyByIDParams) error - UpdateGitAuthLink(ctx context.Context, arg UpdateGitAuthLinkParams) (GitAuthLink, error) + UpdateExternalAuthLink(ctx context.Context, arg UpdateExternalAuthLinkParams) (ExternalAuthLink, error) UpdateGitSSHKey(ctx context.Context, arg UpdateGitSSHKeyParams) (GitSSHKey, error) UpdateGroupByID(ctx context.Context, arg UpdateGroupByIDParams) (Group, error) UpdateInactiveUsersToDormant(ctx context.Context, arg UpdateInactiveUsersToDormantParams) ([]UpdateInactiveUsersToDormantRow, error) @@ -298,7 +298,7 @@ type sqlcQuerier interface { UpdateTemplateScheduleByID(ctx context.Context, arg UpdateTemplateScheduleByIDParams) error UpdateTemplateVersionByID(ctx context.Context, arg UpdateTemplateVersionByIDParams) error UpdateTemplateVersionDescriptionByJobID(ctx context.Context, arg UpdateTemplateVersionDescriptionByJobIDParams) error - UpdateTemplateVersionGitAuthProvidersByJobID(ctx context.Context, arg UpdateTemplateVersionGitAuthProvidersByJobIDParams) error + UpdateTemplateVersionExternalAuthProvidersByJobID(ctx context.Context, arg UpdateTemplateVersionExternalAuthProvidersByJobIDParams) error UpdateTemplateWorkspacesLastUsedAt(ctx context.Context, arg UpdateTemplateWorkspacesLastUsedAtParams) error UpdateUserDeletedByID(ctx context.Context, arg UpdateUserDeletedByIDParams) error UpdateUserHashedPassword(ctx context.Context, arg UpdateUserHashedPasswordParams) error diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index 591fc5d36dd78..c8ebb4c62f900 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -750,181 +750,18 @@ func (q *sqlQuerier) RevokeDBCryptKey(ctx context.Context, activeKeyDigest strin return err } -const getFileByHashAndCreator = `-- name: GetFileByHashAndCreator :one -SELECT - hash, created_at, created_by, mimetype, data, id -FROM - files -WHERE - hash = $1 -AND - created_by = $2 -LIMIT - 1 +const getExternalAuthLink = `-- name: GetExternalAuthLink :one +SELECT provider_id, user_id, created_at, updated_at, oauth_access_token, oauth_refresh_token, oauth_expiry, oauth_access_token_key_id, oauth_refresh_token_key_id FROM external_auth_links WHERE provider_id = $1 AND user_id = $2 ` -type GetFileByHashAndCreatorParams struct { - Hash string `db:"hash" json:"hash"` - CreatedBy uuid.UUID `db:"created_by" json:"created_by"` -} - -func (q *sqlQuerier) GetFileByHashAndCreator(ctx context.Context, arg GetFileByHashAndCreatorParams) (File, error) { - row := q.db.QueryRowContext(ctx, getFileByHashAndCreator, arg.Hash, arg.CreatedBy) - var i File - err := row.Scan( - &i.Hash, - &i.CreatedAt, - &i.CreatedBy, - &i.Mimetype, - &i.Data, - &i.ID, - ) - return i, err -} - -const getFileByID = `-- name: GetFileByID :one -SELECT - hash, created_at, created_by, mimetype, data, id -FROM - files -WHERE - id = $1 -LIMIT - 1 -` - -func (q *sqlQuerier) GetFileByID(ctx context.Context, id uuid.UUID) (File, error) { - row := q.db.QueryRowContext(ctx, getFileByID, id) - var i File - err := row.Scan( - &i.Hash, - &i.CreatedAt, - &i.CreatedBy, - &i.Mimetype, - &i.Data, - &i.ID, - ) - return i, err -} - -const getFileTemplates = `-- name: GetFileTemplates :many -SELECT - files.id AS file_id, - files.created_by AS file_created_by, - templates.id AS template_id, - templates.organization_id AS template_organization_id, - templates.created_by AS template_created_by, - templates.user_acl, - templates.group_acl -FROM - templates -INNER JOIN - template_versions - ON templates.id = template_versions.template_id -INNER JOIN - provisioner_jobs - ON job_id = provisioner_jobs.id -INNER JOIN - files - ON files.id = provisioner_jobs.file_id -WHERE - -- Only fetch template version associated files. - storage_method = 'file' - AND provisioner_jobs.type = 'template_version_import' - AND file_id = $1 -` - -type GetFileTemplatesRow struct { - FileID uuid.UUID `db:"file_id" json:"file_id"` - FileCreatedBy uuid.UUID `db:"file_created_by" json:"file_created_by"` - TemplateID uuid.UUID `db:"template_id" json:"template_id"` - TemplateOrganizationID uuid.UUID `db:"template_organization_id" json:"template_organization_id"` - TemplateCreatedBy uuid.UUID `db:"template_created_by" json:"template_created_by"` - UserACL TemplateACL `db:"user_acl" json:"user_acl"` - GroupACL TemplateACL `db:"group_acl" json:"group_acl"` -} - -// Get all templates that use a file. -func (q *sqlQuerier) GetFileTemplates(ctx context.Context, fileID uuid.UUID) ([]GetFileTemplatesRow, error) { - rows, err := q.db.QueryContext(ctx, getFileTemplates, fileID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []GetFileTemplatesRow - for rows.Next() { - var i GetFileTemplatesRow - if err := rows.Scan( - &i.FileID, - &i.FileCreatedBy, - &i.TemplateID, - &i.TemplateOrganizationID, - &i.TemplateCreatedBy, - &i.UserACL, - &i.GroupACL, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const insertFile = `-- name: InsertFile :one -INSERT INTO - files (id, hash, created_at, created_by, mimetype, "data") -VALUES - ($1, $2, $3, $4, $5, $6) RETURNING hash, created_at, created_by, mimetype, data, id -` - -type InsertFileParams struct { - ID uuid.UUID `db:"id" json:"id"` - Hash string `db:"hash" json:"hash"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - CreatedBy uuid.UUID `db:"created_by" json:"created_by"` - Mimetype string `db:"mimetype" json:"mimetype"` - Data []byte `db:"data" json:"data"` -} - -func (q *sqlQuerier) InsertFile(ctx context.Context, arg InsertFileParams) (File, error) { - row := q.db.QueryRowContext(ctx, insertFile, - arg.ID, - arg.Hash, - arg.CreatedAt, - arg.CreatedBy, - arg.Mimetype, - arg.Data, - ) - var i File - err := row.Scan( - &i.Hash, - &i.CreatedAt, - &i.CreatedBy, - &i.Mimetype, - &i.Data, - &i.ID, - ) - return i, err -} - -const getGitAuthLink = `-- name: GetGitAuthLink :one -SELECT provider_id, user_id, created_at, updated_at, oauth_access_token, oauth_refresh_token, oauth_expiry, oauth_access_token_key_id, oauth_refresh_token_key_id FROM git_auth_links WHERE provider_id = $1 AND user_id = $2 -` - -type GetGitAuthLinkParams struct { +type GetExternalAuthLinkParams struct { ProviderID string `db:"provider_id" json:"provider_id"` UserID uuid.UUID `db:"user_id" json:"user_id"` } -func (q *sqlQuerier) GetGitAuthLink(ctx context.Context, arg GetGitAuthLinkParams) (GitAuthLink, error) { - row := q.db.QueryRowContext(ctx, getGitAuthLink, arg.ProviderID, arg.UserID) - var i GitAuthLink +func (q *sqlQuerier) GetExternalAuthLink(ctx context.Context, arg GetExternalAuthLinkParams) (ExternalAuthLink, error) { + row := q.db.QueryRowContext(ctx, getExternalAuthLink, arg.ProviderID, arg.UserID) + var i ExternalAuthLink err := row.Scan( &i.ProviderID, &i.UserID, @@ -939,19 +776,19 @@ func (q *sqlQuerier) GetGitAuthLink(ctx context.Context, arg GetGitAuthLinkParam return i, err } -const getGitAuthLinksByUserID = `-- name: GetGitAuthLinksByUserID :many -SELECT provider_id, user_id, created_at, updated_at, oauth_access_token, oauth_refresh_token, oauth_expiry, oauth_access_token_key_id, oauth_refresh_token_key_id FROM git_auth_links WHERE user_id = $1 +const getExternalAuthLinksByUserID = `-- name: GetExternalAuthLinksByUserID :many +SELECT provider_id, user_id, created_at, updated_at, oauth_access_token, oauth_refresh_token, oauth_expiry, oauth_access_token_key_id, oauth_refresh_token_key_id FROM external_auth_links WHERE user_id = $1 ` -func (q *sqlQuerier) GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]GitAuthLink, error) { - rows, err := q.db.QueryContext(ctx, getGitAuthLinksByUserID, userID) +func (q *sqlQuerier) GetExternalAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]ExternalAuthLink, error) { + rows, err := q.db.QueryContext(ctx, getExternalAuthLinksByUserID, userID) if err != nil { return nil, err } defer rows.Close() - var items []GitAuthLink + var items []ExternalAuthLink for rows.Next() { - var i GitAuthLink + var i ExternalAuthLink if err := rows.Scan( &i.ProviderID, &i.UserID, @@ -976,8 +813,8 @@ func (q *sqlQuerier) GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UU return items, nil } -const insertGitAuthLink = `-- name: InsertGitAuthLink :one -INSERT INTO git_auth_links ( +const insertExternalAuthLink = `-- name: InsertExternalAuthLink :one +INSERT INTO external_auth_links ( provider_id, user_id, created_at, @@ -1000,7 +837,7 @@ INSERT INTO git_auth_links ( ) RETURNING provider_id, user_id, created_at, updated_at, oauth_access_token, oauth_refresh_token, oauth_expiry, oauth_access_token_key_id, oauth_refresh_token_key_id ` -type InsertGitAuthLinkParams struct { +type InsertExternalAuthLinkParams struct { ProviderID string `db:"provider_id" json:"provider_id"` UserID uuid.UUID `db:"user_id" json:"user_id"` CreatedAt time.Time `db:"created_at" json:"created_at"` @@ -1012,8 +849,8 @@ type InsertGitAuthLinkParams struct { OAuthExpiry time.Time `db:"oauth_expiry" json:"oauth_expiry"` } -func (q *sqlQuerier) InsertGitAuthLink(ctx context.Context, arg InsertGitAuthLinkParams) (GitAuthLink, error) { - row := q.db.QueryRowContext(ctx, insertGitAuthLink, +func (q *sqlQuerier) InsertExternalAuthLink(ctx context.Context, arg InsertExternalAuthLinkParams) (ExternalAuthLink, error) { + row := q.db.QueryRowContext(ctx, insertExternalAuthLink, arg.ProviderID, arg.UserID, arg.CreatedAt, @@ -1024,7 +861,7 @@ func (q *sqlQuerier) InsertGitAuthLink(ctx context.Context, arg InsertGitAuthLin arg.OAuthRefreshTokenKeyID, arg.OAuthExpiry, ) - var i GitAuthLink + var i ExternalAuthLink err := row.Scan( &i.ProviderID, &i.UserID, @@ -1039,8 +876,8 @@ func (q *sqlQuerier) InsertGitAuthLink(ctx context.Context, arg InsertGitAuthLin return i, err } -const updateGitAuthLink = `-- name: UpdateGitAuthLink :one -UPDATE git_auth_links SET +const updateExternalAuthLink = `-- name: UpdateExternalAuthLink :one +UPDATE external_auth_links SET updated_at = $3, oauth_access_token = $4, oauth_access_token_key_id = $5, @@ -1050,7 +887,7 @@ UPDATE git_auth_links SET WHERE provider_id = $1 AND user_id = $2 RETURNING provider_id, user_id, created_at, updated_at, oauth_access_token, oauth_refresh_token, oauth_expiry, oauth_access_token_key_id, oauth_refresh_token_key_id ` -type UpdateGitAuthLinkParams struct { +type UpdateExternalAuthLinkParams struct { ProviderID string `db:"provider_id" json:"provider_id"` UserID uuid.UUID `db:"user_id" json:"user_id"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` @@ -1061,8 +898,8 @@ type UpdateGitAuthLinkParams struct { OAuthExpiry time.Time `db:"oauth_expiry" json:"oauth_expiry"` } -func (q *sqlQuerier) UpdateGitAuthLink(ctx context.Context, arg UpdateGitAuthLinkParams) (GitAuthLink, error) { - row := q.db.QueryRowContext(ctx, updateGitAuthLink, +func (q *sqlQuerier) UpdateExternalAuthLink(ctx context.Context, arg UpdateExternalAuthLinkParams) (ExternalAuthLink, error) { + row := q.db.QueryRowContext(ctx, updateExternalAuthLink, arg.ProviderID, arg.UserID, arg.UpdatedAt, @@ -1072,17 +909,180 @@ func (q *sqlQuerier) UpdateGitAuthLink(ctx context.Context, arg UpdateGitAuthLin arg.OAuthRefreshTokenKeyID, arg.OAuthExpiry, ) - var i GitAuthLink + var i ExternalAuthLink + err := row.Scan( + &i.ProviderID, + &i.UserID, + &i.CreatedAt, + &i.UpdatedAt, + &i.OAuthAccessToken, + &i.OAuthRefreshToken, + &i.OAuthExpiry, + &i.OAuthAccessTokenKeyID, + &i.OAuthRefreshTokenKeyID, + ) + return i, err +} + +const getFileByHashAndCreator = `-- name: GetFileByHashAndCreator :one +SELECT + hash, created_at, created_by, mimetype, data, id +FROM + files +WHERE + hash = $1 +AND + created_by = $2 +LIMIT + 1 +` + +type GetFileByHashAndCreatorParams struct { + Hash string `db:"hash" json:"hash"` + CreatedBy uuid.UUID `db:"created_by" json:"created_by"` +} + +func (q *sqlQuerier) GetFileByHashAndCreator(ctx context.Context, arg GetFileByHashAndCreatorParams) (File, error) { + row := q.db.QueryRowContext(ctx, getFileByHashAndCreator, arg.Hash, arg.CreatedBy) + var i File + err := row.Scan( + &i.Hash, + &i.CreatedAt, + &i.CreatedBy, + &i.Mimetype, + &i.Data, + &i.ID, + ) + return i, err +} + +const getFileByID = `-- name: GetFileByID :one +SELECT + hash, created_at, created_by, mimetype, data, id +FROM + files +WHERE + id = $1 +LIMIT + 1 +` + +func (q *sqlQuerier) GetFileByID(ctx context.Context, id uuid.UUID) (File, error) { + row := q.db.QueryRowContext(ctx, getFileByID, id) + var i File + err := row.Scan( + &i.Hash, + &i.CreatedAt, + &i.CreatedBy, + &i.Mimetype, + &i.Data, + &i.ID, + ) + return i, err +} + +const getFileTemplates = `-- name: GetFileTemplates :many +SELECT + files.id AS file_id, + files.created_by AS file_created_by, + templates.id AS template_id, + templates.organization_id AS template_organization_id, + templates.created_by AS template_created_by, + templates.user_acl, + templates.group_acl +FROM + templates +INNER JOIN + template_versions + ON templates.id = template_versions.template_id +INNER JOIN + provisioner_jobs + ON job_id = provisioner_jobs.id +INNER JOIN + files + ON files.id = provisioner_jobs.file_id +WHERE + -- Only fetch template version associated files. + storage_method = 'file' + AND provisioner_jobs.type = 'template_version_import' + AND file_id = $1 +` + +type GetFileTemplatesRow struct { + FileID uuid.UUID `db:"file_id" json:"file_id"` + FileCreatedBy uuid.UUID `db:"file_created_by" json:"file_created_by"` + TemplateID uuid.UUID `db:"template_id" json:"template_id"` + TemplateOrganizationID uuid.UUID `db:"template_organization_id" json:"template_organization_id"` + TemplateCreatedBy uuid.UUID `db:"template_created_by" json:"template_created_by"` + UserACL TemplateACL `db:"user_acl" json:"user_acl"` + GroupACL TemplateACL `db:"group_acl" json:"group_acl"` +} + +// Get all templates that use a file. +func (q *sqlQuerier) GetFileTemplates(ctx context.Context, fileID uuid.UUID) ([]GetFileTemplatesRow, error) { + rows, err := q.db.QueryContext(ctx, getFileTemplates, fileID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []GetFileTemplatesRow + for rows.Next() { + var i GetFileTemplatesRow + if err := rows.Scan( + &i.FileID, + &i.FileCreatedBy, + &i.TemplateID, + &i.TemplateOrganizationID, + &i.TemplateCreatedBy, + &i.UserACL, + &i.GroupACL, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const insertFile = `-- name: InsertFile :one +INSERT INTO + files (id, hash, created_at, created_by, mimetype, "data") +VALUES + ($1, $2, $3, $4, $5, $6) RETURNING hash, created_at, created_by, mimetype, data, id +` + +type InsertFileParams struct { + ID uuid.UUID `db:"id" json:"id"` + Hash string `db:"hash" json:"hash"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + CreatedBy uuid.UUID `db:"created_by" json:"created_by"` + Mimetype string `db:"mimetype" json:"mimetype"` + Data []byte `db:"data" json:"data"` +} + +func (q *sqlQuerier) InsertFile(ctx context.Context, arg InsertFileParams) (File, error) { + row := q.db.QueryRowContext(ctx, insertFile, + arg.ID, + arg.Hash, + arg.CreatedAt, + arg.CreatedBy, + arg.Mimetype, + arg.Data, + ) + var i File err := row.Scan( - &i.ProviderID, - &i.UserID, + &i.Hash, &i.CreatedAt, - &i.UpdatedAt, - &i.OAuthAccessToken, - &i.OAuthRefreshToken, - &i.OAuthExpiry, - &i.OAuthAccessTokenKeyID, - &i.OAuthRefreshTokenKeyID, + &i.CreatedBy, + &i.Mimetype, + &i.Data, + &i.ID, ) return i, err } @@ -5711,24 +5711,24 @@ func (q *sqlQuerier) UpdateTemplateVersionDescriptionByJobID(ctx context.Context return err } -const updateTemplateVersionGitAuthProvidersByJobID = `-- name: UpdateTemplateVersionGitAuthProvidersByJobID :exec +const updateTemplateVersionExternalAuthProvidersByJobID = `-- name: UpdateTemplateVersionExternalAuthProvidersByJobID :exec UPDATE template_versions SET - git_auth_providers = $2, + external_auth_providers = $2, updated_at = $3 WHERE job_id = $1 ` -type UpdateTemplateVersionGitAuthProvidersByJobIDParams struct { - JobID uuid.UUID `db:"job_id" json:"job_id"` - GitAuthProviders []string `db:"git_auth_providers" json:"git_auth_providers"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at"` +type UpdateTemplateVersionExternalAuthProvidersByJobIDParams struct { + JobID uuid.UUID `db:"job_id" json:"job_id"` + ExternalAuthProviders []string `db:"external_auth_providers" json:"external_auth_providers"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at"` } -func (q *sqlQuerier) UpdateTemplateVersionGitAuthProvidersByJobID(ctx context.Context, arg UpdateTemplateVersionGitAuthProvidersByJobIDParams) error { - _, err := q.db.ExecContext(ctx, updateTemplateVersionGitAuthProvidersByJobID, arg.JobID, pq.Array(arg.GitAuthProviders), arg.UpdatedAt) +func (q *sqlQuerier) UpdateTemplateVersionExternalAuthProvidersByJobID(ctx context.Context, arg UpdateTemplateVersionExternalAuthProvidersByJobIDParams) error { + _, err := q.db.ExecContext(ctx, updateTemplateVersionExternalAuthProvidersByJobID, arg.JobID, pq.Array(arg.ExternalAuthProviders), arg.UpdatedAt) return err } @@ -9554,6 +9554,119 @@ func (q *sqlQuerier) InsertWorkspaceResourceMetadata(ctx context.Context, arg In return items, nil } +const getWorkspaceAgentScriptsByAgentIDs = `-- name: GetWorkspaceAgentScriptsByAgentIDs :many +SELECT workspace_agent_id, log_source_id, log_path, created_at, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds FROM workspace_agent_scripts WHERE workspace_agent_id = ANY($1 :: uuid [ ]) +` + +func (q *sqlQuerier) GetWorkspaceAgentScriptsByAgentIDs(ctx context.Context, ids []uuid.UUID) ([]WorkspaceAgentScript, error) { + rows, err := q.db.QueryContext(ctx, getWorkspaceAgentScriptsByAgentIDs, pq.Array(ids)) + if err != nil { + return nil, err + } + defer rows.Close() + var items []WorkspaceAgentScript + for rows.Next() { + var i WorkspaceAgentScript + if err := rows.Scan( + &i.WorkspaceAgentID, + &i.LogSourceID, + &i.LogPath, + &i.CreatedAt, + &i.Script, + &i.Cron, + &i.StartBlocksLogin, + &i.RunOnStart, + &i.RunOnStop, + &i.TimeoutSeconds, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const insertWorkspaceAgentScripts = `-- name: InsertWorkspaceAgentScripts :many +INSERT INTO + workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds) +SELECT + $1 :: uuid AS workspace_agent_id, + $2 :: timestamptz AS created_at, + unnest($3 :: uuid [ ]) AS log_source_id, + unnest($4 :: text [ ]) AS log_path, + unnest($5 :: text [ ]) AS script, + unnest($6 :: text [ ]) AS cron, + unnest($7 :: boolean [ ]) AS start_blocks_login, + unnest($8 :: boolean [ ]) AS run_on_start, + unnest($9 :: boolean [ ]) AS run_on_stop, + unnest($10 :: integer [ ]) AS timeout_seconds +RETURNING workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds +` + +type InsertWorkspaceAgentScriptsParams struct { + WorkspaceAgentID uuid.UUID `db:"workspace_agent_id" json:"workspace_agent_id"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + LogSourceID []uuid.UUID `db:"log_source_id" json:"log_source_id"` + LogPath []string `db:"log_path" json:"log_path"` + Script []string `db:"script" json:"script"` + Cron []string `db:"cron" json:"cron"` + StartBlocksLogin []bool `db:"start_blocks_login" json:"start_blocks_login"` + RunOnStart []bool `db:"run_on_start" json:"run_on_start"` + RunOnStop []bool `db:"run_on_stop" json:"run_on_stop"` + TimeoutSeconds []int32 `db:"timeout_seconds" json:"timeout_seconds"` +} + +func (q *sqlQuerier) InsertWorkspaceAgentScripts(ctx context.Context, arg InsertWorkspaceAgentScriptsParams) ([]WorkspaceAgentScript, error) { + rows, err := q.db.QueryContext(ctx, insertWorkspaceAgentScripts, + arg.WorkspaceAgentID, + arg.CreatedAt, + pq.Array(arg.LogSourceID), + pq.Array(arg.LogPath), + pq.Array(arg.Script), + pq.Array(arg.Cron), + pq.Array(arg.StartBlocksLogin), + pq.Array(arg.RunOnStart), + pq.Array(arg.RunOnStop), + pq.Array(arg.TimeoutSeconds), + ) + if err != nil { + return nil, err + } + defer rows.Close() + var items []WorkspaceAgentScript + for rows.Next() { + var i WorkspaceAgentScript + if err := rows.Scan( + &i.WorkspaceAgentID, + &i.LogSourceID, + &i.LogPath, + &i.CreatedAt, + &i.Script, + &i.Cron, + &i.StartBlocksLogin, + &i.RunOnStart, + &i.RunOnStop, + &i.TimeoutSeconds, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getDeploymentWorkspaceStats = `-- name: GetDeploymentWorkspaceStats :one WITH workspaces_with_jobs AS ( SELECT @@ -10502,116 +10615,3 @@ func (q *sqlQuerier) UpdateWorkspacesDormantDeletingAtByTemplateID(ctx context.C _, err := q.db.ExecContext(ctx, updateWorkspacesDormantDeletingAtByTemplateID, arg.TimeTilDormantAutodeleteMs, arg.DormantAt, arg.TemplateID) return err } - -const getWorkspaceAgentScriptsByAgentIDs = `-- name: GetWorkspaceAgentScriptsByAgentIDs :many -SELECT workspace_agent_id, log_source_id, log_path, created_at, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds FROM workspace_agent_scripts WHERE workspace_agent_id = ANY($1 :: uuid [ ]) -` - -func (q *sqlQuerier) GetWorkspaceAgentScriptsByAgentIDs(ctx context.Context, ids []uuid.UUID) ([]WorkspaceAgentScript, error) { - rows, err := q.db.QueryContext(ctx, getWorkspaceAgentScriptsByAgentIDs, pq.Array(ids)) - if err != nil { - return nil, err - } - defer rows.Close() - var items []WorkspaceAgentScript - for rows.Next() { - var i WorkspaceAgentScript - if err := rows.Scan( - &i.WorkspaceAgentID, - &i.LogSourceID, - &i.LogPath, - &i.CreatedAt, - &i.Script, - &i.Cron, - &i.StartBlocksLogin, - &i.RunOnStart, - &i.RunOnStop, - &i.TimeoutSeconds, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const insertWorkspaceAgentScripts = `-- name: InsertWorkspaceAgentScripts :many -INSERT INTO - workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds) -SELECT - $1 :: uuid AS workspace_agent_id, - $2 :: timestamptz AS created_at, - unnest($3 :: uuid [ ]) AS log_source_id, - unnest($4 :: text [ ]) AS log_path, - unnest($5 :: text [ ]) AS script, - unnest($6 :: text [ ]) AS cron, - unnest($7 :: boolean [ ]) AS start_blocks_login, - unnest($8 :: boolean [ ]) AS run_on_start, - unnest($9 :: boolean [ ]) AS run_on_stop, - unnest($10 :: integer [ ]) AS timeout_seconds -RETURNING workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds -` - -type InsertWorkspaceAgentScriptsParams struct { - WorkspaceAgentID uuid.UUID `db:"workspace_agent_id" json:"workspace_agent_id"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - LogSourceID []uuid.UUID `db:"log_source_id" json:"log_source_id"` - LogPath []string `db:"log_path" json:"log_path"` - Script []string `db:"script" json:"script"` - Cron []string `db:"cron" json:"cron"` - StartBlocksLogin []bool `db:"start_blocks_login" json:"start_blocks_login"` - RunOnStart []bool `db:"run_on_start" json:"run_on_start"` - RunOnStop []bool `db:"run_on_stop" json:"run_on_stop"` - TimeoutSeconds []int32 `db:"timeout_seconds" json:"timeout_seconds"` -} - -func (q *sqlQuerier) InsertWorkspaceAgentScripts(ctx context.Context, arg InsertWorkspaceAgentScriptsParams) ([]WorkspaceAgentScript, error) { - rows, err := q.db.QueryContext(ctx, insertWorkspaceAgentScripts, - arg.WorkspaceAgentID, - arg.CreatedAt, - pq.Array(arg.LogSourceID), - pq.Array(arg.LogPath), - pq.Array(arg.Script), - pq.Array(arg.Cron), - pq.Array(arg.StartBlocksLogin), - pq.Array(arg.RunOnStart), - pq.Array(arg.RunOnStop), - pq.Array(arg.TimeoutSeconds), - ) - if err != nil { - return nil, err - } - defer rows.Close() - var items []WorkspaceAgentScript - for rows.Next() { - var i WorkspaceAgentScript - if err := rows.Scan( - &i.WorkspaceAgentID, - &i.LogSourceID, - &i.LogPath, - &i.CreatedAt, - &i.Script, - &i.Cron, - &i.StartBlocksLogin, - &i.RunOnStart, - &i.RunOnStop, - &i.TimeoutSeconds, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} diff --git a/coderd/database/queries/gitauth.sql b/coderd/database/queries/externalauth.sql similarity index 60% rename from coderd/database/queries/gitauth.sql rename to coderd/database/queries/externalauth.sql index b2ce97dae1404..12a791d8c1cfb 100644 --- a/coderd/database/queries/gitauth.sql +++ b/coderd/database/queries/externalauth.sql @@ -1,11 +1,11 @@ --- name: GetGitAuthLink :one -SELECT * FROM git_auth_links WHERE provider_id = $1 AND user_id = $2; +-- name: GetExternalAuthLink :one +SELECT * FROM external_auth_links WHERE provider_id = $1 AND user_id = $2; --- name: GetGitAuthLinksByUserID :many -SELECT * FROM git_auth_links WHERE user_id = $1; +-- name: GetExternalAuthLinksByUserID :many +SELECT * FROM external_auth_links WHERE user_id = $1; --- name: InsertGitAuthLink :one -INSERT INTO git_auth_links ( +-- name: InsertExternalAuthLink :one +INSERT INTO external_auth_links ( provider_id, user_id, created_at, @@ -27,8 +27,8 @@ INSERT INTO git_auth_links ( $9 ) RETURNING *; --- name: UpdateGitAuthLink :one -UPDATE git_auth_links SET +-- name: UpdateExternalAuthLink :one +UPDATE external_auth_links SET updated_at = $3, oauth_access_token = $4, oauth_access_token_key_id = $5, diff --git a/coderd/database/queries/templateversions.sql b/coderd/database/queries/templateversions.sql index b1f83d8e91c8b..db30b8cb17e84 100644 --- a/coderd/database/queries/templateversions.sql +++ b/coderd/database/queries/templateversions.sql @@ -105,11 +105,11 @@ SET WHERE job_id = $1; --- name: UpdateTemplateVersionGitAuthProvidersByJobID :exec +-- name: UpdateTemplateVersionExternalAuthProvidersByJobID :exec UPDATE template_versions SET - git_auth_providers = $2, + external_auth_providers = $2, updated_at = $3 WHERE job_id = $1; diff --git a/coderd/database/unique_constraint.go b/coderd/database/unique_constraint.go index 5be23df0d8bcf..0087da609aa2c 100644 --- a/coderd/database/unique_constraint.go +++ b/coderd/database/unique_constraint.go @@ -14,7 +14,7 @@ const ( UniqueDbcryptKeysRevokedKeyDigestKey UniqueConstraint = "dbcrypt_keys_revoked_key_digest_key" // ALTER TABLE ONLY dbcrypt_keys ADD CONSTRAINT dbcrypt_keys_revoked_key_digest_key UNIQUE (revoked_key_digest); UniqueFilesHashCreatedByKey UniqueConstraint = "files_hash_created_by_key" // ALTER TABLE ONLY files ADD CONSTRAINT files_hash_created_by_key UNIQUE (hash, created_by); UniqueFilesPkey UniqueConstraint = "files_pkey" // ALTER TABLE ONLY files ADD CONSTRAINT files_pkey PRIMARY KEY (id); - UniqueGitAuthLinksProviderIDUserIDKey UniqueConstraint = "git_auth_links_provider_id_user_id_key" // ALTER TABLE ONLY git_auth_links ADD CONSTRAINT git_auth_links_provider_id_user_id_key UNIQUE (provider_id, user_id); + UniqueGitAuthLinksProviderIDUserIDKey UniqueConstraint = "git_auth_links_provider_id_user_id_key" // ALTER TABLE ONLY external_auth_links ADD CONSTRAINT git_auth_links_provider_id_user_id_key UNIQUE (provider_id, user_id); UniqueGitSSHKeysPkey UniqueConstraint = "gitsshkeys_pkey" // ALTER TABLE ONLY gitsshkeys ADD CONSTRAINT gitsshkeys_pkey PRIMARY KEY (user_id); UniqueGroupMembersUserIDGroupIDKey UniqueConstraint = "group_members_user_id_group_id_key" // ALTER TABLE ONLY group_members ADD CONSTRAINT group_members_user_id_group_id_key UNIQUE (user_id, group_id); UniqueGroupsNameOrganizationIDKey UniqueConstraint = "groups_name_organization_id_key" // ALTER TABLE ONLY groups ADD CONSTRAINT groups_name_organization_id_key UNIQUE (name, organization_id); diff --git a/coderd/gitauth.go b/coderd/gitauth.go index 729ec037e70d1..ac4f175e66cd8 100644 --- a/coderd/gitauth.go +++ b/coderd/gitauth.go @@ -32,12 +32,12 @@ func (api *API) gitAuthByID(w http.ResponseWriter, r *http.Request) { res := codersdk.GitAuth{ Authenticated: false, Device: config.DeviceAuth != nil, - AppInstallURL: config.AppInstallURL, + AppInstallURL: config.GitAppInstallURL, Type: config.Type.Pretty(), AppInstallations: []codersdk.GitAuthAppInstallation{}, } - link, err := api.Database.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + link, err := api.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: config.ID, UserID: apiKey.UserID, }) @@ -109,7 +109,7 @@ func (api *API) postGitAuthDeviceByID(rw http.ResponseWriter, r *http.Request) { return } - _, err = api.Database.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + _, err = api.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: config.ID, UserID: apiKey.UserID, }) @@ -122,7 +122,7 @@ func (api *API) postGitAuthDeviceByID(rw http.ResponseWriter, r *http.Request) { return } - _, err = api.Database.InsertGitAuthLink(ctx, database.InsertGitAuthLinkParams{ + _, err = api.Database.InsertExternalAuthLink(ctx, database.InsertExternalAuthLinkParams{ ProviderID: config.ID, UserID: apiKey.UserID, CreatedAt: dbtime.Now(), @@ -139,7 +139,7 @@ func (api *API) postGitAuthDeviceByID(rw http.ResponseWriter, r *http.Request) { return } } else { - _, err = api.Database.UpdateGitAuthLink(ctx, database.UpdateGitAuthLinkParams{ + _, err = api.Database.UpdateExternalAuthLink(ctx, database.UpdateExternalAuthLinkParams{ ProviderID: config.ID, UserID: apiKey.UserID, UpdatedAt: dbtime.Now(), @@ -197,7 +197,7 @@ func (api *API) gitAuthCallback(gitAuthConfig *gitauth.Config) http.HandlerFunc apiKey = httpmw.APIKey(r) ) - _, err := api.Database.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + _, err := api.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: gitAuthConfig.ID, UserID: apiKey.UserID, }) @@ -210,7 +210,7 @@ func (api *API) gitAuthCallback(gitAuthConfig *gitauth.Config) http.HandlerFunc return } - _, err = api.Database.InsertGitAuthLink(ctx, database.InsertGitAuthLinkParams{ + _, err = api.Database.InsertExternalAuthLink(ctx, database.InsertExternalAuthLinkParams{ ProviderID: gitAuthConfig.ID, UserID: apiKey.UserID, CreatedAt: dbtime.Now(), @@ -227,7 +227,7 @@ func (api *API) gitAuthCallback(gitAuthConfig *gitauth.Config) http.HandlerFunc return } } else { - _, err = api.Database.UpdateGitAuthLink(ctx, database.UpdateGitAuthLinkParams{ + _, err = api.Database.UpdateExternalAuthLink(ctx, database.UpdateExternalAuthLinkParams{ ProviderID: gitAuthConfig.ID, UserID: apiKey.UserID, UpdatedAt: dbtime.Now(), diff --git a/coderd/gitauth/config.go b/coderd/gitauth/config.go index f5810f733181d..5d444abec10a2 100644 --- a/coderd/gitauth/config.go +++ b/coderd/gitauth/config.go @@ -33,10 +33,11 @@ type Config struct { OAuth2Config // ID is a unique identifier for the authenticator. ID string - // Regex is a regexp that URLs will match against. - Regex *regexp.Regexp // Type is the type of provider. - Type codersdk.GitProvider + Type codersdk.ExternalAuthProvider + // DeviceAuth is set if the provider uses the device flow. + DeviceAuth *DeviceAuth + // NoRefresh stops Coder from using the refresh token // to renew the access token. // @@ -47,21 +48,24 @@ type Config struct { // returning it to the user. If omitted, tokens will // not be validated before being returned. ValidateURL string - // AppInstallURL is for GitHub App's (and hopefully others eventually) + + // GitCloneRegex is a Regexp matched against URLs for + // a Git clone. e.g. "Username for 'https://github.com':" + // The regex would be `github\.com`.. + GitCloneRegex *regexp.Regexp + // GitAppInstallURL is for GitHub App's (and hopefully others eventually) // to provide a link to install the app. There's installation // of the application, and user authentication. It's possible // for the user to authenticate but the application to not. - AppInstallURL string + GitAppInstallURL string // InstallationsURL is an API endpoint that returns a list of // installations for the user. This is used for GitHub Apps. - AppInstallationsURL string - // DeviceAuth is set if the provider uses the device flow. - DeviceAuth *DeviceAuth + GitAppInstallationsURL string } // RefreshToken automatically refreshes the token if expired and permitted. // It returns the token and a bool indicating if the token is valid. -func (c *Config) RefreshToken(ctx context.Context, db database.Store, gitAuthLink database.GitAuthLink) (database.GitAuthLink, bool, error) { +func (c *Config) RefreshToken(ctx context.Context, db database.Store, gitAuthLink database.ExternalAuthLink) (database.ExternalAuthLink, bool, error) { // If the token is expired and refresh is disabled, we prompt // the user to authenticate again. if c.NoRefresh && @@ -108,7 +112,7 @@ validate: // to the read replica in time. // // We do an exponential backoff here to give the write time to propagate. - if c.Type == codersdk.GitProviderGitHub && r.Wait(retryCtx) { + if c.Type == codersdk.ExternalAuthProviderGitHub && r.Wait(retryCtx) { goto validate } // The token is no longer valid! @@ -117,7 +121,7 @@ validate: if token.AccessToken != gitAuthLink.OAuthAccessToken { // Update it - gitAuthLink, err = db.UpdateGitAuthLink(ctx, database.UpdateGitAuthLinkParams{ + gitAuthLink, err = db.UpdateExternalAuthLink(ctx, database.UpdateExternalAuthLinkParams{ ProviderID: c.ID, UserID: gitAuthLink.UserID, UpdatedAt: dbtime.Now(), @@ -164,7 +168,7 @@ func (c *Config) ValidateToken(ctx context.Context, token string) (bool, *coders } var user *codersdk.GitAuthUser - if c.Type == codersdk.GitProviderGitHub { + if c.Type == codersdk.ExternalAuthProviderGitHub { var ghUser github.User err = json.NewDecoder(res.Body).Decode(&ghUser) if err == nil { @@ -191,10 +195,10 @@ type AppInstallation struct { // AppInstallations returns a list of app installations for the given token. // If the provider does not support app installations, it returns nil. func (c *Config) AppInstallations(ctx context.Context, token string) ([]codersdk.GitAuthAppInstallation, bool, error) { - if c.AppInstallationsURL == "" { + if c.GitAppInstallationsURL == "" { return nil, false, nil } - req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.AppInstallationsURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.GitAppInstallationsURL, nil) if err != nil { return nil, false, err } @@ -210,7 +214,7 @@ func (c *Config) AppInstallations(ctx context.Context, token string) ([]codersdk return nil, false, nil } installs := []codersdk.GitAuthAppInstallation{} - if c.Type == codersdk.GitProviderGitHub { + if c.Type == codersdk.ExternalAuthProviderGitHub { var ghInstalls struct { Installations []*github.Installation `json:"installations"` } @@ -244,16 +248,16 @@ func ConvertConfig(entries []codersdk.GitAuthConfig, accessURL *url.URL) ([]*Con ids := map[string]struct{}{} configs := []*Config{} for _, entry := range entries { - var typ codersdk.GitProvider - switch codersdk.GitProvider(entry.Type) { - case codersdk.GitProviderAzureDevops: - typ = codersdk.GitProviderAzureDevops - case codersdk.GitProviderBitBucket: - typ = codersdk.GitProviderBitBucket - case codersdk.GitProviderGitHub: - typ = codersdk.GitProviderGitHub - case codersdk.GitProviderGitLab: - typ = codersdk.GitProviderGitLab + var typ codersdk.ExternalAuthProvider + switch codersdk.ExternalAuthProvider(entry.Type) { + case codersdk.ExternalAuthProviderAzureDevops: + typ = codersdk.ExternalAuthProviderAzureDevops + case codersdk.ExternalAuthProviderBitBucket: + typ = codersdk.ExternalAuthProviderBitBucket + case codersdk.ExternalAuthProviderGitHub: + typ = codersdk.ExternalAuthProviderGitHub + case codersdk.ExternalAuthProviderGitLab: + typ = codersdk.ExternalAuthProviderGitLab default: return nil, xerrors.Errorf("unknown git provider type: %q", entry.Type) } @@ -315,19 +319,19 @@ func ConvertConfig(entries []codersdk.GitAuthConfig, accessURL *url.URL) ([]*Con var oauthConfig OAuth2Config = oc // Azure DevOps uses JWT token authentication! - if typ == codersdk.GitProviderAzureDevops { + if typ == codersdk.ExternalAuthProviderAzureDevops { oauthConfig = &jwtConfig{oc} } cfg := &Config{ - OAuth2Config: oauthConfig, - ID: entry.ID, - Regex: regex, - Type: typ, - NoRefresh: entry.NoRefresh, - ValidateURL: entry.ValidateURL, - AppInstallationsURL: entry.AppInstallationsURL, - AppInstallURL: entry.AppInstallURL, + OAuth2Config: oauthConfig, + ID: entry.ID, + GitCloneRegex: regex, + Type: typ, + NoRefresh: entry.NoRefresh, + ValidateURL: entry.ValidateURL, + GitAppInstallationsURL: entry.AppInstallationsURL, + GitAppInstallURL: entry.AppInstallURL, } if entry.DeviceFlow { diff --git a/coderd/gitauth/config_test.go b/coderd/gitauth/config_test.go index f6c97a440e3cb..3fecc561afd91 100644 --- a/coderd/gitauth/config_test.go +++ b/coderd/gitauth/config_test.go @@ -99,7 +99,7 @@ func TestRefreshToken(t *testing.T) { }, }, } - _, refreshed, err := config.RefreshToken(context.Background(), nil, database.GitAuthLink{ + _, refreshed, err := config.RefreshToken(context.Background(), nil, database.ExternalAuthLink{ OAuthExpiry: expired, }) require.NoError(t, err) @@ -177,7 +177,7 @@ func TestRefreshToken(t *testing.T) { }), }, GitConfigOpt: func(cfg *gitauth.Config) { - cfg.Type = codersdk.GitProviderGitHub + cfg.Type = codersdk.ExternalAuthProviderGitHub }, }) @@ -207,7 +207,7 @@ func TestRefreshToken(t *testing.T) { }), }, GitConfigOpt: func(cfg *gitauth.Config) { - cfg.Type = codersdk.GitProviderGitHub + cfg.Type = codersdk.ExternalAuthProviderGitHub }, }) @@ -238,7 +238,7 @@ func TestRefreshToken(t *testing.T) { }), }, GitConfigOpt: func(cfg *gitauth.Config) { - cfg.Type = codersdk.GitProviderGitHub + cfg.Type = codersdk.ExternalAuthProviderGitHub }, DB: db, }) @@ -254,7 +254,7 @@ func TestRefreshToken(t *testing.T) { require.Equal(t, 1, refreshCalls, "token is refreshed") require.NotEqualf(t, link.OAuthAccessToken, updated.OAuthAccessToken, "token is updated") //nolint:gocritic // testing - dbLink, err := db.GetGitAuthLink(dbauthz.AsSystemRestricted(context.Background()), database.GetGitAuthLinkParams{ + dbLink, err := db.GetExternalAuthLink(dbauthz.AsSystemRestricted(context.Background()), database.GetExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, }) @@ -279,30 +279,30 @@ func TestConvertYAML(t *testing.T) { }, { Name: "InvalidID", Input: []codersdk.GitAuthConfig{{ - Type: string(codersdk.GitProviderGitHub), + Type: string(codersdk.ExternalAuthProviderGitHub), ID: "$hi$", }}, Error: "doesn't have a valid id", }, { Name: "NoClientID", Input: []codersdk.GitAuthConfig{{ - Type: string(codersdk.GitProviderGitHub), + Type: string(codersdk.ExternalAuthProviderGitHub), }}, Error: "client_id must be provided", }, { Name: "DuplicateType", Input: []codersdk.GitAuthConfig{{ - Type: string(codersdk.GitProviderGitHub), + Type: string(codersdk.ExternalAuthProviderGitHub), ClientID: "example", ClientSecret: "example", }, { - Type: string(codersdk.GitProviderGitHub), + Type: string(codersdk.ExternalAuthProviderGitHub), }}, Error: "multiple github git auth providers provided", }, { Name: "InvalidRegex", Input: []codersdk.GitAuthConfig{{ - Type: string(codersdk.GitProviderGitHub), + Type: string(codersdk.ExternalAuthProviderGitHub), ClientID: "example", ClientSecret: "example", Regex: `\K`, @@ -311,7 +311,7 @@ func TestConvertYAML(t *testing.T) { }, { Name: "NoDeviceURL", Input: []codersdk.GitAuthConfig{{ - Type: string(codersdk.GitProviderGitLab), + Type: string(codersdk.ExternalAuthProviderGitLab), ClientID: "example", ClientSecret: "example", DeviceFlow: true, @@ -334,7 +334,7 @@ func TestConvertYAML(t *testing.T) { t.Run("CustomScopesAndEndpoint", func(t *testing.T) { t.Parallel() config, err := gitauth.ConvertConfig([]codersdk.GitAuthConfig{{ - Type: string(codersdk.GitProviderGitLab), + Type: string(codersdk.ExternalAuthProviderGitLab), ClientID: "id", ClientSecret: "secret", AuthURL: "https://auth.com", @@ -359,7 +359,7 @@ type testConfig struct { // No http servers are started so use the fake IDP's HTTPClient to make requests. // The returned token is a fully valid token for the IDP. Feel free to manipulate it // to test different scenarios. -func setupOauth2Test(t *testing.T, settings testConfig) (*oidctest.FakeIDP, *gitauth.Config, database.GitAuthLink) { +func setupOauth2Test(t *testing.T, settings testConfig) (*oidctest.FakeIDP, *gitauth.Config, database.ExternalAuthLink) { t.Helper() const providerID = "test-idp" @@ -380,7 +380,7 @@ func setupOauth2Test(t *testing.T, settings testConfig) (*oidctest.FakeIDP, *git require.NoError(t, err) now := time.Now() - link := database.GitAuthLink{ + link := database.ExternalAuthLink{ ProviderID: providerID, UserID: uuid.New(), CreatedAt: now, @@ -393,7 +393,7 @@ func setupOauth2Test(t *testing.T, settings testConfig) (*oidctest.FakeIDP, *git if settings.DB != nil { // Feel free to insert additional things like the user, etc if required. - link, err = settings.DB.InsertGitAuthLink(context.Background(), database.InsertGitAuthLinkParams{ + link, err = settings.DB.InsertExternalAuthLink(context.Background(), database.InsertExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, CreatedAt: link.CreatedAt, diff --git a/coderd/gitauth/oauth.go b/coderd/gitauth/oauth.go index 0b2415854fa18..24b0416d203f1 100644 --- a/coderd/gitauth/oauth.go +++ b/coderd/gitauth/oauth.go @@ -17,53 +17,53 @@ import ( ) // endpoint contains default SaaS URLs for each Git provider. -var endpoint = map[codersdk.GitProvider]oauth2.Endpoint{ - codersdk.GitProviderAzureDevops: { +var endpoint = map[codersdk.ExternalAuthProvider]oauth2.Endpoint{ + codersdk.ExternalAuthProviderAzureDevops: { AuthURL: "https://app.vssps.visualstudio.com/oauth2/authorize", TokenURL: "https://app.vssps.visualstudio.com/oauth2/token", }, - codersdk.GitProviderBitBucket: { + codersdk.ExternalAuthProviderBitBucket: { AuthURL: "https://bitbucket.org/site/oauth2/authorize", TokenURL: "https://bitbucket.org/site/oauth2/access_token", }, - codersdk.GitProviderGitLab: { + codersdk.ExternalAuthProviderGitLab: { AuthURL: "https://gitlab.com/oauth/authorize", TokenURL: "https://gitlab.com/oauth/token", }, - codersdk.GitProviderGitHub: github.Endpoint, + codersdk.ExternalAuthProviderGitHub: github.Endpoint, } // validateURL contains defaults for each provider. -var validateURL = map[codersdk.GitProvider]string{ - codersdk.GitProviderGitHub: "https://api.github.com/user", - codersdk.GitProviderGitLab: "https://gitlab.com/oauth/token/info", - codersdk.GitProviderBitBucket: "https://api.bitbucket.org/2.0/user", +var validateURL = map[codersdk.ExternalAuthProvider]string{ + codersdk.ExternalAuthProviderGitHub: "https://api.github.com/user", + codersdk.ExternalAuthProviderGitLab: "https://gitlab.com/oauth/token/info", + codersdk.ExternalAuthProviderBitBucket: "https://api.bitbucket.org/2.0/user", } -var deviceAuthURL = map[codersdk.GitProvider]string{ - codersdk.GitProviderGitHub: "https://github.com/login/device/code", +var deviceAuthURL = map[codersdk.ExternalAuthProvider]string{ + codersdk.ExternalAuthProviderGitHub: "https://github.com/login/device/code", } -var appInstallationsURL = map[codersdk.GitProvider]string{ - codersdk.GitProviderGitHub: "https://api.github.com/user/installations", +var appInstallationsURL = map[codersdk.ExternalAuthProvider]string{ + codersdk.ExternalAuthProviderGitHub: "https://api.github.com/user/installations", } // scope contains defaults for each Git provider. -var scope = map[codersdk.GitProvider][]string{ - codersdk.GitProviderAzureDevops: {"vso.code_write"}, - codersdk.GitProviderBitBucket: {"account", "repository:write"}, - codersdk.GitProviderGitLab: {"write_repository"}, +var scope = map[codersdk.ExternalAuthProvider][]string{ + codersdk.ExternalAuthProviderAzureDevops: {"vso.code_write"}, + codersdk.ExternalAuthProviderBitBucket: {"account", "repository:write"}, + codersdk.ExternalAuthProviderGitLab: {"write_repository"}, // "workflow" is required for managing GitHub Actions in a repository. - codersdk.GitProviderGitHub: {"repo", "workflow"}, + codersdk.ExternalAuthProviderGitHub: {"repo", "workflow"}, } // regex provides defaults for each Git provider to match their SaaS host URL. // This is configurable by each provider. -var regex = map[codersdk.GitProvider]*regexp.Regexp{ - codersdk.GitProviderAzureDevops: regexp.MustCompile(`^(https?://)?dev\.azure\.com(/.*)?$`), - codersdk.GitProviderBitBucket: regexp.MustCompile(`^(https?://)?bitbucket\.org(/.*)?$`), - codersdk.GitProviderGitLab: regexp.MustCompile(`^(https?://)?gitlab\.com(/.*)?$`), - codersdk.GitProviderGitHub: regexp.MustCompile(`^(https?://)?github\.com(/.*)?$`), +var regex = map[codersdk.ExternalAuthProvider]*regexp.Regexp{ + codersdk.ExternalAuthProviderAzureDevops: regexp.MustCompile(`^(https?://)?dev\.azure\.com(/.*)?$`), + codersdk.ExternalAuthProviderBitBucket: regexp.MustCompile(`^(https?://)?bitbucket\.org(/.*)?$`), + codersdk.ExternalAuthProviderGitLab: regexp.MustCompile(`^(https?://)?gitlab\.com(/.*)?$`), + codersdk.ExternalAuthProviderGitHub: regexp.MustCompile(`^(https?://)?github\.com(/.*)?$`), } // jwtConfig is a new OAuth2 config that uses a custom diff --git a/coderd/gitauth_test.go b/coderd/gitauth_test.go index 5c5850c0e7fea..d6153a56e8bb0 100644 --- a/coderd/gitauth_test.go +++ b/coderd/gitauth_test.go @@ -34,7 +34,7 @@ func TestGitAuthByID(t *testing.T) { GitAuthConfigs: []*gitauth.Config{{ ID: "test", OAuth2Config: &testutil.OAuth2Config{}, - Type: codersdk.GitProviderGitHub, + Type: codersdk.ExternalAuthProviderGitHub, }}, }) coderdtest.CreateFirstUser(t, client) @@ -51,7 +51,7 @@ func TestGitAuthByID(t *testing.T) { ID: "test", OAuth2Config: &testutil.OAuth2Config{}, // AzureDevops doesn't have a user endpoint! - Type: codersdk.GitProviderAzureDevops, + Type: codersdk.ExternalAuthProviderAzureDevops, }}, }) coderdtest.CreateFirstUser(t, client) @@ -75,7 +75,7 @@ func TestGitAuthByID(t *testing.T) { ID: "test", ValidateURL: validateSrv.URL, OAuth2Config: &testutil.OAuth2Config{}, - Type: codersdk.GitProviderGitHub, + Type: codersdk.ExternalAuthProviderGitHub, }}, }) coderdtest.CreateFirstUser(t, client) @@ -112,11 +112,11 @@ func TestGitAuthByID(t *testing.T) { defer srv.Close() client := coderdtest.New(t, &coderdtest.Options{ GitAuthConfigs: []*gitauth.Config{{ - ID: "test", - ValidateURL: srv.URL + "/user", - AppInstallationsURL: srv.URL + "/installs", - OAuth2Config: &testutil.OAuth2Config{}, - Type: codersdk.GitProviderGitHub, + ID: "test", + ValidateURL: srv.URL + "/user", + GitAppInstallationsURL: srv.URL + "/installs", + OAuth2Config: &testutil.OAuth2Config{}, + Type: codersdk.ExternalAuthProviderGitHub, }}, }) coderdtest.CreateFirstUser(t, client) @@ -246,10 +246,10 @@ func TestGitAuthCallback(t *testing.T) { client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) @@ -275,10 +275,10 @@ func TestGitAuthCallback(t *testing.T) { client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) resp := coderdtest.RequestGitAuthCallback(t, "github", client) @@ -289,10 +289,10 @@ func TestGitAuthCallback(t *testing.T) { client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) _ = coderdtest.CreateFirstUser(t, client) @@ -315,11 +315,11 @@ func TestGitAuthCallback(t *testing.T) { client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, GitAuthConfigs: []*gitauth.Config{{ - ValidateURL: srv.URL, - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, + ValidateURL: srv.URL, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) @@ -374,10 +374,10 @@ func TestGitAuthCallback(t *testing.T) { Expiry: dbtime.Now().Add(-time.Hour), }, }, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, - NoRefresh: true, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, + NoRefresh: true, }}, }) user := coderdtest.CreateFirstUser(t, client) @@ -417,10 +417,10 @@ func TestGitAuthCallback(t *testing.T) { client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) diff --git a/coderd/provisionerdserver/provisionerdserver.go b/coderd/provisionerdserver/provisionerdserver.go index 0d5768cbbdb6f..914680fb536dc 100644 --- a/coderd/provisionerdserver/provisionerdserver.go +++ b/coderd/provisionerdserver/provisionerdserver.go @@ -406,7 +406,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo gitAuthProviders := []*sdkproto.GitAuthProvider{} for _, p := range templateVersion.GitAuthProviders { - link, err := s.Database.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + link, err := s.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: p, UserID: owner.ID, }) @@ -1045,10 +1045,10 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) } } - err = s.Database.UpdateTemplateVersionGitAuthProvidersByJobID(ctx, database.UpdateTemplateVersionGitAuthProvidersByJobIDParams{ - JobID: jobID, - GitAuthProviders: jobType.TemplateImport.GitAuthProviders, - UpdatedAt: dbtime.Now(), + err = s.Database.UpdateTemplateVersionExternalAuthProvidersByJobID(ctx, database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams{ + JobID: jobID, + ExternalAuthProviders: jobType.TemplateImport.GitAuthProviders, + UpdatedAt: dbtime.Now(), }) if err != nil { return nil, xerrors.Errorf("update template version git auth providers: %w", err) diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 82f9855cf90d5..896adab98c9c9 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -158,7 +158,7 @@ func TestAcquireJob(t *testing.T) { OAuthExpiry: dbtime.Now().Add(time.Hour), OAuthAccessToken: "access-token", }) - dbgen.GitAuthLink(t, db, database.GitAuthLink{ + dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ ProviderID: gitAuthProvider, UserID: user.ID, }) @@ -175,7 +175,7 @@ func TestAcquireJob(t *testing.T) { }, JobID: uuid.New(), }) - err := db.UpdateTemplateVersionGitAuthProvidersByJobID(ctx, database.UpdateTemplateVersionGitAuthProvidersByJobIDParams{ + err := db.UpdateTemplateVersionExternalAuthProvidersByJobID(ctx, database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams{ JobID: version.JobID, GitAuthProviders: []string{gitAuthProvider}, UpdatedAt: dbtime.Now(), diff --git a/coderd/templateversions.go b/coderd/templateversions.go index 364c80814bde6..e333a9d6ef6d1 100644 --- a/coderd/templateversions.go +++ b/coderd/templateversions.go @@ -279,7 +279,7 @@ func (api *API) templateVersionRichParameters(rw http.ResponseWriter, r *http.Re // @Produce json // @Tags Templates // @Param templateversion path string true "Template version ID" format(uuid) -// @Success 200 {array} codersdk.TemplateVersionGitAuth +// @Success 200 {array} codersdk.TemplateVersionExternalAuth // @Router /templateversions/{templateversion}/gitauth [get] func (api *API) templateVersionGitAuth(rw http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -289,7 +289,7 @@ func (api *API) templateVersionGitAuth(rw http.ResponseWriter, r *http.Request) ) rawProviders := templateVersion.GitAuthProviders - providers := make([]codersdk.TemplateVersionGitAuth, 0) + providers := make([]codersdk.TemplateVersionExternalAuth, 0) for _, rawProvider := range rawProviders { var config *gitauth.Config for _, provider := range api.GitAuthConfigs { @@ -316,13 +316,13 @@ func (api *API) templateVersionGitAuth(rw http.ResponseWriter, r *http.Request) return } - provider := codersdk.TemplateVersionGitAuth{ + provider := codersdk.TemplateVersionExternalAuth{ ID: config.ID, Type: config.Type, AuthenticateURL: redirectURL.String(), } - authLink, err := api.Database.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + authLink, err := api.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: config.ID, UserID: apiKey.UserID, }) diff --git a/coderd/templateversions_test.go b/coderd/templateversions_test.go index 2ca934e2d4085..6c0c39a3932a0 100644 --- a/coderd/templateversions_test.go +++ b/coderd/templateversions_test.go @@ -331,7 +331,7 @@ func TestTemplateVersionsGitAuth(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) defer cancel() - _, err := client.TemplateVersionGitAuth(ctx, version.ID) + _, err := client.TemplateVersionExternalAuth(ctx, version.ID) require.NoError(t, err) }) t.Run("Authenticated", func(t *testing.T) { @@ -339,10 +339,10 @@ func TestTemplateVersionsGitAuth(t *testing.T) { client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - Regex: regexp.MustCompile(`github\.com`), - Type: codersdk.GitProviderGitHub, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + GitCloneRegex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) @@ -362,7 +362,7 @@ func TestTemplateVersionsGitAuth(t *testing.T) { defer cancel() // Not authenticated to start! - providers, err := client.TemplateVersionGitAuth(ctx, version.ID) + providers, err := client.TemplateVersionExternalAuth(ctx, version.ID) require.NoError(t, err) require.Len(t, providers, 1) require.False(t, providers[0].Authenticated) @@ -373,7 +373,7 @@ func TestTemplateVersionsGitAuth(t *testing.T) { require.Equal(t, http.StatusTemporaryRedirect, resp.StatusCode) // Ensure that the returned Git auth for the template is authenticated! - providers, err = client.TemplateVersionGitAuth(ctx, version.ID) + providers, err = client.TemplateVersionExternalAuth(ctx, version.ID) require.NoError(t, err) require.Len(t, providers, 1) require.True(t, providers[0].Authenticated) diff --git a/coderd/workspaceagents.go b/coderd/workspaceagents.go index 52fa7cf8d4ab3..7f17e51df5430 100644 --- a/coderd/workspaceagents.go +++ b/coderd/workspaceagents.go @@ -2180,7 +2180,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) var gitAuthConfig *gitauth.Config for _, gitAuth := range api.GitAuthConfigs { - matches := gitAuth.Regex.MatchString(gitURL) + matches := gitAuth.GitCloneRegex.MatchString(gitURL) if !matches { continue } @@ -2191,7 +2191,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) if len(api.GitAuthConfigs) > 0 { regexURLs := make([]string, 0, len(api.GitAuthConfigs)) for _, gitAuth := range api.GitAuthConfigs { - regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", gitAuth.ID, gitAuth.Regex.String())) + regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", gitAuth.ID, gitAuth.GitCloneRegex.String())) } detail = fmt.Sprintf("The configured git provider have regex filters that do not match the git url. Provider url regexs: %s", strings.Join(regexURLs, ",")) } @@ -2239,7 +2239,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) return case <-ticker.C: } - gitAuthLink, err := api.Database.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + gitAuthLink, err := api.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: gitAuthConfig.ID, UserID: workspace.OwnerID, }) @@ -2287,7 +2287,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) return } - gitAuthLink, err := api.Database.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + gitAuthLink, err := api.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: gitAuthConfig.ID, UserID: workspace.OwnerID, }) @@ -2324,16 +2324,16 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) } // Provider types have different username/password formats. -func formatGitAuthAccessToken(typ codersdk.GitProvider, token string) agentsdk.GitAuthResponse { +func formatGitAuthAccessToken(typ codersdk.ExternalAuthProvider, token string) agentsdk.GitAuthResponse { var resp agentsdk.GitAuthResponse switch typ { - case codersdk.GitProviderGitLab: + case codersdk.ExternalAuthProviderGitLab: // https://stackoverflow.com/questions/25409700/using-gitlab-token-to-clone-without-authentication resp = agentsdk.GitAuthResponse{ Username: "oauth2", Password: token, } - case codersdk.GitProviderBitBucket: + case codersdk.ExternalAuthProviderBitBucket: // https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/#Cloning-a-repository-with-an-access-token resp = agentsdk.GitAuthResponse{ Username: "x-token-auth", diff --git a/codersdk/templateversions.go b/codersdk/templateversions.go index 18f81731aa03a..fb1f0b21febf0 100644 --- a/codersdk/templateversions.go +++ b/codersdk/templateversions.go @@ -33,11 +33,11 @@ type TemplateVersion struct { Warnings []TemplateVersionWarning `json:"warnings,omitempty" enums:"DEPRECATED_PARAMETERS"` } -type TemplateVersionGitAuth struct { - ID string `json:"id"` - Type GitProvider `json:"type"` - AuthenticateURL string `json:"authenticate_url"` - Authenticated bool `json:"authenticated"` +type TemplateVersionExternalAuth struct { + ID string `json:"id"` + Type ExternalAuthProvider `json:"type"` + AuthenticateURL string `json:"authenticate_url"` + Authenticated bool `json:"authenticated"` } type ValidationMonotonicOrder string @@ -132,9 +132,9 @@ func (c *Client) TemplateVersionRichParameters(ctx context.Context, version uuid return params, json.NewDecoder(res.Body).Decode(¶ms) } -// TemplateVersionGitAuth returns git authentication for the requested template version. -func (c *Client) TemplateVersionGitAuth(ctx context.Context, version uuid.UUID) ([]TemplateVersionGitAuth, error) { - res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/gitauth", version), nil) +// TemplateVersionExternalAuth returns authentication providers for the requested template version. +func (c *Client) TemplateVersionExternalAuth(ctx context.Context, version uuid.UUID) ([]TemplateVersionExternalAuth, error) { + res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/externalauth", version), nil) if err != nil { return nil, err } @@ -142,8 +142,8 @@ func (c *Client) TemplateVersionGitAuth(ctx context.Context, version uuid.UUID) if res.StatusCode != http.StatusOK { return nil, ReadBodyAsError(res) } - var gitAuth []TemplateVersionGitAuth - return gitAuth, json.NewDecoder(res.Body).Decode(&gitAuth) + var extAuth []TemplateVersionExternalAuth + return extAuth, json.NewDecoder(res.Body).Decode(&extAuth) } // TemplateVersionResources returns resources a template version declares. diff --git a/codersdk/workspaceagents.go b/codersdk/workspaceagents.go index 367fafa087a6d..0461e3ae07c33 100644 --- a/codersdk/workspaceagents.go +++ b/codersdk/workspaceagents.go @@ -744,30 +744,33 @@ func (c *Client) WorkspaceAgentLogsAfter(ctx context.Context, agentID uuid.UUID, }), nil } -// GitProvider is a constant that represents the +// ExternalAuthProvider is a constant that represents the // type of providers that are supported within Coder. -type GitProvider string +type ExternalAuthProvider string -func (g GitProvider) Pretty() string { +func (g ExternalAuthProvider) Pretty() string { switch g { - case GitProviderAzureDevops: + case ExternalAuthProviderAzureDevops: return "Azure DevOps" - case GitProviderGitHub: + case ExternalAuthProviderGitHub: return "GitHub" - case GitProviderGitLab: + case ExternalAuthProviderGitLab: return "GitLab" - case GitProviderBitBucket: + case ExternalAuthProviderBitBucket: return "Bitbucket" + case ExternalAuthProviderOpenIDConnect: + return "OpenID Connect" default: return string(g) } } const ( - GitProviderAzureDevops GitProvider = "azure-devops" - GitProviderGitHub GitProvider = "github" - GitProviderGitLab GitProvider = "gitlab" - GitProviderBitBucket GitProvider = "bitbucket" + ExternalAuthProviderAzureDevops ExternalAuthProvider = "azure-devops" + ExternalAuthProviderGitHub ExternalAuthProvider = "github" + ExternalAuthProviderGitLab ExternalAuthProvider = "gitlab" + ExternalAuthProviderBitBucket ExternalAuthProvider = "bitbucket" + ExternalAuthProviderOpenIDConnect ExternalAuthProvider = "openid-connect" ) type WorkspaceAgentLog struct { diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 635a4ad5e8ee1..4e4a1dede69b2 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -2752,6 +2752,24 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `template_autostop_requirement` | | `deployment_health_page` | +## codersdk.ExternalAuthProvider + +```json +"azure-devops" +``` + +### Properties + +#### Enumerated Values + +| Value | +| ---------------- | +| `azure-devops` | +| `github` | +| `gitlab` | +| `bitbucket` | +| `openid-connect` | + ## codersdk.Feature ```json @@ -2965,23 +2983,6 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `name` | string | false | | | | `profile_url` | string | false | | | -## codersdk.GitProvider - -```json -"azure-devops" -``` - -### Properties - -#### Enumerated Values - -| Value | -| -------------- | -| `azure-devops` | -| `github` | -| `gitlab` | -| `bitbucket` | - ## codersdk.GitSSHKey ```json @@ -4734,7 +4735,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `updated_at` | string | false | | | | `warnings` | array of [codersdk.TemplateVersionWarning](#codersdktemplateversionwarning) | false | | | -## codersdk.TemplateVersionGitAuth +## codersdk.TemplateVersionExternalAuth ```json { @@ -4747,12 +4748,12 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ### Properties -| Name | Type | Required | Restrictions | Description | -| ------------------ | -------------------------------------------- | -------- | ------------ | ----------- | -| `authenticate_url` | string | false | | | -| `authenticated` | boolean | false | | | -| `id` | string | false | | | -| `type` | [codersdk.GitProvider](#codersdkgitprovider) | false | | | +| Name | Type | Required | Restrictions | Description | +| ------------------ | -------------------------------------------------------------- | -------- | ------------ | ----------- | +| `authenticate_url` | string | false | | | +| `authenticated` | boolean | false | | | +| `id` | string | false | | | +| `type` | [codersdk.ExternalAuthProvider](#codersdkexternalauthprovider) | false | | | ## codersdk.TemplateVersionParameter diff --git a/docs/api/templates.md b/docs/api/templates.md index 526fc193fa684..f4084144e0494 100644 --- a/docs/api/templates.md +++ b/docs/api/templates.md @@ -1836,30 +1836,31 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/g ### Responses -| Status | Meaning | Description | Schema | -| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------- | -| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.TemplateVersionGitAuth](schemas.md#codersdktemplateversiongitauth) | +| Status | Meaning | Description | Schema | +| ------ | ------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------- | +| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.TemplateVersionExternalAuth](schemas.md#codersdktemplateversionexternalauth) |

Response Schema

Status Code **200** -| Name | Type | Required | Restrictions | Description | -| -------------------- | ------------------------------------------------------ | -------- | ------------ | ----------- | -| `[array item]` | array | false | | | -| `» authenticate_url` | string | false | | | -| `» authenticated` | boolean | false | | | -| `» id` | string | false | | | -| `» type` | [codersdk.GitProvider](schemas.md#codersdkgitprovider) | false | | | +| Name | Type | Required | Restrictions | Description | +| -------------------- | ------------------------------------------------------------------------ | -------- | ------------ | ----------- | +| `[array item]` | array | false | | | +| `» authenticate_url` | string | false | | | +| `» authenticated` | boolean | false | | | +| `» id` | string | false | | | +| `» type` | [codersdk.ExternalAuthProvider](schemas.md#codersdkexternalauthprovider) | false | | | #### Enumerated Values -| Property | Value | -| -------- | -------------- | -| `type` | `azure-devops` | -| `type` | `github` | -| `type` | `gitlab` | -| `type` | `bitbucket` | +| Property | Value | +| -------- | ---------------- | +| `type` | `azure-devops` | +| `type` | `github` | +| `type` | `gitlab` | +| `type` | `bitbucket` | +| `type` | `openid-connect` | To perform this operation, you must be authenticated. [Learn more](authentication.md). diff --git a/enterprise/cli/server_dbcrypt_test.go b/enterprise/cli/server_dbcrypt_test.go index 5c8b982830903..a0ecc3e587799 100644 --- a/enterprise/cli/server_dbcrypt_test.go +++ b/enterprise/cli/server_dbcrypt_test.go @@ -195,7 +195,7 @@ func TestServerDBCrypt(t *testing.T) { userLinks, err := db.GetUserLinksByUserID(ctx, usr.ID) require.NoError(t, err, "failed to get user links for user %s", usr.ID) require.Empty(t, userLinks) - gitAuthLinks, err := db.GetGitAuthLinksByUserID(ctx, usr.ID) + gitAuthLinks, err := db.GetExternalAuthLinksByUserID(ctx, usr.ID) require.NoError(t, err, "failed to get git auth links for user %s", usr.ID) require.Empty(t, gitAuthLinks) } @@ -222,7 +222,7 @@ func genData(t *testing.T, db database.Store) []database.User { Status: status, Deleted: deleted, }) - _ = dbgen.GitAuthLink(t, db, database.GitAuthLink{ + _ = dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ UserID: usr.ID, ProviderID: "fake", OAuthAccessToken: "access-" + usr.ID.String(), @@ -277,7 +277,7 @@ func requireEncryptedWithCipher(ctx context.Context, t *testing.T, db database.S require.Equal(t, c.HexDigest(), ul.OAuthAccessTokenKeyID.String) require.Equal(t, c.HexDigest(), ul.OAuthRefreshTokenKeyID.String) } - gitAuthLinks, err := db.GetGitAuthLinksByUserID(ctx, userID) + gitAuthLinks, err := db.GetExternalAuthLinksByUserID(ctx, userID) require.NoError(t, err, "failed to get git auth links for user %s", userID) for _, gal := range gitAuthLinks { requireEncryptedEquals(t, c, "access-"+userID.String(), gal.OAuthAccessToken) diff --git a/enterprise/dbcrypt/cliutil.go b/enterprise/dbcrypt/cliutil.go index 3601d0c539c2e..98a37df5785bb 100644 --- a/enterprise/dbcrypt/cliutil.go +++ b/enterprise/dbcrypt/cliutil.go @@ -46,7 +46,7 @@ func Rotate(ctx context.Context, log slog.Logger, sqlDB *sql.DB, ciphers []Ciphe } } - gitAuthLinks, err := tx.GetGitAuthLinksByUserID(ctx, uid) + gitAuthLinks, err := tx.GetExternalAuthLinksByUserID(ctx, uid) if err != nil { return xerrors.Errorf("get git auth links for user: %w", err) } @@ -55,7 +55,7 @@ func Rotate(ctx context.Context, log slog.Logger, sqlDB *sql.DB, ciphers []Ciphe log.Debug(ctx, "skipping git auth link", slog.F("user_id", uid), slog.F("current", idx+1), slog.F("cipher", ciphers[0].HexDigest())) continue } - if _, err := tx.UpdateGitAuthLink(ctx, database.UpdateGitAuthLinkParams{ + if _, err := tx.UpdateExternalAuthLink(ctx, database.UpdateExternalAuthLinkParams{ ProviderID: gitAuthLink.ProviderID, UserID: uid, UpdatedAt: gitAuthLink.UpdatedAt, @@ -130,7 +130,7 @@ func Decrypt(ctx context.Context, log slog.Logger, sqlDB *sql.DB, ciphers []Ciph } } - gitAuthLinks, err := tx.GetGitAuthLinksByUserID(ctx, uid) + gitAuthLinks, err := tx.GetExternalAuthLinksByUserID(ctx, uid) if err != nil { return xerrors.Errorf("get git auth links for user: %w", err) } @@ -139,7 +139,7 @@ func Decrypt(ctx context.Context, log slog.Logger, sqlDB *sql.DB, ciphers []Ciph log.Debug(ctx, "skipping git auth link", slog.F("user_id", uid), slog.F("current", idx+1)) continue } - if _, err := tx.UpdateGitAuthLink(ctx, database.UpdateGitAuthLinkParams{ + if _, err := tx.UpdateExternalAuthLink(ctx, database.UpdateExternalAuthLinkParams{ ProviderID: gitAuthLink.ProviderID, UserID: uid, UpdatedAt: gitAuthLink.UpdatedAt, diff --git a/enterprise/dbcrypt/dbcrypt.go b/enterprise/dbcrypt/dbcrypt.go index b050757f594b4..ec56a4897a1e3 100644 --- a/enterprise/dbcrypt/dbcrypt.go +++ b/enterprise/dbcrypt/dbcrypt.go @@ -191,42 +191,42 @@ func (db *dbCrypt) UpdateUserLink(ctx context.Context, params database.UpdateUse return link, nil } -func (db *dbCrypt) InsertGitAuthLink(ctx context.Context, params database.InsertGitAuthLinkParams) (database.GitAuthLink, error) { +func (db *dbCrypt) InsertExternalAuthLink(ctx context.Context, params database.InsertExternalAuthLinkParams) (database.ExternalAuthLink, error) { if err := db.encryptField(¶ms.OAuthAccessToken, ¶ms.OAuthAccessTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.encryptField(¶ms.OAuthRefreshToken, ¶ms.OAuthRefreshTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } - link, err := db.Store.InsertGitAuthLink(ctx, params) + link, err := db.Store.InsertExternalAuthLink(ctx, params) if err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.decryptField(&link.OAuthAccessToken, link.OAuthAccessTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.decryptField(&link.OAuthRefreshToken, link.OAuthRefreshTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } return link, nil } -func (db *dbCrypt) GetGitAuthLink(ctx context.Context, params database.GetGitAuthLinkParams) (database.GitAuthLink, error) { - link, err := db.Store.GetGitAuthLink(ctx, params) +func (db *dbCrypt) GetExternalAuthLink(ctx context.Context, params database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { + link, err := db.Store.GetExternalAuthLink(ctx, params) if err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.decryptField(&link.OAuthAccessToken, link.OAuthAccessTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.decryptField(&link.OAuthRefreshToken, link.OAuthRefreshTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } return link, nil } -func (db *dbCrypt) GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.GitAuthLink, error) { - links, err := db.Store.GetGitAuthLinksByUserID(ctx, userID) +func (db *dbCrypt) GetExternalAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.ExternalAuthLink, error) { + links, err := db.Store.GetExternalAuthLinksByUserID(ctx, userID) if err != nil { return nil, err } @@ -241,22 +241,22 @@ func (db *dbCrypt) GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UUID return links, nil } -func (db *dbCrypt) UpdateGitAuthLink(ctx context.Context, params database.UpdateGitAuthLinkParams) (database.GitAuthLink, error) { +func (db *dbCrypt) UpdateExternalAuthLink(ctx context.Context, params database.UpdateExternalAuthLinkParams) (database.ExternalAuthLink, error) { if err := db.encryptField(¶ms.OAuthAccessToken, ¶ms.OAuthAccessTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.encryptField(¶ms.OAuthRefreshToken, ¶ms.OAuthRefreshTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } - link, err := db.Store.UpdateGitAuthLink(ctx, params) + link, err := db.Store.UpdateExternalAuthLink(ctx, params) if err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.decryptField(&link.OAuthAccessToken, link.OAuthAccessTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } if err := db.decryptField(&link.OAuthRefreshToken, link.OAuthRefreshTokenKeyID); err != nil { - return database.GitAuthLink{}, err + return database.ExternalAuthLink{}, err } return link, nil } diff --git a/enterprise/dbcrypt/dbcrypt_internal_test.go b/enterprise/dbcrypt/dbcrypt_internal_test.go index 346a4977c8cb9..adc9715265b0e 100644 --- a/enterprise/dbcrypt/dbcrypt_internal_test.go +++ b/enterprise/dbcrypt/dbcrypt_internal_test.go @@ -227,14 +227,14 @@ func TestGitAuthLinks(t *testing.T) { t.Run("InsertGitAuthLink", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, crypt, database.GitAuthLink{ + link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{ OAuthAccessToken: "access", OAuthRefreshToken: "refresh", }) require.Equal(t, "access", link.OAuthAccessToken) require.Equal(t, "refresh", link.OAuthRefreshToken) - link, err := db.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + link, err := db.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, }) @@ -246,8 +246,8 @@ func TestGitAuthLinks(t *testing.T) { t.Run("UpdateGitAuthLink", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, crypt, database.GitAuthLink{}) - updated, err := crypt.UpdateGitAuthLink(ctx, database.UpdateGitAuthLinkParams{ + link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{}) + updated, err := crypt.UpdateExternalAuthLink(ctx, database.UpdateExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, OAuthAccessToken: "access", @@ -257,7 +257,7 @@ func TestGitAuthLinks(t *testing.T) { require.Equal(t, "access", updated.OAuthAccessToken) require.Equal(t, "refresh", updated.OAuthRefreshToken) - link, err = db.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + link, err = db.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, }) @@ -270,11 +270,11 @@ func TestGitAuthLinks(t *testing.T) { t.Run("OK", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, crypt, database.GitAuthLink{ + link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{ OAuthAccessToken: "access", OAuthRefreshToken: "refresh", }) - link, err := db.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + link, err := db.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ UserID: link.UserID, ProviderID: link.ProviderID, }) @@ -285,14 +285,14 @@ func TestGitAuthLinks(t *testing.T) { t.Run("DecryptErr", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, db, database.GitAuthLink{ + link := dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ OAuthAccessToken: fakeBase64RandomData(t, 32), OAuthRefreshToken: fakeBase64RandomData(t, 32), OAuthAccessTokenKeyID: sql.NullString{String: ciphers[0].HexDigest(), Valid: true}, OAuthRefreshTokenKeyID: sql.NullString{String: ciphers[0].HexDigest(), Valid: true}, }) - _, err := crypt.GetGitAuthLink(ctx, database.GetGitAuthLinkParams{ + _, err := crypt.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ UserID: link.UserID, ProviderID: link.ProviderID, }) @@ -309,12 +309,12 @@ func TestGitAuthLinks(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) user := dbgen.User(t, crypt, database.User{}) - link := dbgen.GitAuthLink(t, crypt, database.GitAuthLink{ + link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{ UserID: user.ID, OAuthAccessToken: "access", OAuthRefreshToken: "refresh", }) - links, err := crypt.GetGitAuthLinksByUserID(ctx, link.UserID) + links, err := crypt.GetExternalAuthLinksByUserID(ctx, link.UserID) require.NoError(t, err) require.Len(t, links, 1) require.Equal(t, "access", links[0].OAuthAccessToken) @@ -322,7 +322,7 @@ func TestGitAuthLinks(t *testing.T) { require.Equal(t, ciphers[0].HexDigest(), links[0].OAuthAccessTokenKeyID.String) require.Equal(t, ciphers[0].HexDigest(), links[0].OAuthRefreshTokenKeyID.String) - rawLinks, err := db.GetGitAuthLinksByUserID(ctx, link.UserID) + rawLinks, err := db.GetExternalAuthLinksByUserID(ctx, link.UserID) require.NoError(t, err) require.Len(t, rawLinks, 1) requireEncryptedEquals(t, ciphers[0], rawLinks[0].OAuthAccessToken, "access") @@ -332,14 +332,14 @@ func TestGitAuthLinks(t *testing.T) { t.Run("DecryptErr", func(t *testing.T) { db, crypt, ciphers := setup(t) user := dbgen.User(t, db, database.User{}) - link := dbgen.GitAuthLink(t, db, database.GitAuthLink{ + link := dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ UserID: user.ID, OAuthAccessToken: fakeBase64RandomData(t, 32), OAuthRefreshToken: fakeBase64RandomData(t, 32), OAuthAccessTokenKeyID: sql.NullString{String: ciphers[0].HexDigest(), Valid: true}, OAuthRefreshTokenKeyID: sql.NullString{String: ciphers[0].HexDigest(), Valid: true}, }) - _, err := crypt.GetGitAuthLinksByUserID(ctx, link.UserID) + _, err := crypt.GetExternalAuthLinksByUserID(ctx, link.UserID) require.Error(t, err, "expected an error") var derr *DecryptFailedError require.ErrorAs(t, err, &derr, "expected a decrypt error") diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index a631dc3d79868..cd70732f8701c 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -1010,9 +1010,9 @@ export interface TemplateVersion { } // From codersdk/templateversions.go -export interface TemplateVersionGitAuth { +export interface TemplateVersionExternalAuth { readonly id: string; - readonly type: GitProvider; + readonly type: ExternalAuthProvider; readonly authenticate_url: string; readonly authenticated: boolean; } @@ -1655,6 +1655,21 @@ export const Experiments: Experiment[] = [ "workspace_actions", ]; +// From codersdk/workspaceagents.go +export type ExternalAuthProvider = + | "azure-devops" + | "bitbucket" + | "github" + | "gitlab" + | "openid-connect"; +export const ExternalAuthProviders: ExternalAuthProvider[] = [ + "azure-devops", + "bitbucket", + "github", + "gitlab", + "openid-connect", +]; + // From codersdk/deployment.go export type FeatureName = | "advanced_template_scheduling" @@ -1690,15 +1705,6 @@ export const FeatureNames: FeatureName[] = [ "workspace_proxy", ]; -// From codersdk/workspaceagents.go -export type GitProvider = "azure-devops" | "bitbucket" | "github" | "gitlab"; -export const GitProviders: GitProvider[] = [ - "azure-devops", - "bitbucket", - "github", - "gitlab", -]; - // From codersdk/groups.go export type GroupSource = "oidc" | "user"; export const GroupSources: GroupSource[] = ["oidc", "user"]; diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx index 84036b0392921..0e153b3136573 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx @@ -11,9 +11,9 @@ import { MockTemplateVersionParameter1, MockTemplateVersionParameter2, MockTemplateVersionParameter3, - MockTemplateVersionGitAuth, + MockTemplateVersionExternalAuthGithub, MockOrganization, - MockTemplateVersionGitAuthAuthenticated, + MockTemplateVersionExternalAuthGithubAuthenticated, } from "testHelpers/entities"; import { renderWithAuth, @@ -166,7 +166,7 @@ describe("CreateWorkspacePage", () => { jest.spyOn(API, "createWorkspace").mockResolvedValueOnce(MockWorkspace); jest .spyOn(API, "getTemplateVersionGitAuth") - .mockResolvedValue([MockTemplateVersionGitAuth]); + .mockResolvedValue([MockTemplateVersionExternalAuthGithub]); renderCreateWorkspacePage(); await waitForLoaderToBeRemoved(); @@ -182,7 +182,7 @@ describe("CreateWorkspacePage", () => { jest .spyOn(API, "getTemplateVersionGitAuth") - .mockResolvedValue([MockTemplateVersionGitAuthAuthenticated]); + .mockResolvedValue([MockTemplateVersionExternalAuthGithubAuthenticated]); await screen.findByText("Authenticated with GitHub"); @@ -203,7 +203,7 @@ describe("CreateWorkspacePage", () => { it("gitauth: errors if unauthenticated and submits", async () => { jest .spyOn(API, "getTemplateVersionGitAuth") - .mockResolvedValueOnce([MockTemplateVersionGitAuth]); + .mockResolvedValueOnce([MockTemplateVersionExternalAuthGithub]); renderCreateWorkspacePage(); await waitForLoaderToBeRemoved(); diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx index f46b5c42e26ff..aea3832f65917 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx @@ -38,7 +38,7 @@ export interface CreateWorkspacePageViewProps { defaultOwner: TypesGen.User; template: TypesGen.Template; versionId?: string; - gitAuth: TypesGen.TemplateVersionGitAuth[]; + gitAuth: TypesGen.TemplateVersionExternalAuth[]; gitAuthPollingState: GitAuthPollingState; startPollingGitAuth: () => void; parameters: TypesGen.TemplateVersionParameter[]; @@ -233,7 +233,9 @@ export const CreateWorkspacePageView: FC = ({ type GitAuthErrors = Record; -const useGitAuthVerification = (gitAuth: TypesGen.TemplateVersionGitAuth[]) => { +const useGitAuthVerification = ( + gitAuth: TypesGen.TemplateVersionExternalAuth[], +) => { const [gitAuthErrors, setGitAuthErrors] = useState({}); // Clear errors when gitAuth is refreshed diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index a15d43c402857..1a72a34a64d6c 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -2184,14 +2184,15 @@ export const MockWorkspaceBuildParameter5: TypesGen.WorkspaceBuildParameter = { value: "5", }; -export const MockTemplateVersionGitAuth: TypesGen.TemplateVersionGitAuth = { - id: "github", - type: "github", - authenticate_url: "https://example.com/gitauth/github", - authenticated: false, -}; +export const MockTemplateVersionExternalAuthGithub: TypesGen.TemplateVersionExternalAuth = + { + id: "github", + type: "github", + authenticate_url: "https://example.com/gitauth/github", + authenticated: false, + }; -export const MockTemplateVersionGitAuthAuthenticated: TypesGen.TemplateVersionGitAuth = +export const MockTemplateVersionExternalAuthGithubAuthenticated: TypesGen.TemplateVersionExternalAuth = { id: "github", type: "github", From 4709a54437a467dfa22f40fb353d59ac678c5456 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 15:28:13 +0000 Subject: [PATCH 02/16] Fix names --- coderd/provisionerdserver/provisionerdserver_test.go | 6 +++--- site/src/api/api.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 896adab98c9c9..084112c9edb14 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -176,9 +176,9 @@ func TestAcquireJob(t *testing.T) { JobID: uuid.New(), }) err := db.UpdateTemplateVersionExternalAuthProvidersByJobID(ctx, database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams{ - JobID: version.JobID, - GitAuthProviders: []string{gitAuthProvider}, - UpdatedAt: dbtime.Now(), + JobID: version.JobID, + ExternalAuthProviders: []string{gitAuthProvider}, + UpdatedAt: dbtime.Now(), }) require.NoError(t, err) // Import version job diff --git a/site/src/api/api.ts b/site/src/api/api.ts index 600903806ccef..2670bebdb338c 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -333,7 +333,7 @@ export const createTemplateVersion = async ( export const getTemplateVersionGitAuth = async ( versionId: string, -): Promise => { +): Promise => { const response = await axios.get( `/api/v2/templateversions/${versionId}/gitauth`, ); From 0f581ff0b5f8be705e91dc327465fd31932cf0ee Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 15:36:38 +0000 Subject: [PATCH 03/16] Fix outdated view --- coderd/database/dbfake/dbfake.go | 104 +++++++++--------- coderd/database/dump.sql | 2 +- .../migrations/000158_external_auth.up.sql | 22 ++++ coderd/database/models.go | 26 ++--- coderd/database/queries.sql.go | 28 ++--- .../provisionerdserver/provisionerdserver.go | 2 +- coderd/templateversions.go | 2 +- docs/admin/audit-logs.md | 2 +- enterprise/audit/table.go | 26 ++--- 9 files changed, 118 insertions(+), 96 deletions(-) diff --git a/coderd/database/dbfake/dbfake.go b/coderd/database/dbfake/dbfake.go index 81b39d183cb06..8651664f47c4d 100644 --- a/coderd/database/dbfake/dbfake.go +++ b/coderd/database/dbfake/dbfake.go @@ -1438,6 +1438,37 @@ func (q *FakeQuerier) GetDeploymentWorkspaceStats(ctx context.Context) (database return stat, nil } +func (q *FakeQuerier) GetExternalAuthLink(_ context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { + if err := validateDatabaseType(arg); err != nil { + return database.ExternalAuthLink{}, err + } + + q.mutex.RLock() + defer q.mutex.RUnlock() + for _, gitAuthLink := range q.externalAuthLinks { + if arg.UserID != gitAuthLink.UserID { + continue + } + if arg.ProviderID != gitAuthLink.ProviderID { + continue + } + return gitAuthLink, nil + } + return database.ExternalAuthLink{}, sql.ErrNoRows +} + +func (q *FakeQuerier) GetExternalAuthLinksByUserID(_ context.Context, userID uuid.UUID) ([]database.ExternalAuthLink, error) { + q.mutex.RLock() + defer q.mutex.RUnlock() + gals := make([]database.ExternalAuthLink, 0) + for _, gal := range q.externalAuthLinks { + if gal.UserID == userID { + gals = append(gals, gal) + } + } + return gals, nil +} + func (q *FakeQuerier) GetFileByHashAndCreator(_ context.Context, arg database.GetFileByHashAndCreatorParams) (database.File, error) { if err := validateDatabaseType(arg); err != nil { return database.File{}, err @@ -1507,37 +1538,6 @@ func (q *FakeQuerier) GetFileTemplates(_ context.Context, id uuid.UUID) ([]datab return rows, nil } -func (q *FakeQuerier) GetExternalAuthLink(_ context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { - if err := validateDatabaseType(arg); err != nil { - return database.ExternalAuthLink{}, err - } - - q.mutex.RLock() - defer q.mutex.RUnlock() - for _, gitAuthLink := range q.externalAuthLinks { - if arg.UserID != gitAuthLink.UserID { - continue - } - if arg.ProviderID != gitAuthLink.ProviderID { - continue - } - return gitAuthLink, nil - } - return database.ExternalAuthLink{}, sql.ErrNoRows -} - -func (q *FakeQuerier) GetExternalAuthLinksByUserID(_ context.Context, userID uuid.UUID) ([]database.ExternalAuthLink, error) { - q.mutex.RLock() - defer q.mutex.RUnlock() - gals := make([]database.ExternalAuthLink, 0) - for _, gal := range q.externalAuthLinks { - if gal.UserID == userID { - gals = append(gals, gal) - } - } - return gals, nil -} - func (q *FakeQuerier) GetGitSSHKey(_ context.Context, userID uuid.UUID) (database.GitSSHKey, error) { q.mutex.RLock() defer q.mutex.RUnlock() @@ -4205,27 +4205,6 @@ func (q *FakeQuerier) InsertDeploymentID(_ context.Context, id string) error { return nil } -func (q *FakeQuerier) InsertFile(_ context.Context, arg database.InsertFileParams) (database.File, error) { - if err := validateDatabaseType(arg); err != nil { - return database.File{}, err - } - - q.mutex.Lock() - defer q.mutex.Unlock() - - //nolint:gosimple - file := database.File{ - ID: arg.ID, - Hash: arg.Hash, - CreatedAt: arg.CreatedAt, - CreatedBy: arg.CreatedBy, - Mimetype: arg.Mimetype, - Data: arg.Data, - } - q.files = append(q.files, file) - return file, nil -} - func (q *FakeQuerier) InsertExternalAuthLink(_ context.Context, arg database.InsertExternalAuthLinkParams) (database.ExternalAuthLink, error) { if err := validateDatabaseType(arg); err != nil { return database.ExternalAuthLink{}, err @@ -4249,6 +4228,27 @@ func (q *FakeQuerier) InsertExternalAuthLink(_ context.Context, arg database.Ins return gitAuthLink, nil } +func (q *FakeQuerier) InsertFile(_ context.Context, arg database.InsertFileParams) (database.File, error) { + if err := validateDatabaseType(arg); err != nil { + return database.File{}, err + } + + q.mutex.Lock() + defer q.mutex.Unlock() + + //nolint:gosimple + file := database.File{ + ID: arg.ID, + Hash: arg.Hash, + CreatedAt: arg.CreatedAt, + CreatedBy: arg.CreatedBy, + Mimetype: arg.Mimetype, + Data: arg.Data, + } + q.files = append(q.files, file) + return file, nil +} + func (q *FakeQuerier) InsertGitSSHKey(_ context.Context, arg database.InsertGitSSHKeyParams) (database.GitSSHKey, error) { if err := validateDatabaseType(arg); err != nil { return database.GitSSHKey{}, err diff --git a/coderd/database/dump.sql b/coderd/database/dump.sql index 4ce61a2b95331..27fc6815a0d40 100644 --- a/coderd/database/dump.sql +++ b/coderd/database/dump.sql @@ -683,7 +683,7 @@ CREATE VIEW template_version_with_user AS template_versions.readme, template_versions.job_id, template_versions.created_by, - template_versions.external_auth_providers AS git_auth_providers, + template_versions.external_auth_providers, template_versions.message, COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url, COALESCE(visible_users.username, ''::text) AS created_by_username diff --git a/coderd/database/migrations/000158_external_auth.up.sql b/coderd/database/migrations/000158_external_auth.up.sql index 3fe17b2660100..3c9b787b232b6 100644 --- a/coderd/database/migrations/000158_external_auth.up.sql +++ b/coderd/database/migrations/000158_external_auth.up.sql @@ -1,3 +1,25 @@ +BEGIN; + ALTER TABLE template_versions RENAME COLUMN git_auth_providers TO external_auth_providers; ALTER TABLE git_auth_links RENAME TO external_auth_links; + +DROP VIEW template_version_with_user; +-- If you need to update this view, put 'DROP VIEW template_version_with_user;' before this. +CREATE VIEW + template_version_with_user +AS +SELECT + template_versions.*, + coalesce(visible_users.avatar_url, '') AS created_by_avatar_url, + coalesce(visible_users.username, '') AS created_by_username +FROM + template_versions + LEFT JOIN + visible_users + ON + template_versions.created_by = visible_users.id; + +COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.'; + +COMMIT; diff --git a/coderd/database/models.go b/coderd/database/models.go index 4ad2878174e9a..dda46ce282462 100644 --- a/coderd/database/models.go +++ b/coderd/database/models.go @@ -1796,19 +1796,19 @@ type TemplateTable struct { // Joins in the username + avatar url of the created by user. type TemplateVersion struct { - ID uuid.UUID `db:"id" json:"id"` - TemplateID uuid.NullUUID `db:"template_id" json:"template_id"` - OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at"` - Name string `db:"name" json:"name"` - Readme string `db:"readme" json:"readme"` - JobID uuid.UUID `db:"job_id" json:"job_id"` - CreatedBy uuid.UUID `db:"created_by" json:"created_by"` - GitAuthProviders []string `db:"git_auth_providers" json:"git_auth_providers"` - Message string `db:"message" json:"message"` - CreatedByAvatarURL sql.NullString `db:"created_by_avatar_url" json:"created_by_avatar_url"` - CreatedByUsername string `db:"created_by_username" json:"created_by_username"` + ID uuid.UUID `db:"id" json:"id"` + TemplateID uuid.NullUUID `db:"template_id" json:"template_id"` + OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at"` + Name string `db:"name" json:"name"` + Readme string `db:"readme" json:"readme"` + JobID uuid.UUID `db:"job_id" json:"job_id"` + CreatedBy uuid.UUID `db:"created_by" json:"created_by"` + ExternalAuthProviders []string `db:"external_auth_providers" json:"external_auth_providers"` + Message string `db:"message" json:"message"` + CreatedByAvatarURL sql.NullString `db:"created_by_avatar_url" json:"created_by_avatar_url"` + CreatedByUsername string `db:"created_by_username" json:"created_by_username"` } type TemplateVersionParameter struct { diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index c8ebb4c62f900..f1ea7719dfdaf 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -5303,7 +5303,7 @@ func (q *sqlQuerier) InsertTemplateVersionParameter(ctx context.Context, arg Ins const getPreviousTemplateVersion = `-- name: GetPreviousTemplateVersion :one SELECT - id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, git_auth_providers, message, created_by_avatar_url, created_by_username + id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE @@ -5337,7 +5337,7 @@ func (q *sqlQuerier) GetPreviousTemplateVersion(ctx context.Context, arg GetPrev &i.Readme, &i.JobID, &i.CreatedBy, - pq.Array(&i.GitAuthProviders), + pq.Array(&i.ExternalAuthProviders), &i.Message, &i.CreatedByAvatarURL, &i.CreatedByUsername, @@ -5347,7 +5347,7 @@ func (q *sqlQuerier) GetPreviousTemplateVersion(ctx context.Context, arg GetPrev const getTemplateVersionByID = `-- name: GetTemplateVersionByID :one SELECT - id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, git_auth_providers, message, created_by_avatar_url, created_by_username + id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE @@ -5367,7 +5367,7 @@ func (q *sqlQuerier) GetTemplateVersionByID(ctx context.Context, id uuid.UUID) ( &i.Readme, &i.JobID, &i.CreatedBy, - pq.Array(&i.GitAuthProviders), + pq.Array(&i.ExternalAuthProviders), &i.Message, &i.CreatedByAvatarURL, &i.CreatedByUsername, @@ -5377,7 +5377,7 @@ func (q *sqlQuerier) GetTemplateVersionByID(ctx context.Context, id uuid.UUID) ( const getTemplateVersionByJobID = `-- name: GetTemplateVersionByJobID :one SELECT - id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, git_auth_providers, message, created_by_avatar_url, created_by_username + id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE @@ -5397,7 +5397,7 @@ func (q *sqlQuerier) GetTemplateVersionByJobID(ctx context.Context, jobID uuid.U &i.Readme, &i.JobID, &i.CreatedBy, - pq.Array(&i.GitAuthProviders), + pq.Array(&i.ExternalAuthProviders), &i.Message, &i.CreatedByAvatarURL, &i.CreatedByUsername, @@ -5407,7 +5407,7 @@ func (q *sqlQuerier) GetTemplateVersionByJobID(ctx context.Context, jobID uuid.U const getTemplateVersionByTemplateIDAndName = `-- name: GetTemplateVersionByTemplateIDAndName :one SELECT - id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, git_auth_providers, message, created_by_avatar_url, created_by_username + id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE @@ -5433,7 +5433,7 @@ func (q *sqlQuerier) GetTemplateVersionByTemplateIDAndName(ctx context.Context, &i.Readme, &i.JobID, &i.CreatedBy, - pq.Array(&i.GitAuthProviders), + pq.Array(&i.ExternalAuthProviders), &i.Message, &i.CreatedByAvatarURL, &i.CreatedByUsername, @@ -5443,7 +5443,7 @@ func (q *sqlQuerier) GetTemplateVersionByTemplateIDAndName(ctx context.Context, const getTemplateVersionsByIDs = `-- name: GetTemplateVersionsByIDs :many SELECT - id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, git_auth_providers, message, created_by_avatar_url, created_by_username + id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE @@ -5469,7 +5469,7 @@ func (q *sqlQuerier) GetTemplateVersionsByIDs(ctx context.Context, ids []uuid.UU &i.Readme, &i.JobID, &i.CreatedBy, - pq.Array(&i.GitAuthProviders), + pq.Array(&i.ExternalAuthProviders), &i.Message, &i.CreatedByAvatarURL, &i.CreatedByUsername, @@ -5489,7 +5489,7 @@ func (q *sqlQuerier) GetTemplateVersionsByIDs(ctx context.Context, ids []uuid.UU const getTemplateVersionsByTemplateID = `-- name: GetTemplateVersionsByTemplateID :many SELECT - id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, git_auth_providers, message, created_by_avatar_url, created_by_username + id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE @@ -5553,7 +5553,7 @@ func (q *sqlQuerier) GetTemplateVersionsByTemplateID(ctx context.Context, arg Ge &i.Readme, &i.JobID, &i.CreatedBy, - pq.Array(&i.GitAuthProviders), + pq.Array(&i.ExternalAuthProviders), &i.Message, &i.CreatedByAvatarURL, &i.CreatedByUsername, @@ -5572,7 +5572,7 @@ func (q *sqlQuerier) GetTemplateVersionsByTemplateID(ctx context.Context, arg Ge } const getTemplateVersionsCreatedAfter = `-- name: GetTemplateVersionsCreatedAfter :many -SELECT id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, git_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE created_at > $1 +SELECT id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, created_by_avatar_url, created_by_username FROM template_version_with_user AS template_versions WHERE created_at > $1 ` func (q *sqlQuerier) GetTemplateVersionsCreatedAfter(ctx context.Context, createdAt time.Time) ([]TemplateVersion, error) { @@ -5594,7 +5594,7 @@ func (q *sqlQuerier) GetTemplateVersionsCreatedAfter(ctx context.Context, create &i.Readme, &i.JobID, &i.CreatedBy, - pq.Array(&i.GitAuthProviders), + pq.Array(&i.ExternalAuthProviders), &i.Message, &i.CreatedByAvatarURL, &i.CreatedByUsername, diff --git a/coderd/provisionerdserver/provisionerdserver.go b/coderd/provisionerdserver/provisionerdserver.go index 914680fb536dc..362d9a84d37f6 100644 --- a/coderd/provisionerdserver/provisionerdserver.go +++ b/coderd/provisionerdserver/provisionerdserver.go @@ -405,7 +405,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo } gitAuthProviders := []*sdkproto.GitAuthProvider{} - for _, p := range templateVersion.GitAuthProviders { + for _, p := range templateVersion.ExternalAuthProviders { link, err := s.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: p, UserID: owner.ID, diff --git a/coderd/templateversions.go b/coderd/templateversions.go index e333a9d6ef6d1..e9e3930950a87 100644 --- a/coderd/templateversions.go +++ b/coderd/templateversions.go @@ -288,7 +288,7 @@ func (api *API) templateVersionGitAuth(rw http.ResponseWriter, r *http.Request) templateVersion = httpmw.TemplateVersionParam(r) ) - rawProviders := templateVersion.GitAuthProviders + rawProviders := templateVersion.ExternalAuthProviders providers := make([]codersdk.TemplateVersionExternalAuth, 0) for _, rawProvider := range rawProviders { var config *gitauth.Config diff --git a/docs/admin/audit-logs.md b/docs/admin/audit-logs.md index 330770b89b017..864d20cc756be 100644 --- a/docs/admin/audit-logs.md +++ b/docs/admin/audit-logs.md @@ -16,7 +16,7 @@ We track the following resources: | GitSSHKey
create |
FieldTracked
created_atfalse
private_keytrue
public_keytrue
updated_atfalse
user_idtrue
| | License
create, delete |
FieldTracked
exptrue
idfalse
jwtfalse
uploaded_attrue
uuidtrue
| | Template
write, delete |
FieldTracked
active_version_idtrue
allow_user_autostarttrue
allow_user_autostoptrue
allow_user_cancel_workspace_jobstrue
autostop_requirement_days_of_weektrue
autostop_requirement_weekstrue
created_atfalse
created_bytrue
created_by_avatar_urlfalse
created_by_usernamefalse
default_ttltrue
deletedfalse
descriptiontrue
display_nametrue
failure_ttltrue
group_acltrue
icontrue
idtrue
max_ttltrue
nametrue
organization_idfalse
provisionertrue
time_til_dormanttrue
time_til_dormant_autodeletetrue
updated_atfalse
user_acltrue
| -| TemplateVersion
create, write |
FieldTracked
created_atfalse
created_bytrue
created_by_avatar_urlfalse
created_by_usernamefalse
git_auth_providersfalse
idtrue
job_idfalse
messagefalse
nametrue
organization_idfalse
readmetrue
template_idtrue
updated_atfalse
| +| TemplateVersion
create, write |
FieldTracked
created_atfalse
created_bytrue
created_by_avatar_urlfalse
created_by_usernamefalse
external_auth_providersfalse
idtrue
job_idfalse
messagefalse
nametrue
organization_idfalse
readmetrue
template_idtrue
updated_atfalse
| | User
create, write, delete |
FieldTracked
avatar_urlfalse
created_atfalse
deletedtrue
emailtrue
hashed_passwordtrue
idtrue
last_seen_atfalse
login_typetrue
quiet_hours_scheduletrue
rbac_rolestrue
statustrue
updated_atfalse
usernametrue
| | Workspace
create, write, delete |
FieldTracked
autostart_scheduletrue
created_atfalse
deletedfalse
deleting_attrue
dormant_attrue
idtrue
last_used_atfalse
nametrue
organization_idfalse
owner_idtrue
template_idtrue
ttltrue
updated_atfalse
| | WorkspaceBuild
start, stop |
FieldTracked
build_numberfalse
created_atfalse
daily_costfalse
deadlinefalse
idfalse
initiator_by_avatar_urlfalse
initiator_by_usernamefalse
initiator_idfalse
job_idfalse
max_deadlinefalse
provisioner_statefalse
reasonfalse
template_version_idtrue
transitionfalse
updated_atfalse
workspace_idfalse
| diff --git a/enterprise/audit/table.go b/enterprise/audit/table.go index b83ab02266505..611c35db1456b 100644 --- a/enterprise/audit/table.go +++ b/enterprise/audit/table.go @@ -86,19 +86,19 @@ var auditableResourcesTypes = map[any]map[string]Action{ "time_til_dormant_autodelete": ActionTrack, }, &database.TemplateVersion{}: { - "id": ActionTrack, - "template_id": ActionTrack, - "organization_id": ActionIgnore, // Never changes. - "created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff. - "updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff. - "name": ActionTrack, - "message": ActionIgnore, // Never changes after creation. - "readme": ActionTrack, - "job_id": ActionIgnore, // Not helpful in a diff because jobs aren't tracked in audit logs. - "created_by": ActionTrack, - "git_auth_providers": ActionIgnore, // Not helpful because this can only change when new versions are added. - "created_by_avatar_url": ActionIgnore, - "created_by_username": ActionIgnore, + "id": ActionTrack, + "template_id": ActionTrack, + "organization_id": ActionIgnore, // Never changes. + "created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff. + "updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff. + "name": ActionTrack, + "message": ActionIgnore, // Never changes after creation. + "readme": ActionTrack, + "job_id": ActionIgnore, // Not helpful in a diff because jobs aren't tracked in audit logs. + "created_by": ActionTrack, + "external_auth_providers": ActionIgnore, // Not helpful because this can only change when new versions are added. + "created_by_avatar_url": ActionIgnore, + "created_by_username": ActionIgnore, }, &database.User{}: { "id": ActionTrack, From 76f70ad0a8415303689c5ecd6d7ddd08496e8d51 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 15:40:21 +0000 Subject: [PATCH 04/16] Rename some additional places --- cli/create_test.go | 10 +-- cli/server.go | 2 +- coderd/coderd.go | 10 +-- coderd/coderdtest/coderdtest.go | 4 +- coderd/gitauth.go | 2 +- coderd/gitauth/config.go | 32 +++---- coderd/gitauth_test.go | 88 +++++++++---------- .../provisionerdserver/provisionerdserver.go | 12 +-- .../provisionerdserver_test.go | 2 +- coderd/templateversions.go | 2 +- coderd/templateversions_test.go | 10 +-- coderd/workspaceagents.go | 14 +-- enterprise/coderd/coderd.go | 4 +- enterprise/coderd/provisionerdaemons.go | 4 +- 14 files changed, 98 insertions(+), 98 deletions(-) diff --git a/cli/create_test.go b/cli/create_test.go index 08575143cf557..6c516ae8d8414 100644 --- a/cli/create_test.go +++ b/cli/create_test.go @@ -609,11 +609,11 @@ func TestCreateWithGitAuth(t *testing.T) { } client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, IncludeProvisionerDaemon: true, }) diff --git a/cli/server.go b/cli/server.go index 45d8d7dd471bd..bf5b92fb79e14 100644 --- a/cli/server.go +++ b/cli/server.go @@ -608,7 +608,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. Pubsub: pubsub.NewInMemory(), CacheDir: cacheDir, GoogleTokenValidator: googleTokenValidator, - GitAuthConfigs: gitAuthConfigs, + ExternalAuthConfigs: gitAuthConfigs, RealIPConfig: realIPConfig, SecureAuthCookie: vals.SecureAuthCookie.Value(), SSHKeygenAlgorithm: sshKeygenAlgorithm, diff --git a/coderd/coderd.go b/coderd/coderd.go index 24f0b38f08dc9..46792b1e7076e 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -114,7 +114,7 @@ type Options struct { SSHKeygenAlgorithm gitsshkey.Algorithm Telemetry telemetry.Reporter TracerProvider trace.TracerProvider - GitAuthConfigs []*gitauth.Config + ExternalAuthConfigs []*gitauth.Config RealIPConfig *httpmw.RealIPConfig TrialGenerator func(ctx context.Context, email string) error // TLSCertificates is used to mesh DERP servers securely. @@ -541,7 +541,7 @@ func New(options *Options) *API { // Register callback handlers for each OAuth2 provider. r.Route("/gitauth", func(r chi.Router) { - for _, gitAuthConfig := range options.GitAuthConfigs { + for _, gitAuthConfig := range options.ExternalAuthConfigs { // We don't need to register a callback handler for device auth. if gitAuthConfig.DeviceAuth != nil { continue @@ -610,7 +610,7 @@ func New(options *Options) *API { r.Route("/gitauth/{gitauth}", func(r chi.Router) { r.Use( apiKeyMiddleware, - httpmw.ExtractGitAuthParam(options.GitAuthConfigs), + httpmw.ExtractGitAuthParam(options.ExternalAuthConfigs), ) r.Get("/", api.gitAuthByID) r.Post("/device", api.postGitAuthDeviceByID) @@ -1111,8 +1111,8 @@ func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context) (client pro api.UserQuietHoursScheduleStore, api.DeploymentValues, provisionerdserver.Options{ - OIDCConfig: api.OIDCConfig, - GitAuthConfigs: api.GitAuthConfigs, + OIDCConfig: api.OIDCConfig, + ExternalAuthConfigs: api.ExternalAuthConfigs, }, ) if err != nil { diff --git a/coderd/coderdtest/coderdtest.go b/coderd/coderdtest/coderdtest.go index c91481d0d3a5c..cb6452b8f4751 100644 --- a/coderd/coderdtest/coderdtest.go +++ b/coderd/coderdtest/coderdtest.go @@ -105,7 +105,7 @@ type Options struct { AutobuildStats chan<- autobuild.Stats Auditor audit.Auditor TLSCertificates []tls.Certificate - GitAuthConfigs []*gitauth.Config + ExternalAuthConfigs []*gitauth.Config TrialGenerator func(context.Context, string) error TemplateScheduleStore schedule.TemplateScheduleStore Coordinator tailnet.Coordinator @@ -392,7 +392,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can CacheDir: t.TempDir(), Database: options.Database, Pubsub: options.Pubsub, - GitAuthConfigs: options.GitAuthConfigs, + ExternalAuthConfigs: options.ExternalAuthConfigs, Auditor: options.Auditor, AWSCertificates: options.AWSCertificates, diff --git a/coderd/gitauth.go b/coderd/gitauth.go index ac4f175e66cd8..728f4d6613d2c 100644 --- a/coderd/gitauth.go +++ b/coderd/gitauth.go @@ -32,7 +32,7 @@ func (api *API) gitAuthByID(w http.ResponseWriter, r *http.Request) { res := codersdk.GitAuth{ Authenticated: false, Device: config.DeviceAuth != nil, - AppInstallURL: config.GitAppInstallURL, + AppInstallURL: config.AppInstallURL, Type: config.Type.Pretty(), AppInstallations: []codersdk.GitAuthAppInstallation{}, } diff --git a/coderd/gitauth/config.go b/coderd/gitauth/config.go index 5d444abec10a2..820721ad1b08d 100644 --- a/coderd/gitauth/config.go +++ b/coderd/gitauth/config.go @@ -49,18 +49,18 @@ type Config struct { // not be validated before being returned. ValidateURL string - // GitCloneRegex is a Regexp matched against URLs for + // Regex is a Regexp matched against URLs for // a Git clone. e.g. "Username for 'https://github.com':" // The regex would be `github\.com`.. - GitCloneRegex *regexp.Regexp - // GitAppInstallURL is for GitHub App's (and hopefully others eventually) + Regex *regexp.Regexp + // AppInstallURL is for GitHub App's (and hopefully others eventually) // to provide a link to install the app. There's installation // of the application, and user authentication. It's possible // for the user to authenticate but the application to not. - GitAppInstallURL string - // InstallationsURL is an API endpoint that returns a list of + AppInstallURL string + // AppInstallationsURL is an API endpoint that returns a list of // installations for the user. This is used for GitHub Apps. - GitAppInstallationsURL string + AppInstallationsURL string } // RefreshToken automatically refreshes the token if expired and permitted. @@ -195,10 +195,10 @@ type AppInstallation struct { // AppInstallations returns a list of app installations for the given token. // If the provider does not support app installations, it returns nil. func (c *Config) AppInstallations(ctx context.Context, token string) ([]codersdk.GitAuthAppInstallation, bool, error) { - if c.GitAppInstallationsURL == "" { + if c.AppInstallationsURL == "" { return nil, false, nil } - req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.GitAppInstallationsURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.AppInstallationsURL, nil) if err != nil { return nil, false, err } @@ -324,14 +324,14 @@ func ConvertConfig(entries []codersdk.GitAuthConfig, accessURL *url.URL) ([]*Con } cfg := &Config{ - OAuth2Config: oauthConfig, - ID: entry.ID, - GitCloneRegex: regex, - Type: typ, - NoRefresh: entry.NoRefresh, - ValidateURL: entry.ValidateURL, - GitAppInstallationsURL: entry.AppInstallationsURL, - GitAppInstallURL: entry.AppInstallURL, + OAuth2Config: oauthConfig, + ID: entry.ID, + Regex: regex, + Type: typ, + NoRefresh: entry.NoRefresh, + ValidateURL: entry.ValidateURL, + AppInstallationsURL: entry.AppInstallationsURL, + AppInstallURL: entry.AppInstallURL, } if entry.DeviceFlow { diff --git a/coderd/gitauth_test.go b/coderd/gitauth_test.go index d6153a56e8bb0..985a823af4b82 100644 --- a/coderd/gitauth_test.go +++ b/coderd/gitauth_test.go @@ -31,7 +31,7 @@ func TestGitAuthByID(t *testing.T) { t.Run("Unauthenticated", func(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ + ExternalAuthConfigs: []*gitauth.Config{{ ID: "test", OAuth2Config: &testutil.OAuth2Config{}, Type: codersdk.ExternalAuthProviderGitHub, @@ -47,7 +47,7 @@ func TestGitAuthByID(t *testing.T) { // still return that the provider is authenticated. t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ + ExternalAuthConfigs: []*gitauth.Config{{ ID: "test", OAuth2Config: &testutil.OAuth2Config{}, // AzureDevops doesn't have a user endpoint! @@ -71,7 +71,7 @@ func TestGitAuthByID(t *testing.T) { })) defer validateSrv.Close() client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ + ExternalAuthConfigs: []*gitauth.Config{{ ID: "test", ValidateURL: validateSrv.URL, OAuth2Config: &testutil.OAuth2Config{}, @@ -111,12 +111,12 @@ func TestGitAuthByID(t *testing.T) { })) defer srv.Close() client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ - ID: "test", - ValidateURL: srv.URL + "/user", - GitAppInstallationsURL: srv.URL + "/installs", - OAuth2Config: &testutil.OAuth2Config{}, - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + ID: "test", + ValidateURL: srv.URL + "/user", + AppInstallationsURL: srv.URL + "/installs", + OAuth2Config: &testutil.OAuth2Config{}, + Type: codersdk.ExternalAuthProviderGitHub, }}, }) coderdtest.CreateFirstUser(t, client) @@ -137,7 +137,7 @@ func TestGitAuthDevice(t *testing.T) { t.Run("NotSupported", func(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ + ExternalAuthConfigs: []*gitauth.Config{{ ID: "test", }}, }) @@ -156,7 +156,7 @@ func TestGitAuthDevice(t *testing.T) { })) defer srv.Close() client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ + ExternalAuthConfigs: []*gitauth.Config{{ ID: "test", DeviceAuth: &gitauth.DeviceAuth{ ClientID: "test", @@ -180,7 +180,7 @@ func TestGitAuthDevice(t *testing.T) { })) defer srv.Close() client := coderdtest.New(t, &coderdtest.Options{ - GitAuthConfigs: []*gitauth.Config{{ + ExternalAuthConfigs: []*gitauth.Config{{ ID: "test", DeviceAuth: &gitauth.DeviceAuth{ ClientID: "test", @@ -220,7 +220,7 @@ func TestGitAuthCallback(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{}, + ExternalAuthConfigs: []*gitauth.Config{}, }) user := coderdtest.CreateFirstUser(t, client) authToken := uuid.NewString() @@ -245,11 +245,11 @@ func TestGitAuthCallback(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) @@ -274,11 +274,11 @@ func TestGitAuthCallback(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) resp := coderdtest.RequestGitAuthCallback(t, "github", client) @@ -288,11 +288,11 @@ func TestGitAuthCallback(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) _ = coderdtest.CreateFirstUser(t, client) @@ -314,12 +314,12 @@ func TestGitAuthCallback(t *testing.T) { defer srv.Close() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{{ - ValidateURL: srv.URL, - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + ValidateURL: srv.URL, + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) @@ -366,7 +366,7 @@ func TestGitAuthCallback(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{{ + ExternalAuthConfigs: []*gitauth.Config{{ OAuth2Config: &testutil.OAuth2Config{ Token: &oauth2.Token{ AccessToken: "token", @@ -374,10 +374,10 @@ func TestGitAuthCallback(t *testing.T) { Expiry: dbtime.Now().Add(-time.Hour), }, }, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, - NoRefresh: true, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, + NoRefresh: true, }}, }) user := coderdtest.CreateFirstUser(t, client) @@ -416,11 +416,11 @@ func TestGitAuthCallback(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) diff --git a/coderd/provisionerdserver/provisionerdserver.go b/coderd/provisionerdserver/provisionerdserver.go index 362d9a84d37f6..04b1ba65f7efb 100644 --- a/coderd/provisionerdserver/provisionerdserver.go +++ b/coderd/provisionerdserver/provisionerdserver.go @@ -48,8 +48,8 @@ import ( const DefaultAcquireJobLongPollDur = time.Second * 5 type Options struct { - OIDCConfig httpmw.OAuth2Config - GitAuthConfigs []*gitauth.Config + OIDCConfig httpmw.OAuth2Config + ExternalAuthConfigs []*gitauth.Config // TimeNowFn is only used in tests TimeNowFn func() time.Time @@ -62,7 +62,7 @@ type server struct { ID uuid.UUID Logger slog.Logger Provisioners []database.ProvisionerType - GitAuthConfigs []*gitauth.Config + ExternalAuthConfigs []*gitauth.Config Tags Tags Database database.Store Pubsub pubsub.Pubsub @@ -157,7 +157,7 @@ func NewServer( ID: id, Logger: logger, Provisioners: provisioners, - GitAuthConfigs: options.GitAuthConfigs, + ExternalAuthConfigs: options.ExternalAuthConfigs, Tags: tags, Database: db, Pubsub: ps, @@ -417,7 +417,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo return nil, failJob(fmt.Sprintf("acquire git auth link: %s", err)) } var config *gitauth.Config - for _, c := range s.GitAuthConfigs { + for _, c := range s.ExternalAuthConfigs { if c.ID != p { continue } @@ -1030,7 +1030,7 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) for _, gitAuthProvider := range jobType.TemplateImport.GitAuthProviders { contains := false - for _, configuredProvider := range s.GitAuthConfigs { + for _, configuredProvider := range s.ExternalAuthConfigs { if configuredProvider.ID == gitAuthProvider { contains = true break diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 084112c9edb14..da63c9608dc62 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -1748,7 +1748,7 @@ func setup(t *testing.T, ignoreLogErrors bool, ov *overrides) (proto.DRPCProvisi uqhss, deploymentValues, provisionerdserver.Options{ - GitAuthConfigs: gitAuthConfigs, + ExternalAuthConfigs: gitAuthConfigs, TimeNowFn: timeNowFn, OIDCConfig: &oauth2.Config{}, AcquireJobLongPollDur: pollDur, diff --git a/coderd/templateversions.go b/coderd/templateversions.go index e9e3930950a87..a797d1697952f 100644 --- a/coderd/templateversions.go +++ b/coderd/templateversions.go @@ -292,7 +292,7 @@ func (api *API) templateVersionGitAuth(rw http.ResponseWriter, r *http.Request) providers := make([]codersdk.TemplateVersionExternalAuth, 0) for _, rawProvider := range rawProviders { var config *gitauth.Config - for _, provider := range api.GitAuthConfigs { + for _, provider := range api.ExternalAuthConfigs { if provider.ID == rawProvider { config = provider break diff --git a/coderd/templateversions_test.go b/coderd/templateversions_test.go index 6c0c39a3932a0..1218356703cc0 100644 --- a/coderd/templateversions_test.go +++ b/coderd/templateversions_test.go @@ -338,11 +338,11 @@ func TestTemplateVersionsGitAuth(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, - GitAuthConfigs: []*gitauth.Config{{ - OAuth2Config: &testutil.OAuth2Config{}, - ID: "github", - GitCloneRegex: regexp.MustCompile(`github\.com`), - Type: codersdk.ExternalAuthProviderGitHub, + ExternalAuthConfigs: []*gitauth.Config{{ + OAuth2Config: &testutil.OAuth2Config{}, + ID: "github", + Regex: regexp.MustCompile(`github\.com`), + Type: codersdk.ExternalAuthProviderGitHub, }}, }) user := coderdtest.CreateFirstUser(t, client) diff --git a/coderd/workspaceagents.go b/coderd/workspaceagents.go index 7f17e51df5430..cef39105819c8 100644 --- a/coderd/workspaceagents.go +++ b/coderd/workspaceagents.go @@ -229,7 +229,7 @@ func (api *API) workspaceAgentManifest(rw http.ResponseWriter, r *http.Request) Scripts: convertScripts(scripts), DERPMap: api.DERPMap(), DERPForceWebSockets: api.DeploymentValues.DERP.Config.ForceWebSockets.Value(), - GitAuthConfigs: len(api.GitAuthConfigs), + GitAuthConfigs: len(api.ExternalAuthConfigs), EnvironmentVariables: apiAgent.EnvironmentVariables, Directory: apiAgent.Directory, VSCodePortProxyURI: vscodeProxyURI, @@ -2179,8 +2179,8 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) listen := r.URL.Query().Has("listen") var gitAuthConfig *gitauth.Config - for _, gitAuth := range api.GitAuthConfigs { - matches := gitAuth.GitCloneRegex.MatchString(gitURL) + for _, gitAuth := range api.ExternalAuthConfigs { + matches := gitAuth.Regex.MatchString(gitURL) if !matches { continue } @@ -2188,10 +2188,10 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) } if gitAuthConfig == nil { detail := "No git providers are configured." - if len(api.GitAuthConfigs) > 0 { - regexURLs := make([]string, 0, len(api.GitAuthConfigs)) - for _, gitAuth := range api.GitAuthConfigs { - regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", gitAuth.ID, gitAuth.GitCloneRegex.String())) + if len(api.ExternalAuthConfigs) > 0 { + regexURLs := make([]string, 0, len(api.ExternalAuthConfigs)) + for _, gitAuth := range api.ExternalAuthConfigs { + regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", gitAuth.ID, gitAuth.Regex.String())) } detail = fmt.Sprintf("The configured git provider have regex filters that do not match the git url. Provider url regexs: %s", strings.Join(regexURLs, ",")) } diff --git a/enterprise/coderd/coderd.go b/enterprise/coderd/coderd.go index 0bd10c654fa83..795dd68c10931 100644 --- a/enterprise/coderd/coderd.go +++ b/enterprise/coderd/coderd.go @@ -460,12 +460,12 @@ func (api *API) updateEntitlements(ctx context.Context) error { entitlements, err := license.Entitlements( ctx, api.Database, - api.Logger, len(api.replicaManager.AllPrimary()), len(api.GitAuthConfigs), api.LicenseKeys, map[codersdk.FeatureName]bool{ + api.Logger, len(api.replicaManager.AllPrimary()), len(api.ExternalAuthConfigs), api.LicenseKeys, map[codersdk.FeatureName]bool{ codersdk.FeatureAuditLog: api.AuditLogging, codersdk.FeatureBrowserOnly: api.BrowserOnly, codersdk.FeatureSCIM: len(api.SCIMAPIKey) != 0, codersdk.FeatureHighAvailability: api.DERPServerRelayAddress != "", - codersdk.FeatureMultipleGitAuth: len(api.GitAuthConfigs) > 1, + codersdk.FeatureMultipleGitAuth: len(api.ExternalAuthConfigs) > 1, codersdk.FeatureTemplateRBAC: api.RBAC, codersdk.FeatureExternalTokenEncryption: len(api.ExternalTokenEncryption) > 0, codersdk.FeatureExternalProvisionerDaemons: true, diff --git a/enterprise/coderd/provisionerdaemons.go b/enterprise/coderd/provisionerdaemons.go index 7ab337d169f95..c74a439e2db87 100644 --- a/enterprise/coderd/provisionerdaemons.go +++ b/enterprise/coderd/provisionerdaemons.go @@ -259,8 +259,8 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request) api.AGPL.UserQuietHoursScheduleStore, api.DeploymentValues, provisionerdserver.Options{ - GitAuthConfigs: api.GitAuthConfigs, - OIDCConfig: api.OIDCConfig, + ExternalAuthConfigs: api.ExternalAuthConfigs, + OIDCConfig: api.OIDCConfig, }, ) if err != nil { From 5e98a1dd6033ae64f4ebf833f331e10e80d3a393 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 15:47:42 +0000 Subject: [PATCH 05/16] Fix sort order --- coderd/database/queries.sql.go | 226 ++++++++++++++++----------------- 1 file changed, 113 insertions(+), 113 deletions(-) diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index f1ea7719dfdaf..40b7ee7e72715 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -9554,119 +9554,6 @@ func (q *sqlQuerier) InsertWorkspaceResourceMetadata(ctx context.Context, arg In return items, nil } -const getWorkspaceAgentScriptsByAgentIDs = `-- name: GetWorkspaceAgentScriptsByAgentIDs :many -SELECT workspace_agent_id, log_source_id, log_path, created_at, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds FROM workspace_agent_scripts WHERE workspace_agent_id = ANY($1 :: uuid [ ]) -` - -func (q *sqlQuerier) GetWorkspaceAgentScriptsByAgentIDs(ctx context.Context, ids []uuid.UUID) ([]WorkspaceAgentScript, error) { - rows, err := q.db.QueryContext(ctx, getWorkspaceAgentScriptsByAgentIDs, pq.Array(ids)) - if err != nil { - return nil, err - } - defer rows.Close() - var items []WorkspaceAgentScript - for rows.Next() { - var i WorkspaceAgentScript - if err := rows.Scan( - &i.WorkspaceAgentID, - &i.LogSourceID, - &i.LogPath, - &i.CreatedAt, - &i.Script, - &i.Cron, - &i.StartBlocksLogin, - &i.RunOnStart, - &i.RunOnStop, - &i.TimeoutSeconds, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const insertWorkspaceAgentScripts = `-- name: InsertWorkspaceAgentScripts :many -INSERT INTO - workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds) -SELECT - $1 :: uuid AS workspace_agent_id, - $2 :: timestamptz AS created_at, - unnest($3 :: uuid [ ]) AS log_source_id, - unnest($4 :: text [ ]) AS log_path, - unnest($5 :: text [ ]) AS script, - unnest($6 :: text [ ]) AS cron, - unnest($7 :: boolean [ ]) AS start_blocks_login, - unnest($8 :: boolean [ ]) AS run_on_start, - unnest($9 :: boolean [ ]) AS run_on_stop, - unnest($10 :: integer [ ]) AS timeout_seconds -RETURNING workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds -` - -type InsertWorkspaceAgentScriptsParams struct { - WorkspaceAgentID uuid.UUID `db:"workspace_agent_id" json:"workspace_agent_id"` - CreatedAt time.Time `db:"created_at" json:"created_at"` - LogSourceID []uuid.UUID `db:"log_source_id" json:"log_source_id"` - LogPath []string `db:"log_path" json:"log_path"` - Script []string `db:"script" json:"script"` - Cron []string `db:"cron" json:"cron"` - StartBlocksLogin []bool `db:"start_blocks_login" json:"start_blocks_login"` - RunOnStart []bool `db:"run_on_start" json:"run_on_start"` - RunOnStop []bool `db:"run_on_stop" json:"run_on_stop"` - TimeoutSeconds []int32 `db:"timeout_seconds" json:"timeout_seconds"` -} - -func (q *sqlQuerier) InsertWorkspaceAgentScripts(ctx context.Context, arg InsertWorkspaceAgentScriptsParams) ([]WorkspaceAgentScript, error) { - rows, err := q.db.QueryContext(ctx, insertWorkspaceAgentScripts, - arg.WorkspaceAgentID, - arg.CreatedAt, - pq.Array(arg.LogSourceID), - pq.Array(arg.LogPath), - pq.Array(arg.Script), - pq.Array(arg.Cron), - pq.Array(arg.StartBlocksLogin), - pq.Array(arg.RunOnStart), - pq.Array(arg.RunOnStop), - pq.Array(arg.TimeoutSeconds), - ) - if err != nil { - return nil, err - } - defer rows.Close() - var items []WorkspaceAgentScript - for rows.Next() { - var i WorkspaceAgentScript - if err := rows.Scan( - &i.WorkspaceAgentID, - &i.LogSourceID, - &i.LogPath, - &i.CreatedAt, - &i.Script, - &i.Cron, - &i.StartBlocksLogin, - &i.RunOnStart, - &i.RunOnStop, - &i.TimeoutSeconds, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - const getDeploymentWorkspaceStats = `-- name: GetDeploymentWorkspaceStats :one WITH workspaces_with_jobs AS ( SELECT @@ -10615,3 +10502,116 @@ func (q *sqlQuerier) UpdateWorkspacesDormantDeletingAtByTemplateID(ctx context.C _, err := q.db.ExecContext(ctx, updateWorkspacesDormantDeletingAtByTemplateID, arg.TimeTilDormantAutodeleteMs, arg.DormantAt, arg.TemplateID) return err } + +const getWorkspaceAgentScriptsByAgentIDs = `-- name: GetWorkspaceAgentScriptsByAgentIDs :many +SELECT workspace_agent_id, log_source_id, log_path, created_at, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds FROM workspace_agent_scripts WHERE workspace_agent_id = ANY($1 :: uuid [ ]) +` + +func (q *sqlQuerier) GetWorkspaceAgentScriptsByAgentIDs(ctx context.Context, ids []uuid.UUID) ([]WorkspaceAgentScript, error) { + rows, err := q.db.QueryContext(ctx, getWorkspaceAgentScriptsByAgentIDs, pq.Array(ids)) + if err != nil { + return nil, err + } + defer rows.Close() + var items []WorkspaceAgentScript + for rows.Next() { + var i WorkspaceAgentScript + if err := rows.Scan( + &i.WorkspaceAgentID, + &i.LogSourceID, + &i.LogPath, + &i.CreatedAt, + &i.Script, + &i.Cron, + &i.StartBlocksLogin, + &i.RunOnStart, + &i.RunOnStop, + &i.TimeoutSeconds, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const insertWorkspaceAgentScripts = `-- name: InsertWorkspaceAgentScripts :many +INSERT INTO + workspace_agent_scripts (workspace_agent_id, created_at, log_source_id, log_path, script, cron, start_blocks_login, run_on_start, run_on_stop, timeout_seconds) +SELECT + $1 :: uuid AS workspace_agent_id, + $2 :: timestamptz AS created_at, + unnest($3 :: uuid [ ]) AS log_source_id, + unnest($4 :: text [ ]) AS log_path, + unnest($5 :: text [ ]) AS script, + unnest($6 :: text [ ]) AS cron, + unnest($7 :: boolean [ ]) AS start_blocks_login, + unnest($8 :: boolean [ ]) AS run_on_start, + unnest($9 :: boolean [ ]) AS run_on_stop, + unnest($10 :: integer [ ]) AS timeout_seconds +RETURNING workspace_agent_scripts.workspace_agent_id, workspace_agent_scripts.log_source_id, workspace_agent_scripts.log_path, workspace_agent_scripts.created_at, workspace_agent_scripts.script, workspace_agent_scripts.cron, workspace_agent_scripts.start_blocks_login, workspace_agent_scripts.run_on_start, workspace_agent_scripts.run_on_stop, workspace_agent_scripts.timeout_seconds +` + +type InsertWorkspaceAgentScriptsParams struct { + WorkspaceAgentID uuid.UUID `db:"workspace_agent_id" json:"workspace_agent_id"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + LogSourceID []uuid.UUID `db:"log_source_id" json:"log_source_id"` + LogPath []string `db:"log_path" json:"log_path"` + Script []string `db:"script" json:"script"` + Cron []string `db:"cron" json:"cron"` + StartBlocksLogin []bool `db:"start_blocks_login" json:"start_blocks_login"` + RunOnStart []bool `db:"run_on_start" json:"run_on_start"` + RunOnStop []bool `db:"run_on_stop" json:"run_on_stop"` + TimeoutSeconds []int32 `db:"timeout_seconds" json:"timeout_seconds"` +} + +func (q *sqlQuerier) InsertWorkspaceAgentScripts(ctx context.Context, arg InsertWorkspaceAgentScriptsParams) ([]WorkspaceAgentScript, error) { + rows, err := q.db.QueryContext(ctx, insertWorkspaceAgentScripts, + arg.WorkspaceAgentID, + arg.CreatedAt, + pq.Array(arg.LogSourceID), + pq.Array(arg.LogPath), + pq.Array(arg.Script), + pq.Array(arg.Cron), + pq.Array(arg.StartBlocksLogin), + pq.Array(arg.RunOnStart), + pq.Array(arg.RunOnStop), + pq.Array(arg.TimeoutSeconds), + ) + if err != nil { + return nil, err + } + defer rows.Close() + var items []WorkspaceAgentScript + for rows.Next() { + var i WorkspaceAgentScript + if err := rows.Scan( + &i.WorkspaceAgentID, + &i.LogSourceID, + &i.LogPath, + &i.CreatedAt, + &i.Script, + &i.Cron, + &i.StartBlocksLogin, + &i.RunOnStart, + &i.RunOnStop, + &i.TimeoutSeconds, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} From a3aabe17413337978355837d795ae790324e4247 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 15:52:23 +0000 Subject: [PATCH 06/16] Fix template versions auth route --- codersdk/templateversions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codersdk/templateversions.go b/codersdk/templateversions.go index fb1f0b21febf0..3e3a1363bccf2 100644 --- a/codersdk/templateversions.go +++ b/codersdk/templateversions.go @@ -134,7 +134,7 @@ func (c *Client) TemplateVersionRichParameters(ctx context.Context, version uuid // TemplateVersionExternalAuth returns authentication providers for the requested template version. func (c *Client) TemplateVersionExternalAuth(ctx context.Context, version uuid.UUID) ([]TemplateVersionExternalAuth, error) { - res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/externalauth", version), nil) + res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/gitauth", version), nil) if err != nil { return nil, err } From 13ffd77f68381a7036e413639ffa6edf2284b50b Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 15:55:36 +0000 Subject: [PATCH 07/16] Fix types --- site/src/pages/CreateWorkspacePage/GitAuth.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/pages/CreateWorkspacePage/GitAuth.tsx b/site/src/pages/CreateWorkspacePage/GitAuth.tsx index bc81c3a73a1c9..e7ab032153165 100644 --- a/site/src/pages/CreateWorkspacePage/GitAuth.tsx +++ b/site/src/pages/CreateWorkspacePage/GitAuth.tsx @@ -15,7 +15,7 @@ import ReplayIcon from "@mui/icons-material/Replay"; import { LoadingButton } from "components/LoadingButton/LoadingButton"; export interface GitAuthProps { - type: TypesGen.GitProvider; + type: TypesGen.ExternalAuthProvider; authenticated: boolean; authenticateURL: string; gitAuthPollingState: GitAuthPollingState; From 4789226b4c8cceea3de2a62f712514d517fc981e Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 16:04:01 +0000 Subject: [PATCH 08/16] Fix dbauthz --- coderd/database/dbauthz/dbauthz_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/database/dbauthz/dbauthz_test.go b/coderd/database/dbauthz/dbauthz_test.go index 672b9c8782d14..44d66154ebb61 100644 --- a/coderd/database/dbauthz/dbauthz_test.go +++ b/coderd/database/dbauthz/dbauthz_test.go @@ -825,7 +825,7 @@ func (s *MethodTestSuite) TestTemplate() { Readme: "foo", }).Asserts(t1, rbac.ActionUpdate).Returns() })) - s.Run("UpdateTemplateVersionGitAuthProvidersByJobID", s.Subtest(func(db database.Store, check *expects) { + s.Run("UpdateTemplateVersionExternalAuthProvidersByJobID", s.Subtest(func(db database.Store, check *expects) { jobID := uuid.New() t1 := dbgen.Template(s.T(), db, database.Template{}) _ = dbgen.TemplateVersion(s.T(), db, database.TemplateVersion{ From 81269f54b9f26250eff3bc53d0ad2f7e0214267a Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 17:04:19 +0000 Subject: [PATCH 09/16] Fix names --- coderd/database/dbauthz/dbauthz_test.go | 2 +- coderd/database/dbmetrics/dbmetrics.go | 4 ++-- enterprise/dbcrypt/dbcrypt_internal_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/coderd/database/dbauthz/dbauthz_test.go b/coderd/database/dbauthz/dbauthz_test.go index 44d66154ebb61..04bb41b0459dc 100644 --- a/coderd/database/dbauthz/dbauthz_test.go +++ b/coderd/database/dbauthz/dbauthz_test.go @@ -953,7 +953,7 @@ func (s *MethodTestSuite) TestUser() { UpdatedAt: key.UpdatedAt, }).Asserts(key, rbac.ActionUpdate).Returns(key) })) - s.Run("GetGitAuthLink", s.Subtest(func(db database.Store, check *expects) { + s.Run("GetExternalAuthLink", s.Subtest(func(db database.Store, check *expects) { link := dbgen.GitAuthLink(s.T(), db, database.ExternalAuthLink{}) check.Args(database.GetExternalAuthLinkParams{ ProviderID: link.ProviderID, diff --git a/coderd/database/dbmetrics/dbmetrics.go b/coderd/database/dbmetrics/dbmetrics.go index 9f385fec013d5..a863a26d523c2 100644 --- a/coderd/database/dbmetrics/dbmetrics.go +++ b/coderd/database/dbmetrics/dbmetrics.go @@ -366,14 +366,14 @@ func (m metricsStore) GetDeploymentWorkspaceStats(ctx context.Context) (database func (m metricsStore) GetExternalAuthLink(ctx context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) { start := time.Now() link, err := m.s.GetExternalAuthLink(ctx, arg) - m.queryLatencies.WithLabelValues("GetGitAuthLink").Observe(time.Since(start).Seconds()) + m.queryLatencies.WithLabelValues("GetExternalAuthLink").Observe(time.Since(start).Seconds()) return link, err } func (m metricsStore) GetExternalAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.ExternalAuthLink, error) { start := time.Now() r0, r1 := m.s.GetExternalAuthLinksByUserID(ctx, userID) - m.queryLatencies.WithLabelValues("GetGitAuthLinksByUserID").Observe(time.Since(start).Seconds()) + m.queryLatencies.WithLabelValues("GetExternalAuthLinksByUserID").Observe(time.Since(start).Seconds()) return r0, r1 } diff --git a/enterprise/dbcrypt/dbcrypt_internal_test.go b/enterprise/dbcrypt/dbcrypt_internal_test.go index adc9715265b0e..bfec9f6e94fc4 100644 --- a/enterprise/dbcrypt/dbcrypt_internal_test.go +++ b/enterprise/dbcrypt/dbcrypt_internal_test.go @@ -266,7 +266,7 @@ func TestGitAuthLinks(t *testing.T) { requireEncryptedEquals(t, ciphers[0], link.OAuthRefreshToken, "refresh") }) - t.Run("GetGitAuthLink", func(t *testing.T) { + t.Run("GetExternalAuthLink", func(t *testing.T) { t.Run("OK", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) @@ -302,7 +302,7 @@ func TestGitAuthLinks(t *testing.T) { }) }) - t.Run("GetGitAuthLinksByUserID", func(t *testing.T) { + t.Run("GetExternalAuthLinksByUserID", func(t *testing.T) { t.Parallel() t.Run("OK", func(t *testing.T) { From e891ca5cca1a5a9dfb44601dfa607a50d9ff4a15 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 18:21:05 +0000 Subject: [PATCH 10/16] More renames --- coderd/database/dbauthz/dbauthz_test.go | 8 +- coderd/database/dbgen/dbgen.go | 4 +- coderd/database/dbgen/dbgen_test.go | 2 +- coderd/database/dbmetrics/dbmetrics.go | 6 +- .../provisionerdserver/provisionerdserver.go | 34 +- .../provisionerdserver_test.go | 16 +- enterprise/cli/server_dbcrypt_test.go | 2 +- enterprise/dbcrypt/dbcrypt_internal_test.go | 18 +- provisioner/terraform/provision.go | 8 +- provisionerd/proto/provisionerd.pb.go | 425 ++++++------ provisionerd/proto/provisionerd.proto | 4 +- provisionerd/runner/runner.go | 28 +- provisionersdk/proto/provisioner.pb.go | 623 +++++++++--------- provisionersdk/proto/provisioner.proto | 4 +- 14 files changed, 592 insertions(+), 590 deletions(-) diff --git a/coderd/database/dbauthz/dbauthz_test.go b/coderd/database/dbauthz/dbauthz_test.go index 04bb41b0459dc..a23781bb17e73 100644 --- a/coderd/database/dbauthz/dbauthz_test.go +++ b/coderd/database/dbauthz/dbauthz_test.go @@ -954,21 +954,21 @@ func (s *MethodTestSuite) TestUser() { }).Asserts(key, rbac.ActionUpdate).Returns(key) })) s.Run("GetExternalAuthLink", s.Subtest(func(db database.Store, check *expects) { - link := dbgen.GitAuthLink(s.T(), db, database.ExternalAuthLink{}) + link := dbgen.ExternalAuthLink(s.T(), db, database.ExternalAuthLink{}) check.Args(database.GetExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, }).Asserts(link, rbac.ActionRead).Returns(link) })) - s.Run("InsertGitAuthLink", s.Subtest(func(db database.Store, check *expects) { + s.Run("InsertExternalAuthLink", s.Subtest(func(db database.Store, check *expects) { u := dbgen.User(s.T(), db, database.User{}) check.Args(database.InsertExternalAuthLinkParams{ ProviderID: uuid.NewString(), UserID: u.ID, }).Asserts(rbac.ResourceUserData.WithOwner(u.ID.String()).WithID(u.ID), rbac.ActionCreate) })) - s.Run("UpdateGitAuthLink", s.Subtest(func(db database.Store, check *expects) { - link := dbgen.GitAuthLink(s.T(), db, database.ExternalAuthLink{}) + s.Run("UpdateExternalAuthLink", s.Subtest(func(db database.Store, check *expects) { + link := dbgen.ExternalAuthLink(s.T(), db, database.ExternalAuthLink{}) check.Args(database.UpdateExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, diff --git a/coderd/database/dbgen/dbgen.go b/coderd/database/dbgen/dbgen.go index 251b9dc7adf2c..e769aef7366f3 100644 --- a/coderd/database/dbgen/dbgen.go +++ b/coderd/database/dbgen/dbgen.go @@ -504,7 +504,7 @@ func UserLink(t testing.TB, db database.Store, orig database.UserLink) database. return link } -func GitAuthLink(t testing.TB, db database.Store, orig database.ExternalAuthLink) database.ExternalAuthLink { +func ExternalAuthLink(t testing.TB, db database.Store, orig database.ExternalAuthLink) database.ExternalAuthLink { link, err := db.InsertExternalAuthLink(genCtx, database.InsertExternalAuthLinkParams{ ProviderID: takeFirst(orig.ProviderID, uuid.New().String()), UserID: takeFirst(orig.UserID, uuid.New()), @@ -517,7 +517,7 @@ func GitAuthLink(t testing.TB, db database.Store, orig database.ExternalAuthLink UpdatedAt: takeFirst(orig.UpdatedAt, dbtime.Now()), }) - require.NoError(t, err, "insert git auth link") + require.NoError(t, err, "insert external auth link") return link } diff --git a/coderd/database/dbgen/dbgen_test.go b/coderd/database/dbgen/dbgen_test.go index ea99d3e1863e5..d7d961b1ae2fe 100644 --- a/coderd/database/dbgen/dbgen_test.go +++ b/coderd/database/dbgen/dbgen_test.go @@ -47,7 +47,7 @@ func TestGenerator(t *testing.T) { t.Run("GitAuthLink", func(t *testing.T) { t.Parallel() db := dbfake.New() - exp := dbgen.GitAuthLink(t, db, database.ExternalAuthLink{}) + exp := dbgen.ExternalAuthLink(t, db, database.ExternalAuthLink{}) require.Equal(t, exp, must(db.GetExternalAuthLink(context.Background(), database.GetExternalAuthLinkParams{ ProviderID: exp.ProviderID, UserID: exp.UserID, diff --git a/coderd/database/dbmetrics/dbmetrics.go b/coderd/database/dbmetrics/dbmetrics.go index a863a26d523c2..3811cb9561801 100644 --- a/coderd/database/dbmetrics/dbmetrics.go +++ b/coderd/database/dbmetrics/dbmetrics.go @@ -1169,7 +1169,7 @@ func (m metricsStore) InsertDeploymentID(ctx context.Context, value string) erro func (m metricsStore) InsertExternalAuthLink(ctx context.Context, arg database.InsertExternalAuthLinkParams) (database.ExternalAuthLink, error) { start := time.Now() link, err := m.s.InsertExternalAuthLink(ctx, arg) - m.queryLatencies.WithLabelValues("InsertGitAuthLink").Observe(time.Since(start).Seconds()) + m.queryLatencies.WithLabelValues("InsertExternalAuthLink").Observe(time.Since(start).Seconds()) return link, err } @@ -1442,7 +1442,7 @@ func (m metricsStore) UpdateAPIKeyByID(ctx context.Context, arg database.UpdateA func (m metricsStore) UpdateExternalAuthLink(ctx context.Context, arg database.UpdateExternalAuthLinkParams) (database.ExternalAuthLink, error) { start := time.Now() link, err := m.s.UpdateExternalAuthLink(ctx, arg) - m.queryLatencies.WithLabelValues("UpdateGitAuthLink").Observe(time.Since(start).Seconds()) + m.queryLatencies.WithLabelValues("UpdateExternalAuthLink").Observe(time.Since(start).Seconds()) return link, err } @@ -1554,7 +1554,7 @@ func (m metricsStore) UpdateTemplateVersionDescriptionByJobID(ctx context.Contex func (m metricsStore) UpdateTemplateVersionExternalAuthProvidersByJobID(ctx context.Context, arg database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams) error { start := time.Now() err := m.s.UpdateTemplateVersionExternalAuthProvidersByJobID(ctx, arg) - m.queryLatencies.WithLabelValues("UpdateTemplateVersionGitAuthProvidersByJobID").Observe(time.Since(start).Seconds()) + m.queryLatencies.WithLabelValues("UpdateTemplateVersionExternalAuthProvidersByJobID").Observe(time.Since(start).Seconds()) return err } diff --git a/coderd/provisionerdserver/provisionerdserver.go b/coderd/provisionerdserver/provisionerdserver.go index 04b1ba65f7efb..0fd20465236dd 100644 --- a/coderd/provisionerdserver/provisionerdserver.go +++ b/coderd/provisionerdserver/provisionerdserver.go @@ -404,7 +404,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo return nil, failJob(fmt.Sprintf("get workspace build parameters: %s", err)) } - gitAuthProviders := []*sdkproto.GitAuthProvider{} + externalAuthProviders := []*sdkproto.ExternalAuthProvider{} for _, p := range templateVersion.ExternalAuthProviders { link, err := s.Database.GetExternalAuthLink(ctx, database.GetExternalAuthLinkParams{ ProviderID: p, @@ -414,7 +414,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo continue } if err != nil { - return nil, failJob(fmt.Sprintf("acquire git auth link: %s", err)) + return nil, failJob(fmt.Sprintf("acquire external auth link: %s", err)) } var config *gitauth.Config for _, c := range s.ExternalAuthConfigs { @@ -426,8 +426,8 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo } // We weren't able to find a matching config for the ID! if config == nil { - s.Logger.Warn(ctx, "workspace build job is missing git provider", - slog.F("git_provider_id", p), + s.Logger.Warn(ctx, "workspace build job is missing external auth provider", + slog.F("provider_id", p), slog.F("template_version_id", templateVersion.ID), slog.F("workspace_id", workspaceBuild.WorkspaceID)) continue @@ -435,12 +435,12 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo link, valid, err := config.RefreshToken(ctx, s.Database, link) if err != nil { - return nil, failJob(fmt.Sprintf("refresh git auth link %q: %s", p, err)) + return nil, failJob(fmt.Sprintf("refresh external auth link %q: %s", p, err)) } if !valid { continue } - gitAuthProviders = append(gitAuthProviders, &sdkproto.GitAuthProvider{ + externalAuthProviders = append(externalAuthProviders, &sdkproto.ExternalAuthProvider{ Id: p, AccessToken: link.OAuthAccessToken, }) @@ -448,12 +448,12 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo protoJob.Type = &proto.AcquiredJob_WorkspaceBuild_{ WorkspaceBuild: &proto.AcquiredJob_WorkspaceBuild{ - WorkspaceBuildId: workspaceBuild.ID.String(), - WorkspaceName: workspace.Name, - State: workspaceBuild.ProvisionerState, - RichParameterValues: convertRichParameterValues(workspaceBuildParameters), - VariableValues: asVariableValues(templateVariables), - GitAuthProviders: gitAuthProviders, + WorkspaceBuildId: workspaceBuild.ID.String(), + WorkspaceName: workspace.Name, + State: workspaceBuild.ProvisionerState, + RichParameterValues: convertRichParameterValues(workspaceBuildParameters), + VariableValues: asVariableValues(templateVariables), + ExternalAuthProviders: externalAuthProviders, Metadata: &sdkproto.Metadata{ CoderUrl: s.AccessURL.String(), WorkspaceTransition: transition, @@ -1028,17 +1028,17 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) var completedError sql.NullString - for _, gitAuthProvider := range jobType.TemplateImport.GitAuthProviders { + for _, externalAuthProvider := range jobType.TemplateImport.ExternalAuthProviders { contains := false for _, configuredProvider := range s.ExternalAuthConfigs { - if configuredProvider.ID == gitAuthProvider { + if configuredProvider.ID == externalAuthProvider { contains = true break } } if !contains { completedError = sql.NullString{ - String: fmt.Sprintf("git auth provider %q is not configured", gitAuthProvider), + String: fmt.Sprintf("external provider %q is not configured", externalAuthProvider), Valid: true, } break @@ -1047,11 +1047,11 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) err = s.Database.UpdateTemplateVersionExternalAuthProvidersByJobID(ctx, database.UpdateTemplateVersionExternalAuthProvidersByJobIDParams{ JobID: jobID, - ExternalAuthProviders: jobType.TemplateImport.GitAuthProviders, + ExternalAuthProviders: jobType.TemplateImport.ExternalAuthProviders, UpdatedAt: dbtime.Now(), }) if err != nil { - return nil, xerrors.Errorf("update template version git auth providers: %w", err) + return nil, xerrors.Errorf("update template version external auth providers: %w", err) } err = s.Database.UpdateProvisionerJobWithCompleteByID(ctx, database.UpdateProvisionerJobWithCompleteByIDParams{ diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index da63c9608dc62..04ffd64e4a976 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -143,7 +143,7 @@ func TestAcquireJob(t *testing.T) { gitAuthProvider := "github" srv, db, ps := setup(t, false, &overrides{ deploymentValues: dv, - gitAuthConfigs: []*gitauth.Config{{ + externalAuthConfigs: []*gitauth.Config{{ ID: gitAuthProvider, OAuth2Config: &testutil.OAuth2Config{}, }}, @@ -158,7 +158,7 @@ func TestAcquireJob(t *testing.T) { OAuthExpiry: dbtime.Now().Add(time.Hour), OAuthAccessToken: "access-token", }) - dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ + dbgen.ExternalAuthLink(t, db, database.ExternalAuthLink{ ProviderID: gitAuthProvider, UserID: user.ID, }) @@ -941,7 +941,7 @@ func TestCompleteJob(t *testing.T) { srvID := uuid.New() srv, db, _ := setup(t, false, &overrides{ id: &srvID, - gitAuthConfigs: []*gitauth.Config{{ + externalAuthConfigs: []*gitauth.Config{{ ID: "github", }}, }) @@ -1675,7 +1675,7 @@ func TestInsertWorkspaceResource(t *testing.T) { type overrides struct { deploymentValues *codersdk.DeploymentValues - gitAuthConfigs []*gitauth.Config + externalAuthConfigs []*gitauth.Config id *uuid.UUID templateScheduleStore *atomic.Pointer[schedule.TemplateScheduleStore] userQuietHoursScheduleStore *atomic.Pointer[schedule.UserQuietHoursScheduleStore] @@ -1691,7 +1691,7 @@ func setup(t *testing.T, ignoreLogErrors bool, ov *overrides) (proto.DRPCProvisi db := dbfake.New() ps := pubsub.NewInMemory() deploymentValues := &codersdk.DeploymentValues{} - var gitAuthConfigs []*gitauth.Config + var externalAuthConfigs []*gitauth.Config srvID := uuid.New() tss := testTemplateScheduleStore() uqhss := testUserQuietHoursScheduleStore() @@ -1701,8 +1701,8 @@ func setup(t *testing.T, ignoreLogErrors bool, ov *overrides) (proto.DRPCProvisi if ov.deploymentValues != nil { deploymentValues = ov.deploymentValues } - if ov.gitAuthConfigs != nil { - gitAuthConfigs = ov.gitAuthConfigs + if ov.externalAuthConfigs != nil { + externalAuthConfigs = ov.externalAuthConfigs } if ov.id != nil { srvID = *ov.id @@ -1748,7 +1748,7 @@ func setup(t *testing.T, ignoreLogErrors bool, ov *overrides) (proto.DRPCProvisi uqhss, deploymentValues, provisionerdserver.Options{ - ExternalAuthConfigs: gitAuthConfigs, + ExternalAuthConfigs: externalAuthConfigs, TimeNowFn: timeNowFn, OIDCConfig: &oauth2.Config{}, AcquireJobLongPollDur: pollDur, diff --git a/enterprise/cli/server_dbcrypt_test.go b/enterprise/cli/server_dbcrypt_test.go index a0ecc3e587799..a61dbc58f3f62 100644 --- a/enterprise/cli/server_dbcrypt_test.go +++ b/enterprise/cli/server_dbcrypt_test.go @@ -222,7 +222,7 @@ func genData(t *testing.T, db database.Store) []database.User { Status: status, Deleted: deleted, }) - _ = dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ + _ = dbgen.ExternalAuthLink(t, db, database.ExternalAuthLink{ UserID: usr.ID, ProviderID: "fake", OAuthAccessToken: "access-" + usr.ID.String(), diff --git a/enterprise/dbcrypt/dbcrypt_internal_test.go b/enterprise/dbcrypt/dbcrypt_internal_test.go index bfec9f6e94fc4..589531d0dbeba 100644 --- a/enterprise/dbcrypt/dbcrypt_internal_test.go +++ b/enterprise/dbcrypt/dbcrypt_internal_test.go @@ -220,14 +220,14 @@ func TestUserLinks(t *testing.T) { }) } -func TestGitAuthLinks(t *testing.T) { +func TestExternalAuthLinks(t *testing.T) { t.Parallel() ctx := context.Background() - t.Run("InsertGitAuthLink", func(t *testing.T) { + t.Run("InsertExternalAuthLink", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{ + link := dbgen.ExternalAuthLink(t, crypt, database.ExternalAuthLink{ OAuthAccessToken: "access", OAuthRefreshToken: "refresh", }) @@ -243,10 +243,10 @@ func TestGitAuthLinks(t *testing.T) { requireEncryptedEquals(t, ciphers[0], link.OAuthRefreshToken, "refresh") }) - t.Run("UpdateGitAuthLink", func(t *testing.T) { + t.Run("UpdateExternalAuthLink", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{}) + link := dbgen.ExternalAuthLink(t, crypt, database.ExternalAuthLink{}) updated, err := crypt.UpdateExternalAuthLink(ctx, database.UpdateExternalAuthLinkParams{ ProviderID: link.ProviderID, UserID: link.UserID, @@ -270,7 +270,7 @@ func TestGitAuthLinks(t *testing.T) { t.Run("OK", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{ + link := dbgen.ExternalAuthLink(t, crypt, database.ExternalAuthLink{ OAuthAccessToken: "access", OAuthRefreshToken: "refresh", }) @@ -285,7 +285,7 @@ func TestGitAuthLinks(t *testing.T) { t.Run("DecryptErr", func(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) - link := dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ + link := dbgen.ExternalAuthLink(t, db, database.ExternalAuthLink{ OAuthAccessToken: fakeBase64RandomData(t, 32), OAuthRefreshToken: fakeBase64RandomData(t, 32), OAuthAccessTokenKeyID: sql.NullString{String: ciphers[0].HexDigest(), Valid: true}, @@ -309,7 +309,7 @@ func TestGitAuthLinks(t *testing.T) { t.Parallel() db, crypt, ciphers := setup(t) user := dbgen.User(t, crypt, database.User{}) - link := dbgen.GitAuthLink(t, crypt, database.ExternalAuthLink{ + link := dbgen.ExternalAuthLink(t, crypt, database.ExternalAuthLink{ UserID: user.ID, OAuthAccessToken: "access", OAuthRefreshToken: "refresh", @@ -332,7 +332,7 @@ func TestGitAuthLinks(t *testing.T) { t.Run("DecryptErr", func(t *testing.T) { db, crypt, ciphers := setup(t) user := dbgen.User(t, db, database.User{}) - link := dbgen.GitAuthLink(t, db, database.ExternalAuthLink{ + link := dbgen.ExternalAuthLink(t, db, database.ExternalAuthLink{ UserID: user.ID, OAuthAccessToken: fakeBase64RandomData(t, 32), OAuthRefreshToken: fakeBase64RandomData(t, 32), diff --git a/provisioner/terraform/provision.go b/provisioner/terraform/provision.go index 3b30787a00fde..5ffd06e21fa72 100644 --- a/provisioner/terraform/provision.go +++ b/provisioner/terraform/provision.go @@ -106,7 +106,7 @@ func (s *server) Plan( } s.logger.Debug(ctx, "ran initialization") - env, err := provisionEnv(sess.Config, request.Metadata, request.RichParameterValues, request.GitAuthProviders) + env, err := provisionEnv(sess.Config, request.Metadata, request.RichParameterValues, request.ExternalAuthProviders) if err != nil { return provisionersdk.PlanErrorf("setup env: %s", err) } @@ -183,7 +183,7 @@ func planVars(plan *proto.PlanRequest) ([]string, error) { func provisionEnv( config *proto.Config, metadata *proto.Metadata, - richParams []*proto.RichParameterValue, gitAuth []*proto.GitAuthProvider, + richParams []*proto.RichParameterValue, externalAuth []*proto.ExternalAuthProvider, ) ([]string, error) { env := safeEnviron() env = append(env, @@ -205,8 +205,8 @@ func provisionEnv( for _, param := range richParams { env = append(env, provider.ParameterEnvironmentVariable(param.Name)+"="+param.Value) } - for _, gitAuth := range gitAuth { - env = append(env, provider.GitAuthAccessTokenEnvironmentVariable(gitAuth.Id)+"="+gitAuth.AccessToken) + for _, extAuth := range externalAuth { + env = append(env, provider.GitAuthAccessTokenEnvironmentVariable(extAuth.Id)+"="+extAuth.AccessToken) } if config.ProvisionerLogLevel != "" { diff --git a/provisionerd/proto/provisionerd.pb.go b/provisionerd/proto/provisionerd.pb.go index 186f4f79bad4d..451d301e9c38d 100644 --- a/provisionerd/proto/provisionerd.pb.go +++ b/provisionerd/proto/provisionerd.pb.go @@ -852,14 +852,14 @@ type AcquiredJob_WorkspaceBuild struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - WorkspaceBuildId string `protobuf:"bytes,1,opt,name=workspace_build_id,json=workspaceBuildId,proto3" json:"workspace_build_id,omitempty"` - WorkspaceName string `protobuf:"bytes,2,opt,name=workspace_name,json=workspaceName,proto3" json:"workspace_name,omitempty"` - RichParameterValues []*proto.RichParameterValue `protobuf:"bytes,4,rep,name=rich_parameter_values,json=richParameterValues,proto3" json:"rich_parameter_values,omitempty"` - VariableValues []*proto.VariableValue `protobuf:"bytes,5,rep,name=variable_values,json=variableValues,proto3" json:"variable_values,omitempty"` - GitAuthProviders []*proto.GitAuthProvider `protobuf:"bytes,6,rep,name=git_auth_providers,json=gitAuthProviders,proto3" json:"git_auth_providers,omitempty"` - Metadata *proto.Metadata `protobuf:"bytes,7,opt,name=metadata,proto3" json:"metadata,omitempty"` - State []byte `protobuf:"bytes,8,opt,name=state,proto3" json:"state,omitempty"` - LogLevel string `protobuf:"bytes,9,opt,name=log_level,json=logLevel,proto3" json:"log_level,omitempty"` + WorkspaceBuildId string `protobuf:"bytes,1,opt,name=workspace_build_id,json=workspaceBuildId,proto3" json:"workspace_build_id,omitempty"` + WorkspaceName string `protobuf:"bytes,2,opt,name=workspace_name,json=workspaceName,proto3" json:"workspace_name,omitempty"` + RichParameterValues []*proto.RichParameterValue `protobuf:"bytes,4,rep,name=rich_parameter_values,json=richParameterValues,proto3" json:"rich_parameter_values,omitempty"` + VariableValues []*proto.VariableValue `protobuf:"bytes,5,rep,name=variable_values,json=variableValues,proto3" json:"variable_values,omitempty"` + ExternalAuthProviders []*proto.ExternalAuthProvider `protobuf:"bytes,6,rep,name=external_auth_providers,json=externalAuthProviders,proto3" json:"external_auth_providers,omitempty"` + Metadata *proto.Metadata `protobuf:"bytes,7,opt,name=metadata,proto3" json:"metadata,omitempty"` + State []byte `protobuf:"bytes,8,opt,name=state,proto3" json:"state,omitempty"` + LogLevel string `protobuf:"bytes,9,opt,name=log_level,json=logLevel,proto3" json:"log_level,omitempty"` } func (x *AcquiredJob_WorkspaceBuild) Reset() { @@ -922,9 +922,9 @@ func (x *AcquiredJob_WorkspaceBuild) GetVariableValues() []*proto.VariableValue return nil } -func (x *AcquiredJob_WorkspaceBuild) GetGitAuthProviders() []*proto.GitAuthProvider { +func (x *AcquiredJob_WorkspaceBuild) GetExternalAuthProviders() []*proto.ExternalAuthProvider { if x != nil { - return x.GitAuthProviders + return x.ExternalAuthProviders } return nil } @@ -1251,10 +1251,10 @@ type CompletedJob_TemplateImport struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StartResources []*proto.Resource `protobuf:"bytes,1,rep,name=start_resources,json=startResources,proto3" json:"start_resources,omitempty"` - StopResources []*proto.Resource `protobuf:"bytes,2,rep,name=stop_resources,json=stopResources,proto3" json:"stop_resources,omitempty"` - RichParameters []*proto.RichParameter `protobuf:"bytes,3,rep,name=rich_parameters,json=richParameters,proto3" json:"rich_parameters,omitempty"` - GitAuthProviders []string `protobuf:"bytes,4,rep,name=git_auth_providers,json=gitAuthProviders,proto3" json:"git_auth_providers,omitempty"` + StartResources []*proto.Resource `protobuf:"bytes,1,rep,name=start_resources,json=startResources,proto3" json:"start_resources,omitempty"` + StopResources []*proto.Resource `protobuf:"bytes,2,rep,name=stop_resources,json=stopResources,proto3" json:"stop_resources,omitempty"` + RichParameters []*proto.RichParameter `protobuf:"bytes,3,rep,name=rich_parameters,json=richParameters,proto3" json:"rich_parameters,omitempty"` + ExternalAuthProviders []string `protobuf:"bytes,4,rep,name=external_auth_providers,json=externalAuthProviders,proto3" json:"external_auth_providers,omitempty"` } func (x *CompletedJob_TemplateImport) Reset() { @@ -1310,9 +1310,9 @@ func (x *CompletedJob_TemplateImport) GetRichParameters() []*proto.RichParameter return nil } -func (x *CompletedJob_TemplateImport) GetGitAuthProviders() []string { +func (x *CompletedJob_TemplateImport) GetExternalAuthProviders() []string { if x != nil { - return x.GitAuthProviders + return x.ExternalAuthProviders } return nil } @@ -1373,7 +1373,7 @@ var file_provisionerd_proto_provisionerd_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x1a, 0x26, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x73, 0x64, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x07, 0x0a, - 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x8d, 0x0b, 0x0a, 0x0b, 0x41, 0x63, 0x71, 0x75, 0x69, + 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x9c, 0x0b, 0x0a, 0x0b, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, @@ -1406,7 +1406,7 @@ var file_provisionerd_proto_provisionerd_proto_rawDesc = []byte{ 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x63, 0x65, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0xb7, 0x03, 0x0a, 0x0e, 0x57, 0x6f, 0x72, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0xc6, 0x03, 0x0a, 0x0e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, @@ -1422,203 +1422,204 @@ var file_provisionerd_proto_provisionerd_proto_rawDesc = []byte{ 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0e, 0x76, 0x61, 0x72, 0x69, - 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x12, 0x67, 0x69, - 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, - 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x47, 0x69, 0x74, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x52, 0x10, 0x67, 0x69, 0x74, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, - 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, - 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x1b, 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x4a, 0x04, 0x08, 0x03, - 0x10, 0x04, 0x1a, 0x91, 0x01, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, - 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x59, 0x0a, 0x17, 0x65, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x15, + 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x4c, 0x0a, 0x14, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x4a, 0x04, 0x08, 0x03, 0x10, + 0x04, 0x1a, 0x91, 0x01, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, + 0x70, 0x6f, 0x72, 0x74, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x4c, 0x0a, 0x14, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x52, 0x12, 0x75, 0x73, 0x65, 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x1a, 0xe3, 0x01, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x12, 0x53, 0x0a, 0x15, 0x72, 0x69, 0x63, 0x68, + 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x13, 0x72, 0x69, 0x63, 0x68, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x43, 0x0a, + 0x0f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x52, 0x12, 0x75, 0x73, 0x65, 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x1a, 0xe3, 0x01, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x12, 0x53, 0x0a, 0x15, 0x72, 0x69, 0x63, - 0x68, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x65, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x13, 0x72, 0x69, 0x63, 0x68, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x43, - 0x0a, 0x0f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x52, 0x0e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x1a, 0x40, 0x0a, 0x12, - 0x54, 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xa5, 0x03, 0x0a, 0x09, 0x46, 0x61, 0x69, 0x6c, 0x65, - 0x64, 0x4a, 0x6f, 0x62, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x12, 0x51, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x62, - 0x75, 0x69, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, - 0x4a, 0x6f, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, - 0x6c, 0x64, 0x48, 0x00, 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, - 0x75, 0x69, 0x6c, 0x64, 0x12, 0x51, 0x0a, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x46, 0x61, 0x69, - 0x6c, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, - 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x52, 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x5f, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, - 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x1a, 0x26, 0x0a, 0x0e, 0x57, 0x6f, - 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x14, 0x0a, 0x05, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, - 0x74, 0x65, 0x1a, 0x10, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, - 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x10, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xd8, - 0x05, 0x0a, 0x0c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x12, - 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x54, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, - 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x48, 0x00, 0x52, 0x0e, 0x77, 0x6f, - 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x54, 0x0a, 0x0f, - 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, - 0x62, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, - 0x48, 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, 0x70, 0x6f, - 0x72, 0x74, 0x12, 0x55, 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x64, - 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x70, - 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, - 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x1a, 0x5b, 0x0a, 0x0e, 0x57, 0x6f, 0x72, + 0x75, 0x65, 0x52, 0x0e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x1a, 0x40, 0x0a, 0x12, 0x54, + 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xa5, 0x03, 0x0a, 0x09, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, + 0x4a, 0x6f, 0x62, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x12, 0x51, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4a, + 0x6f, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, + 0x64, 0x48, 0x00, 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, + 0x69, 0x6c, 0x64, 0x12, 0x51, 0x0a, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, + 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x46, 0x61, 0x69, 0x6c, + 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, + 0x70, 0x6f, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x52, 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x5f, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, + 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x1a, 0x26, 0x0a, 0x0e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x81, 0x02, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x3e, 0x0a, 0x0f, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, - 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3c, 0x0a, 0x0e, 0x73, 0x74, 0x6f, - 0x70, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, - 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x0d, 0x73, 0x74, 0x6f, 0x70, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x0f, 0x72, 0x69, 0x63, 0x68, 0x5f, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, - 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x72, 0x69, - 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x2c, 0x0a, 0x12, - 0x67, 0x69, 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, - 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x41, 0x75, 0x74, - 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x1a, 0x45, 0x0a, 0x0e, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x12, 0x33, 0x0a, 0x09, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x03, 0x4c, 0x6f, - 0x67, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, - 0x2e, 0x4c, 0x6f, 0x67, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, - 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, - 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, - 0x74, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x8a, 0x02, 0x0a, - 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, - 0x4c, 0x0a, 0x12, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, 0x72, 0x69, - 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x11, 0x74, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x4c, 0x0a, - 0x14, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, - 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x12, 0x75, 0x73, 0x65, 0x72, 0x56, 0x61, 0x72, - 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, - 0x65, 0x61, 0x64, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x61, - 0x64, 0x6d, 0x65, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x22, 0x7a, 0x0a, 0x11, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x12, 0x43, 0x0a, 0x0f, 0x76, 0x61, - 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, - 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, - 0x0e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x4a, - 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x4a, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x51, - 0x75, 0x6f, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6a, - 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, - 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x73, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x43, 0x6f, 0x73, - 0x74, 0x22, 0x68, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x61, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x72, 0x65, 0x64, - 0x69, 0x74, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0f, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x43, 0x6f, 0x6e, 0x73, 0x75, - 0x6d, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x22, 0x0f, 0x0a, 0x0d, 0x43, - 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x2a, 0x34, 0x0a, 0x09, - 0x4c, 0x6f, 0x67, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x50, 0x52, 0x4f, - 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, 0x52, 0x5f, 0x44, 0x41, 0x45, 0x4d, 0x4f, 0x4e, 0x10, - 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, 0x52, - 0x10, 0x01, 0x32, 0xc5, 0x03, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x65, 0x72, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x0a, 0x41, 0x63, 0x71, 0x75, - 0x69, 0x72, 0x65, 0x4a, 0x6f, 0x62, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x19, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, - 0x72, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x22, 0x03, 0x88, 0x02, 0x01, 0x12, 0x52, 0x0a, 0x14, 0x41, - 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4a, 0x6f, 0x62, 0x57, 0x69, 0x74, 0x68, 0x43, 0x61, 0x6e, - 0x63, 0x65, 0x6c, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, - 0x72, 0x64, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, - 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, - 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x28, 0x01, 0x30, 0x01, 0x12, - 0x52, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x12, 0x20, + 0x65, 0x1a, 0x10, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, 0x70, + 0x6f, 0x72, 0x74, 0x1a, 0x10, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x44, + 0x72, 0x79, 0x52, 0x75, 0x6e, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xe2, 0x05, + 0x0a, 0x0c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x12, 0x15, + 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x54, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, - 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x37, 0x0a, 0x07, 0x46, 0x61, 0x69, 0x6c, 0x4a, 0x6f, 0x62, 0x12, 0x17, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x46, 0x61, 0x69, 0x6c, - 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3e, 0x0a, 0x0b, 0x43, 0x6f, - 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, - 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x48, 0x00, 0x52, 0x0e, 0x77, 0x6f, 0x72, + 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x54, 0x0a, 0x0f, 0x74, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, + 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x48, + 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, + 0x74, 0x12, 0x55, 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x64, 0x72, + 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, + 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x1a, 0x5b, 0x0a, 0x0e, 0x57, 0x6f, 0x72, 0x6b, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, + 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x8b, 0x02, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x3e, 0x0a, 0x0f, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x0e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3c, 0x0a, 0x0e, 0x73, 0x74, 0x6f, 0x70, + 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x0d, 0x73, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x0f, 0x72, 0x69, 0x63, 0x68, 0x5f, 0x70, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, + 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x72, 0x69, 0x63, + 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x36, 0x0a, 0x17, 0x65, + 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x15, 0x65, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x72, 0x73, 0x1a, 0x45, 0x0a, 0x0e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x44, + 0x72, 0x79, 0x52, 0x75, 0x6e, 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, + 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, 0x6f, 0x67, 0x53, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x6c, + 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, + 0x6c, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, + 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x8a, 0x02, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, + 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, + 0x64, 0x12, 0x25, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, + 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x4c, 0x0a, 0x12, 0x74, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, + 0x62, 0x6c, 0x65, 0x52, 0x11, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, + 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x4c, 0x0a, 0x14, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x76, + 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x12, 0x75, 0x73, 0x65, 0x72, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x65, 0x4a, 0x04, 0x08, 0x03, + 0x10, 0x04, 0x22, 0x7a, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x6e, 0x63, 0x65, + 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x63, 0x61, 0x6e, 0x63, 0x65, + 0x6c, 0x65, 0x64, 0x12, 0x43, 0x0a, 0x0f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, + 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, + 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x4a, + 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x64, + 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x43, 0x6f, 0x73, 0x74, 0x22, 0x68, 0x0a, 0x13, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, + 0x6b, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x72, 0x65, 0x64, 0x69, 0x74, 0x73, 0x5f, 0x63, 0x6f, 0x6e, + 0x73, 0x75, 0x6d, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x63, 0x72, 0x65, + 0x64, 0x69, 0x74, 0x73, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, + 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, + 0x64, 0x67, 0x65, 0x74, 0x22, 0x0f, 0x0a, 0x0d, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x63, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x2a, 0x34, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x53, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, + 0x52, 0x5f, 0x44, 0x41, 0x45, 0x4d, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x52, + 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, 0x52, 0x10, 0x01, 0x32, 0xc5, 0x03, 0x0a, 0x11, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x65, 0x6d, 0x6f, + 0x6e, 0x12, 0x41, 0x0a, 0x0a, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4a, 0x6f, 0x62, 0x12, + 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x64, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x22, + 0x03, 0x88, 0x02, 0x01, 0x12, 0x52, 0x0a, 0x14, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4a, + 0x6f, 0x62, 0x57, 0x69, 0x74, 0x68, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x12, 0x1b, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x61, 0x6e, 0x63, + 0x65, 0x6c, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x64, 0x4a, 0x6f, 0x62, 0x28, 0x01, 0x30, 0x01, 0x12, 0x52, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x12, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x51, 0x75, 0x6f, + 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x51, + 0x75, 0x6f, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x09, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, + 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, + 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x46, 0x61, + 0x69, 0x6c, 0x4a, 0x6f, 0x62, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x12, 0x3e, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x4a, + 0x6f, 0x62, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, + 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x76, 0x32, + 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1661,7 +1662,7 @@ var file_provisionerd_proto_provisionerd_proto_goTypes = []interface{}{ (*proto.TemplateVariable)(nil), // 22: provisioner.TemplateVariable (*proto.VariableValue)(nil), // 23: provisioner.VariableValue (*proto.RichParameterValue)(nil), // 24: provisioner.RichParameterValue - (*proto.GitAuthProvider)(nil), // 25: provisioner.GitAuthProvider + (*proto.ExternalAuthProvider)(nil), // 25: provisioner.ExternalAuthProvider (*proto.Metadata)(nil), // 26: provisioner.Metadata (*proto.Resource)(nil), // 27: provisioner.Resource (*proto.RichParameter)(nil), // 28: provisioner.RichParameter @@ -1685,7 +1686,7 @@ var file_provisionerd_proto_provisionerd_proto_depIdxs = []int32{ 23, // 15: provisionerd.UpdateJobResponse.variable_values:type_name -> provisioner.VariableValue 24, // 16: provisionerd.AcquiredJob.WorkspaceBuild.rich_parameter_values:type_name -> provisioner.RichParameterValue 23, // 17: provisionerd.AcquiredJob.WorkspaceBuild.variable_values:type_name -> provisioner.VariableValue - 25, // 18: provisionerd.AcquiredJob.WorkspaceBuild.git_auth_providers:type_name -> provisioner.GitAuthProvider + 25, // 18: provisionerd.AcquiredJob.WorkspaceBuild.external_auth_providers:type_name -> provisioner.ExternalAuthProvider 26, // 19: provisionerd.AcquiredJob.WorkspaceBuild.metadata:type_name -> provisioner.Metadata 26, // 20: provisionerd.AcquiredJob.TemplateImport.metadata:type_name -> provisioner.Metadata 23, // 21: provisionerd.AcquiredJob.TemplateImport.user_variable_values:type_name -> provisioner.VariableValue diff --git a/provisionerd/proto/provisionerd.proto b/provisionerd/proto/provisionerd.proto index bab2ad5c0cb69..705c0ffbed258 100644 --- a/provisionerd/proto/provisionerd.proto +++ b/provisionerd/proto/provisionerd.proto @@ -18,7 +18,7 @@ message AcquiredJob { string workspace_name = 2; repeated provisioner.RichParameterValue rich_parameter_values = 4; repeated provisioner.VariableValue variable_values = 5; - repeated provisioner.GitAuthProvider git_auth_providers = 6; + repeated provisioner.ExternalAuthProvider external_auth_providers = 6; provisioner.Metadata metadata = 7; bytes state = 8; string log_level = 9; @@ -77,7 +77,7 @@ message CompletedJob { repeated provisioner.Resource start_resources = 1; repeated provisioner.Resource stop_resources = 2; repeated provisioner.RichParameter rich_parameters = 3; - repeated string git_auth_providers = 4; + repeated string external_auth_providers = 4; } message TemplateDryRun { repeated provisioner.Resource resources = 1; diff --git a/provisionerd/runner/runner.go b/provisionerd/runner/runner.go index 7afa7a0999627..7fe2c5a5211d7 100644 --- a/provisionerd/runner/runner.go +++ b/provisionerd/runner/runner.go @@ -568,10 +568,10 @@ func (r *Runner) runTemplateImport(ctx context.Context) (*proto.CompletedJob, *p JobId: r.job.JobId, Type: &proto.CompletedJob_TemplateImport_{ TemplateImport: &proto.CompletedJob_TemplateImport{ - StartResources: startProvision.Resources, - StopResources: stopProvision.Resources, - RichParameters: startProvision.Parameters, - GitAuthProviders: startProvision.GitAuthProviders, + StartResources: startProvision.Resources, + StopResources: stopProvision.Resources, + RichParameters: startProvision.Parameters, + ExternalAuthProviders: startProvision.ExternalAuthProviders, }, }, }, nil @@ -627,9 +627,9 @@ func (r *Runner) runTemplateImportParse(ctx context.Context) ( } type templateImportProvision struct { - Resources []*sdkproto.Resource - Parameters []*sdkproto.RichParameter - GitAuthProviders []string + Resources []*sdkproto.Resource + Parameters []*sdkproto.RichParameter + ExternalAuthProviders []string } // Performs a dry-run provision when importing a template. @@ -718,9 +718,9 @@ func (r *Runner) runTemplateImportProvisionWithRichParameters( ) return &templateImportProvision{ - Resources: c.Resources, - Parameters: c.Parameters, - GitAuthProviders: c.GitAuthProviders, + Resources: c.Resources, + Parameters: c.Parameters, + ExternalAuthProviders: c.GitAuthProviders, }, nil default: return nil, xerrors.Errorf("invalid message type %q received from provisioner", @@ -925,10 +925,10 @@ func (r *Runner) runWorkspaceBuild(ctx context.Context) (*proto.CompletedJob, *p resp, failed := r.buildWorkspace(ctx, "Planning infrastructure", &sdkproto.Request{ Type: &sdkproto.Request_Plan{ Plan: &sdkproto.PlanRequest{ - Metadata: r.job.GetWorkspaceBuild().Metadata, - RichParameterValues: r.job.GetWorkspaceBuild().RichParameterValues, - VariableValues: r.job.GetWorkspaceBuild().VariableValues, - GitAuthProviders: r.job.GetWorkspaceBuild().GitAuthProviders, + Metadata: r.job.GetWorkspaceBuild().Metadata, + RichParameterValues: r.job.GetWorkspaceBuild().RichParameterValues, + VariableValues: r.job.GetWorkspaceBuild().VariableValues, + ExternalAuthProviders: r.job.GetWorkspaceBuild().ExternalAuthProviders, }, }, }) diff --git a/provisionersdk/proto/provisioner.pb.go b/provisionersdk/proto/provisioner.pb.go index 6b96780c5cdbf..7ec9944717c18 100644 --- a/provisionersdk/proto/provisioner.pb.go +++ b/provisionersdk/proto/provisioner.pb.go @@ -766,7 +766,7 @@ func (x *InstanceIdentityAuth) GetInstanceId() string { return "" } -type GitAuthProvider struct { +type ExternalAuthProvider struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -775,8 +775,8 @@ type GitAuthProvider struct { AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` } -func (x *GitAuthProvider) Reset() { - *x = GitAuthProvider{} +func (x *ExternalAuthProvider) Reset() { + *x = ExternalAuthProvider{} if protoimpl.UnsafeEnabled { mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -784,13 +784,13 @@ func (x *GitAuthProvider) Reset() { } } -func (x *GitAuthProvider) String() string { +func (x *ExternalAuthProvider) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GitAuthProvider) ProtoMessage() {} +func (*ExternalAuthProvider) ProtoMessage() {} -func (x *GitAuthProvider) ProtoReflect() protoreflect.Message { +func (x *ExternalAuthProvider) ProtoReflect() protoreflect.Message { mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -802,19 +802,19 @@ func (x *GitAuthProvider) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GitAuthProvider.ProtoReflect.Descriptor instead. -func (*GitAuthProvider) Descriptor() ([]byte, []int) { +// Deprecated: Use ExternalAuthProvider.ProtoReflect.Descriptor instead. +func (*ExternalAuthProvider) Descriptor() ([]byte, []int) { return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{8} } -func (x *GitAuthProvider) GetId() string { +func (x *ExternalAuthProvider) GetId() string { if x != nil { return x.Id } return "" } -func (x *GitAuthProvider) GetAccessToken() string { +func (x *ExternalAuthProvider) GetAccessToken() string { if x != nil { return x.AccessToken } @@ -1795,10 +1795,10 @@ type PlanRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` - RichParameterValues []*RichParameterValue `protobuf:"bytes,2,rep,name=rich_parameter_values,json=richParameterValues,proto3" json:"rich_parameter_values,omitempty"` - VariableValues []*VariableValue `protobuf:"bytes,3,rep,name=variable_values,json=variableValues,proto3" json:"variable_values,omitempty"` - GitAuthProviders []*GitAuthProvider `protobuf:"bytes,4,rep,name=git_auth_providers,json=gitAuthProviders,proto3" json:"git_auth_providers,omitempty"` + Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + RichParameterValues []*RichParameterValue `protobuf:"bytes,2,rep,name=rich_parameter_values,json=richParameterValues,proto3" json:"rich_parameter_values,omitempty"` + VariableValues []*VariableValue `protobuf:"bytes,3,rep,name=variable_values,json=variableValues,proto3" json:"variable_values,omitempty"` + ExternalAuthProviders []*ExternalAuthProvider `protobuf:"bytes,4,rep,name=external_auth_providers,json=externalAuthProviders,proto3" json:"external_auth_providers,omitempty"` } func (x *PlanRequest) Reset() { @@ -1854,9 +1854,9 @@ func (x *PlanRequest) GetVariableValues() []*VariableValue { return nil } -func (x *PlanRequest) GetGitAuthProviders() []*GitAuthProvider { +func (x *PlanRequest) GetExternalAuthProviders() []*ExternalAuthProvider { if x != nil { - return x.GitAuthProviders + return x.ExternalAuthProviders } return nil } @@ -2567,298 +2567,299 @@ var file_provisionersdk_proto_provisioner_proto_rawDesc = []byte{ 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x41, 0x75, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x49, 0x64, 0x22, 0x44, 0x0a, 0x0f, 0x47, 0x69, 0x74, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xc3, 0x06, 0x0a, 0x05, 0x41, 0x67, 0x65, - 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, - 0x72, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x6e, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, 0x29, 0x0a, 0x10, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6e, 0x67, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, - 0x74, 0x75, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, - 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x79, 0x12, 0x24, 0x0a, 0x04, 0x61, 0x70, 0x70, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, - 0x70, 0x70, 0x52, 0x04, 0x61, 0x70, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x21, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x49, 0x64, 0x12, 0x3c, 0x0a, 0x1a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, - 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x18, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, - 0x73, 0x12, 0x2f, 0x0a, 0x13, 0x74, 0x72, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x73, 0x68, 0x6f, 0x6f, - 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, - 0x74, 0x72, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x73, 0x68, 0x6f, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x55, - 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x6f, 0x74, 0x64, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, - 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x6f, 0x74, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, - 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x12, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, - 0x41, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3b, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, - 0x6c, 0x61, 0x79, 0x5f, 0x61, 0x70, 0x70, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x44, 0x69, 0x73, - 0x70, 0x6c, 0x61, 0x79, 0x41, 0x70, 0x70, 0x73, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, - 0x79, 0x41, 0x70, 0x70, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, - 0x18, 0x15, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x07, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x73, 0x1a, 0x8d, 0x01, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, - 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x1a, - 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, - 0x65, 0x6f, 0x75, 0x74, 0x1a, 0x36, 0x0a, 0x08, 0x45, 0x6e, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x0a, 0x04, - 0x61, 0x75, 0x74, 0x68, 0x4a, 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x52, 0x12, 0x6c, 0x6f, 0x67, 0x69, - 0x6e, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x22, 0xc6, - 0x01, 0x0a, 0x0b, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x41, 0x70, 0x70, 0x73, 0x12, 0x16, - 0x0a, 0x06, 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, - 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, - 0x5f, 0x69, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0e, 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12, - 0x21, 0x0a, 0x0c, 0x77, 0x65, 0x62, 0x5f, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x77, 0x65, 0x62, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, - 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x73, 0x68, 0x5f, 0x68, 0x65, 0x6c, 0x70, 0x65, 0x72, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x73, 0x68, 0x48, 0x65, 0x6c, 0x70, 0x65, - 0x72, 0x12, 0x34, 0x0a, 0x16, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, - 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x68, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x14, 0x70, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, - 0x67, 0x48, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x22, 0x9f, 0x02, 0x0a, 0x06, 0x53, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, - 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x10, 0x73, 0x74, 0x61, 0x72, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x4c, 0x6f, - 0x67, 0x69, 0x6e, 0x12, 0x20, 0x0a, 0x0c, 0x72, 0x75, 0x6e, 0x5f, 0x6f, 0x6e, 0x5f, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x72, 0x75, 0x6e, 0x4f, 0x6e, - 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x72, 0x75, 0x6e, 0x5f, 0x6f, 0x6e, 0x5f, - 0x73, 0x74, 0x6f, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x72, 0x75, 0x6e, 0x4f, - 0x6e, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, - 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x19, - 0x0a, 0x08, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6c, 0x6f, 0x67, 0x50, 0x61, 0x74, 0x68, 0x22, 0xb5, 0x02, 0x0a, 0x03, 0x41, 0x70, - 0x70, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x75, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x73, 0x6c, 0x75, 0x67, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, - 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x75, 0x62, - 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x3a, 0x0a, 0x0b, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, - 0x63, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, - 0x63, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x0b, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x63, 0x68, 0x65, - 0x63, 0x6b, 0x12, 0x41, 0x0a, 0x0d, 0x73, 0x68, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x65, - 0x76, 0x65, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x53, 0x68, 0x61, 0x72, 0x69, - 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x69, 0x6e, 0x67, - 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x22, 0x59, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x63, 0x68, 0x65, 0x63, 0x6b, - 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, - 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x1c, - 0x0a, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0xf1, 0x02, 0x0a, - 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, - 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3a, 0x0a, - 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, - 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x64, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x68, 0x69, 0x64, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, - 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, - 0x63, 0x6f, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x64, 0x61, 0x69, 0x6c, - 0x79, 0x43, 0x6f, 0x73, 0x74, 0x1a, 0x69, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x6e, - 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x65, - 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x73, 0x5f, 0x6e, 0x75, - 0x6c, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x4e, 0x75, 0x6c, 0x6c, - 0x22, 0xcf, 0x04, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1b, 0x0a, - 0x09, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, 0x53, 0x0a, 0x14, 0x77, 0x6f, - 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x77, 0x6f, 0x72, 0x6b, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x25, 0x0a, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x12, - 0x21, 0x0a, 0x0c, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, - 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, - 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x49, 0x64, - 0x12, 0x32, 0x0a, 0x15, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6f, 0x77, - 0x6e, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x45, - 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x74, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x48, 0x0a, 0x21, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x6f, 0x69, 0x64, 0x63, 0x5f, 0x61, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x1d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x4f, - 0x69, 0x64, 0x63, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x41, - 0x0a, 0x1d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, - 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, - 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x49, 0x64, 0x22, 0x8a, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x36, 0x0a, - 0x17, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x15, - 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x41, 0x72, - 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x6c, - 0x65, 0x76, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x22, - 0x0e, 0x0a, 0x0c, 0x50, 0x61, 0x72, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, - 0x8b, 0x01, 0x0a, 0x0d, 0x50, 0x61, 0x72, 0x73, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x4c, 0x0a, 0x12, 0x74, 0x65, 0x6d, 0x70, 0x6c, - 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, - 0x72, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, - 0x6c, 0x65, 0x52, 0x11, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, 0x61, 0x72, 0x69, - 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x65, 0x22, 0xa6, 0x02, - 0x0a, 0x0b, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, - 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x53, 0x0a, 0x15, 0x72, 0x69, 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, - 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x52, 0x13, 0x72, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x0f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, - 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x72, - 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0e, 0x76, 0x61, 0x72, 0x69, - 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x12, 0x67, 0x69, - 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, - 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x47, 0x69, 0x74, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x52, 0x10, 0x67, 0x69, 0x74, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x22, 0xc3, 0x01, 0x0a, 0x0c, 0x50, 0x6c, 0x61, 0x6e, 0x43, - 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x33, 0x0a, - 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x2c, - 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x41, - 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x22, 0x41, 0x0a, 0x0c, - 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, 0x08, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, - 0xda, 0x01, 0x0a, 0x0d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x33, 0x0a, - 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, - 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x2c, - 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x67, 0x69, 0x74, 0x41, - 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x22, 0x0f, 0x0a, 0x0d, - 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x8c, 0x02, - 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x06, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, - 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x31, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x73, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x48, 0x00, 0x52, 0x05, 0x70, 0x61, 0x72, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x04, 0x70, - 0x6c, 0x61, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x12, 0x31, 0x0a, 0x05, 0x61, - 0x70, 0x70, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x05, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x12, 0x34, - 0x0a, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x43, 0x61, 0x6e, - 0x63, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x06, 0x63, 0x61, - 0x6e, 0x63, 0x65, 0x6c, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xd1, 0x01, 0x0a, - 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x03, 0x6c, 0x6f, 0x67, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, - 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x48, 0x00, 0x52, 0x03, 0x6c, 0x6f, 0x67, 0x12, - 0x32, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, - 0x73, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x48, 0x00, 0x52, 0x05, 0x70, 0x61, - 0x72, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, - 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x48, 0x00, 0x52, 0x04, - 0x70, 0x6c, 0x61, 0x6e, 0x12, 0x32, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, - 0x72, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x48, - 0x00, 0x52, 0x05, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x2a, 0x3f, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, - 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45, 0x42, 0x55, 0x47, - 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, - 0x57, 0x41, 0x52, 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, - 0x04, 0x2a, 0x3b, 0x0a, 0x0f, 0x41, 0x70, 0x70, 0x53, 0x68, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4c, - 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x4f, 0x57, 0x4e, 0x45, 0x52, 0x10, 0x00, 0x12, - 0x11, 0x0a, 0x0d, 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43, 0x41, 0x54, 0x45, 0x44, - 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, 0x02, 0x2a, 0x37, - 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x00, - 0x12, 0x08, 0x0a, 0x04, 0x53, 0x54, 0x4f, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, - 0x53, 0x54, 0x52, 0x4f, 0x59, 0x10, 0x02, 0x32, 0x49, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x76, 0x69, - 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x07, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, - 0x30, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x76, 0x32, 0x2f, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x73, 0x64, 0x6b, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x64, 0x22, 0x49, 0x0a, 0x14, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x75, + 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xc3, 0x06, + 0x0a, 0x05, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x03, 0x65, + 0x6e, 0x76, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x6e, 0x76, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, 0x29, 0x0a, 0x10, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x53, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, + 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, + 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x72, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x24, 0x0a, 0x04, 0x61, 0x70, 0x70, 0x73, 0x18, + 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x52, 0x04, 0x61, 0x70, 0x70, 0x73, 0x12, 0x16, 0x0a, + 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x21, 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0a, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x3c, 0x0a, 0x1a, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x73, + 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x18, 0x63, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x53, + 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x2f, 0x0a, 0x13, 0x74, 0x72, 0x6f, 0x75, 0x62, 0x6c, + 0x65, 0x73, 0x68, 0x6f, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x12, 0x74, 0x72, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x73, 0x68, 0x6f, 0x6f, + 0x74, 0x69, 0x6e, 0x67, 0x55, 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x6f, 0x74, 0x64, 0x5f, + 0x66, 0x69, 0x6c, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x6f, 0x74, 0x64, + 0x46, 0x69, 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3b, 0x0a, + 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x61, 0x70, 0x70, 0x73, 0x18, 0x14, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, + 0x72, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x41, 0x70, 0x70, 0x73, 0x52, 0x0b, 0x64, + 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x41, 0x70, 0x70, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x73, 0x18, 0x15, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x52, 0x07, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x1a, 0x8d, 0x01, 0x0a, 0x08, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, + 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, + 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x1a, 0x36, 0x0a, 0x08, 0x45, 0x6e, 0x76, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x42, 0x06, 0x0a, 0x04, 0x61, 0x75, 0x74, 0x68, 0x4a, 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x52, + 0x12, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x5f, 0x72, 0x65, + 0x61, 0x64, 0x79, 0x22, 0xc6, 0x01, 0x0a, 0x0b, 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x41, + 0x70, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x76, + 0x73, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x76, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x73, 0x69, + 0x64, 0x65, 0x72, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x77, 0x65, 0x62, 0x5f, 0x74, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x77, 0x65, 0x62, 0x54, + 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x73, 0x68, 0x5f, 0x68, + 0x65, 0x6c, 0x70, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x73, 0x68, + 0x48, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x16, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x66, + 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x68, 0x65, 0x6c, 0x70, 0x65, 0x72, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x70, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, + 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x22, 0x9f, 0x02, 0x0a, + 0x06, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, + 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, + 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, 0x74, 0x61, 0x72, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x73, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x20, 0x0a, 0x0c, 0x72, 0x75, 0x6e, 0x5f, + 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x72, 0x75, 0x6e, 0x4f, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x72, 0x75, + 0x6e, 0x5f, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x6f, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x09, 0x72, 0x75, 0x6e, 0x4f, 0x6e, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x74, 0x69, + 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x53, 0x65, 0x63, 0x6f, + 0x6e, 0x64, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x6f, 0x67, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x6f, 0x67, 0x50, 0x61, 0x74, 0x68, 0x22, 0xb5, + 0x02, 0x0a, 0x03, 0x41, 0x70, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x75, 0x67, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x6c, 0x75, 0x67, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, + 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6f, + 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, + 0x09, 0x73, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x09, 0x73, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x3a, 0x0a, 0x0b, 0x68, + 0x65, 0x61, 0x6c, 0x74, 0x68, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x48, + 0x65, 0x61, 0x6c, 0x74, 0x68, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x0b, 0x68, 0x65, 0x61, 0x6c, + 0x74, 0x68, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x41, 0x0a, 0x0d, 0x73, 0x68, 0x61, 0x72, 0x69, + 0x6e, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, + 0x53, 0x68, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x0c, 0x73, 0x68, + 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x65, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x22, 0x59, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x63, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, + 0x64, 0x22, 0xf1, 0x02, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x61, 0x67, 0x65, 0x6e, + 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, + 0x0a, 0x04, 0x68, 0x69, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x68, 0x69, + 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x64, + 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x43, 0x6f, 0x73, 0x74, 0x1a, 0x69, 0x0a, 0x08, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x73, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x09, 0x73, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x12, 0x17, 0x0a, 0x07, + 0x69, 0x73, 0x5f, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, + 0x73, 0x4e, 0x75, 0x6c, 0x6c, 0x22, 0xcf, 0x04, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, + 0x53, 0x0a, 0x14, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x57, 0x6f, 0x72, 0x6b, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x77, 0x6f, + 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x77, + 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, + 0x77, 0x6e, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x77, 0x6f, 0x72, 0x6b, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x10, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, 0x77, + 0x6e, 0x65, 0x72, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x15, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, + 0x77, 0x6e, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, + 0x0a, 0x10, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x48, 0x0a, 0x21, 0x77, 0x6f, 0x72, + 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x6f, 0x69, 0x64, + 0x63, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x1d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, + 0x77, 0x6e, 0x65, 0x72, 0x4f, 0x69, 0x64, 0x63, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x12, 0x41, 0x0a, 0x1d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x77, 0x6f, 0x72, 0x6b, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x22, 0x8a, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x36, 0x0a, 0x17, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x15, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x12, 0x32, 0x0a, 0x15, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x5f, + 0x6c, 0x6f, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x13, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x4c, + 0x65, 0x76, 0x65, 0x6c, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x61, 0x72, 0x73, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x8b, 0x01, 0x0a, 0x0d, 0x50, 0x61, 0x72, 0x73, 0x65, 0x43, 0x6f, + 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x4c, 0x0a, 0x12, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x56, + 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x11, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, + 0x65, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, + 0x61, 0x64, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x61, 0x64, + 0x6d, 0x65, 0x22, 0xb5, 0x02, 0x0a, 0x0b, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x53, 0x0a, 0x15, 0x72, 0x69, 0x63, 0x68, 0x5f, 0x70, 0x61, + 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x52, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x13, 0x72, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x0f, 0x76, 0x61, + 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, + 0x72, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x0e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, + 0x59, 0x0a, 0x17, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x61, 0x75, 0x74, 0x68, + 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x45, + 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x52, 0x15, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x75, 0x74, + 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x22, 0xc3, 0x01, 0x0a, 0x0c, 0x50, + 0x6c, 0x61, 0x6e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, + 0x72, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, + 0x67, 0x69, 0x74, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, + 0x22, 0x41, 0x0a, 0x0c, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, + 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x22, 0xda, 0x01, 0x0a, 0x0d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x69, 0x63, 0x68, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, + 0x72, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x67, 0x69, 0x74, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, + 0x67, 0x69, 0x74, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, + 0x22, 0x0f, 0x0a, 0x0d, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x8c, 0x02, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, + 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x48, 0x00, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x31, 0x0a, 0x05, + 0x70, 0x61, 0x72, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x05, 0x70, 0x61, 0x72, 0x73, 0x65, 0x12, + 0x2e, 0x0a, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x12, + 0x31, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, + 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x05, 0x61, 0x70, 0x70, + 0x6c, 0x79, 0x12, 0x34, 0x0a, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, + 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, + 0x52, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x22, 0xd1, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, + 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x48, 0x00, 0x52, 0x03, + 0x6c, 0x6f, 0x67, 0x12, 0x32, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, + 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x48, 0x00, + 0x52, 0x05, 0x70, 0x61, 0x72, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, + 0x48, 0x00, 0x52, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x12, 0x32, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x6c, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x6f, 0x6d, 0x70, 0x6c, + 0x65, 0x74, 0x65, 0x48, 0x00, 0x52, 0x05, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x42, 0x06, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x2a, 0x3f, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, + 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, + 0x45, 0x42, 0x55, 0x47, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, + 0x12, 0x08, 0x0a, 0x04, 0x57, 0x41, 0x52, 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x10, 0x04, 0x2a, 0x3b, 0x0a, 0x0f, 0x41, 0x70, 0x70, 0x53, 0x68, 0x61, 0x72, + 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x4f, 0x57, 0x4e, 0x45, + 0x52, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43, + 0x41, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, + 0x10, 0x02, 0x2a, 0x37, 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x54, 0x41, + 0x52, 0x54, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x54, 0x4f, 0x50, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x44, 0x45, 0x53, 0x54, 0x52, 0x4f, 0x59, 0x10, 0x02, 0x32, 0x49, 0x0a, 0x0b, 0x50, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x07, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, + 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x73, + 0x64, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2887,7 +2888,7 @@ var file_provisionersdk_proto_provisioner_proto_goTypes = []interface{}{ (*VariableValue)(nil), // 8: provisioner.VariableValue (*Log)(nil), // 9: provisioner.Log (*InstanceIdentityAuth)(nil), // 10: provisioner.InstanceIdentityAuth - (*GitAuthProvider)(nil), // 11: provisioner.GitAuthProvider + (*ExternalAuthProvider)(nil), // 11: provisioner.ExternalAuthProvider (*Agent)(nil), // 12: provisioner.Agent (*DisplayApps)(nil), // 13: provisioner.DisplayApps (*Script)(nil), // 14: provisioner.Script @@ -2926,7 +2927,7 @@ var file_provisionersdk_proto_provisioner_proto_depIdxs = []int32{ 18, // 13: provisioner.PlanRequest.metadata:type_name -> provisioner.Metadata 7, // 14: provisioner.PlanRequest.rich_parameter_values:type_name -> provisioner.RichParameterValue 8, // 15: provisioner.PlanRequest.variable_values:type_name -> provisioner.VariableValue - 11, // 16: provisioner.PlanRequest.git_auth_providers:type_name -> provisioner.GitAuthProvider + 11, // 16: provisioner.PlanRequest.external_auth_providers:type_name -> provisioner.ExternalAuthProvider 17, // 17: provisioner.PlanComplete.resources:type_name -> provisioner.Resource 6, // 18: provisioner.PlanComplete.parameters:type_name -> provisioner.RichParameter 18, // 19: provisioner.ApplyRequest.metadata:type_name -> provisioner.Metadata @@ -3053,7 +3054,7 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GitAuthProvider); i { + switch v := v.(*ExternalAuthProvider); i { case 0: return &v.state case 1: diff --git a/provisionersdk/proto/provisioner.proto b/provisionersdk/proto/provisioner.proto index 0acf000353b69..24e0c87301767 100644 --- a/provisionersdk/proto/provisioner.proto +++ b/provisionersdk/proto/provisioner.proto @@ -81,7 +81,7 @@ message InstanceIdentityAuth { string instance_id = 1; } -message GitAuthProvider { +message ExternalAuthProvider { string id = 1; string access_token = 2; } @@ -237,7 +237,7 @@ message PlanRequest { Metadata metadata = 1; repeated RichParameterValue rich_parameter_values = 2; repeated VariableValue variable_values = 3; - repeated GitAuthProvider git_auth_providers = 4; + repeated ExternalAuthProvider external_auth_providers = 4; } // PlanComplete indicates a request to plan completed. From 7e447a56bd0f4efcb45c346dfc9822cdade71e0b Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 18:25:48 +0000 Subject: [PATCH 11/16] Fix gen --- Makefile | 3 +-- site/e2e/provisionerGenerated.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 67e506851d583..d606832fd1fad 100644 --- a/Makefile +++ b/Makefile @@ -542,12 +542,11 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./coders cd site pnpm run format:types ./src/api/typesGenerated.ts -site/e2e/provisionerGenerated.ts: +site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go cd site ../scripts/pnpm_install.sh pnpm run gen:provisioner - examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates) go run ./scripts/examplegen/main.go > examples/examples.gen.json diff --git a/site/e2e/provisionerGenerated.ts b/site/e2e/provisionerGenerated.ts index abd81ad7aacc4..1ade0a9e6b2cb 100644 --- a/site/e2e/provisionerGenerated.ts +++ b/site/e2e/provisionerGenerated.ts @@ -94,7 +94,7 @@ export interface InstanceIdentityAuth { instanceId: string; } -export interface GitAuthProvider { +export interface ExternalAuthProvider { id: string; accessToken: string; } @@ -241,7 +241,7 @@ export interface PlanRequest { metadata: Metadata | undefined; richParameterValues: RichParameterValue[]; variableValues: VariableValue[]; - gitAuthProviders: GitAuthProvider[]; + externalAuthProviders: ExternalAuthProvider[]; } /** PlanComplete indicates a request to plan completed. */ @@ -455,9 +455,9 @@ export const InstanceIdentityAuth = { }, }; -export const GitAuthProvider = { +export const ExternalAuthProvider = { encode( - message: GitAuthProvider, + message: ExternalAuthProvider, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { if (message.id !== "") { @@ -838,8 +838,8 @@ export const PlanRequest = { for (const v of message.variableValues) { VariableValue.encode(v!, writer.uint32(26).fork()).ldelim(); } - for (const v of message.gitAuthProviders) { - GitAuthProvider.encode(v!, writer.uint32(34).fork()).ldelim(); + for (const v of message.externalAuthProviders) { + ExternalAuthProvider.encode(v!, writer.uint32(34).fork()).ldelim(); } return writer; }, From d57e91fc5ed87744120562cf9eab62f4d1d2d2b3 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 18:37:15 +0000 Subject: [PATCH 12/16] Fix test --- coderd/provisionerdserver/provisionerdserver_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 04ffd64e4a976..144a43214cc95 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -923,8 +923,8 @@ func TestCompleteJob(t *testing.T) { Name: "hello", Type: "aws_instance", }}, - StopResources: []*sdkproto.Resource{}, - GitAuthProviders: []string{"github"}, + StopResources: []*sdkproto.Resource{}, + ExternalAuthProviders: []string{"github"}, }, }, }) @@ -977,8 +977,8 @@ func TestCompleteJob(t *testing.T) { Name: "hello", Type: "aws_instance", }}, - StopResources: []*sdkproto.Resource{}, - GitAuthProviders: []string{"github"}, + StopResources: []*sdkproto.Resource{}, + ExternalAuthProviders: []string{"github"}, }, }, }) From 1d11cd953dbf995ca11f03bf74dd9edec6fe9431 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 18:42:06 +0000 Subject: [PATCH 13/16] Fix syntax error --- coderd/provisionerdserver/provisionerdserver_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 144a43214cc95..9f6c045184d3b 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -288,7 +288,7 @@ func TestAcquireJob(t *testing.T) { Value: "second_value", }, }, - GitAuthProviders: []*sdkproto.GitAuthProvider{{ + ExternalAuthProviders: []*sdkproto.ExternalAuthProvider{{ Id: gitAuthProvider, AccessToken: "access_token", }}, From 9f2cb2a59c730096f72111e0b5949ef933d7397b Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 18:49:55 +0000 Subject: [PATCH 14/16] Fix test --- coderd/provisionerdserver/provisionerdserver.go | 2 +- coderd/provisionerdserver/provisionerdserver_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coderd/provisionerdserver/provisionerdserver.go b/coderd/provisionerdserver/provisionerdserver.go index 0fd20465236dd..2c063660db97b 100644 --- a/coderd/provisionerdserver/provisionerdserver.go +++ b/coderd/provisionerdserver/provisionerdserver.go @@ -1038,7 +1038,7 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) } if !contains { completedError = sql.NullString{ - String: fmt.Sprintf("external provider %q is not configured", externalAuthProvider), + String: fmt.Sprintf("external auth provider %q is not configured", externalAuthProvider), Valid: true, } break diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 9f6c045184d3b..7b380b6426974 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -933,7 +933,7 @@ func TestCompleteJob(t *testing.T) { completeJob() job, err = db.GetProvisionerJobByID(ctx, job.ID) require.NoError(t, err) - require.Contains(t, job.Error.String, `git auth provider "github" is not configured`) + require.Contains(t, job.Error.String, `external auth provider "github" is not configured`) }) t.Run("TemplateImport_WithGitAuth", func(t *testing.T) { From 063d50b27f9f19b144facae8553adc5e1e68fb31 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 18:55:19 +0000 Subject: [PATCH 15/16] Another syntax error --- provisioner/terraform/provision_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioner/terraform/provision_test.go b/provisioner/terraform/provision_test.go index 254ddec45b5e6..c85604a86cdb1 100644 --- a/provisioner/terraform/provision_test.go +++ b/provisioner/terraform/provision_test.go @@ -549,7 +549,7 @@ func TestProvision(t *testing.T) { `, }, Request: &proto.PlanRequest{ - GitAuthProviders: []*proto.GitAuthProvider{{ + ExternalAuthProviders: []*proto.ExternalAuthProvider{{ Id: "github", AccessToken: "some-value", }}, From e2862fc1cc1fd6bca2b20bf5ffe596f21d0431a6 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 29 Sep 2023 19:04:15 +0000 Subject: [PATCH 16/16] Fix migrations --- .../migrations/000158_external_auth.down.sql | 25 +++++++++++++++++++ coderd/database/migrations/migrate_test.go | 2 +- docs/admin/encryption.md | 4 +-- enterprise/dbcrypt/cliutil.go | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/coderd/database/migrations/000158_external_auth.down.sql b/coderd/database/migrations/000158_external_auth.down.sql index e69de29bb2d1d..427de53c95fb2 100644 --- a/coderd/database/migrations/000158_external_auth.down.sql +++ b/coderd/database/migrations/000158_external_auth.down.sql @@ -0,0 +1,25 @@ +BEGIN; + +ALTER TABLE template_versions RENAME COLUMN external_auth_providers TO git_auth_providers; + +ALTER TABLE external_auth_links RENAME TO git_auth_links; + +DROP VIEW template_version_with_user; +-- If you need to update this view, put 'DROP VIEW template_version_with_user;' before this. +CREATE VIEW + template_version_with_user +AS +SELECT + template_versions.*, + coalesce(visible_users.avatar_url, '') AS created_by_avatar_url, + coalesce(visible_users.username, '') AS created_by_username +FROM + template_versions + LEFT JOIN + visible_users + ON + template_versions.created_by = visible_users.id; + +COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.'; + +COMMIT; diff --git a/coderd/database/migrations/migrate_test.go b/coderd/database/migrations/migrate_test.go index b512811f2ab18..c475c1fa5f026 100644 --- a/coderd/database/migrations/migrate_test.go +++ b/coderd/database/migrations/migrate_test.go @@ -259,7 +259,7 @@ func TestMigrateUpWithFixtures(t *testing.T) { // but we should eventually add fixtures for them. ignoredTablesForStats := []string{ "audit_logs", - "git_auth_links", + "external_auth_links", "group_members", "licenses", "replicas", diff --git a/docs/admin/encryption.md b/docs/admin/encryption.md index 03228b68a0268..38c321120e00e 100644 --- a/docs/admin/encryption.md +++ b/docs/admin/encryption.md @@ -20,8 +20,8 @@ The following database fields are currently encrypted: - `user_links.oauth_access_token` - `user_links.oauth_refresh_token` -- `git_auth_links.oauth_access_token` -- `git_auth_links.oauth_refresh_token` +- `external_auth_links.oauth_access_token` +- `external_auth_links.oauth_refresh_token` Additional database fields may be encrypted in the future. diff --git a/enterprise/dbcrypt/cliutil.go b/enterprise/dbcrypt/cliutil.go index 98a37df5785bb..8ffc8347e69b2 100644 --- a/enterprise/dbcrypt/cliutil.go +++ b/enterprise/dbcrypt/cliutil.go @@ -177,7 +177,7 @@ BEGIN; DELETE FROM user_links WHERE oauth_access_token_key_id IS NOT NULL OR oauth_refresh_token_key_id IS NOT NULL; -DELETE FROM git_auth_links +DELETE FROM external_auth_links WHERE oauth_access_token_key_id IS NOT NULL OR oauth_refresh_token_key_id IS NOT NULL; COMMIT;