From 6653b245bc32956254d0abcdf226485bb7ccea0a Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 13:36:44 +0100 Subject: [PATCH 01/17] Update go.mod --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6e4cb6ae3ee28..fdc5b4946315a 100644 --- a/go.mod +++ b/go.mod @@ -96,7 +96,7 @@ require ( github.com/coder/flog v1.1.0 github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 github.com/coder/retry v1.5.1 - github.com/coder/terraform-provider-coder v0.12.2 + github.com/coder/terraform-provider-coder v0.13.0 github.com/coder/wgtunnel v0.1.13-0.20231127054351-578bfff9b92a github.com/coreos/go-oidc/v3 v3.9.0 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index 5fc9480461041..ab18418c9db40 100644 --- a/go.sum +++ b/go.sum @@ -195,8 +195,8 @@ github.com/coder/ssh v0.0.0-20231128192721-70855dedb788 h1:YoUSJ19E8AtuUFVYBpXuO github.com/coder/ssh v0.0.0-20231128192721-70855dedb788/go.mod h1:aGQbuCLyhRLMzZF067xc84Lh7JDs1FKwCmF1Crl9dxQ= github.com/coder/tailscale v1.1.1-0.20231205095743-61c97bad8c8b h1:ut/aL6oI8TjGdg4JI8+bKB9w5j73intbe0dJAmcmYyQ= github.com/coder/tailscale v1.1.1-0.20231205095743-61c97bad8c8b/go.mod h1:L8tPrwSi31RAMEMV8rjb0vYTGs7rXt8rAHbqY/p41j4= -github.com/coder/terraform-provider-coder v0.12.2 h1:KsnJLHyTtELvV1Rzkm75iCQ7npXjL0KcoU3NTreagZU= -github.com/coder/terraform-provider-coder v0.12.2/go.mod h1:+BHer8AX5Y0QqZS9viau+ZkDTaOCOE3ga1lx1QIJDrk= +github.com/coder/terraform-provider-coder v0.13.0 h1:MjW7O+THAiqIYcxyiuBoGbFEduqgjp7tUZhSkiwGxwo= +github.com/coder/terraform-provider-coder v0.13.0/go.mod h1:g2bDO+IkYqMSMxMdziOlyZsVh5BP/8wBIDvhIkSJ4rg= github.com/coder/wgtunnel v0.1.13-0.20231127054351-578bfff9b92a h1:KhR9LUVllMZ+e9lhubZ1HNrtJDgH5YLoTvpKwmrGag4= github.com/coder/wgtunnel v0.1.13-0.20231127054351-578bfff9b92a/go.mod h1:QzfptVUdEO+XbkzMKx1kw13i9wwpJlfI1RrZ6SNZ0hA= github.com/coder/wireguard-go v0.0.0-20230807234434-d825b45ccbf5 h1:eDk/42Kj4xN4yfE504LsvcFEo3dWUiCOaBiWJ2uIH2A= From 2b239ab390abd0e1f3b676d94e70b5ef2faeb8b3 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 13:56:38 +0100 Subject: [PATCH 02/17] Proto changes --- provisionersdk/proto/provisioner.pb.go | 257 +++++++++++++------------ provisionersdk/proto/provisioner.proto | 1 + site/e2e/provisionerGenerated.ts | 4 + 3 files changed, 139 insertions(+), 123 deletions(-) diff --git a/provisionersdk/proto/provisioner.pb.go b/provisionersdk/proto/provisioner.pb.go index 420319a661aa9..50ad466d40e26 100644 --- a/provisionersdk/proto/provisioner.pb.go +++ b/provisionersdk/proto/provisioner.pb.go @@ -1565,6 +1565,7 @@ type Metadata struct { WorkspaceOwnerOidcAccessToken string `protobuf:"bytes,10,opt,name=workspace_owner_oidc_access_token,json=workspaceOwnerOidcAccessToken,proto3" json:"workspace_owner_oidc_access_token,omitempty"` WorkspaceOwnerSessionToken string `protobuf:"bytes,11,opt,name=workspace_owner_session_token,json=workspaceOwnerSessionToken,proto3" json:"workspace_owner_session_token,omitempty"` TemplateId string `protobuf:"bytes,12,opt,name=template_id,json=templateId,proto3" json:"template_id,omitempty"` + WorkspaceOwnerName string `protobuf:"bytes,13,opt,name=workspace_owner_name,json=workspaceOwnerName,proto3" json:"workspace_owner_name,omitempty"` } func (x *Metadata) Reset() { @@ -1683,6 +1684,13 @@ func (x *Metadata) GetTemplateId() string { return "" } +func (x *Metadata) GetWorkspaceOwnerName() string { + if x != nil { + return x.WorkspaceOwnerName + } + return "" +} + // Config represents execution configuration shared by all subsequent requests in the Session type Config struct { state protoimpl.MessageState @@ -2772,7 +2780,7 @@ var file_provisionersdk_proto_provisioner_proto_rawDesc = []byte{ 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, + 0x06, 0x69, 0x73, 0x4e, 0x75, 0x6c, 0x6c, 0x22, 0x81, 0x05, 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, @@ -2809,128 +2817,131 @@ var file_provisionersdk_proto_provisioner_proto_rawDesc = []byte{ 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, 0xcd, 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, 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, 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, - 0xe4, 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, 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, 0x05, 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, 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, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x30, 0x0a, 0x14, 0x77, 0x6f, 0x72, + 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 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, 0xcd, + 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, 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, 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, 0xe4, 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, 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, 0x05, 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, 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 ( diff --git a/provisionersdk/proto/provisioner.proto b/provisionersdk/proto/provisioner.proto index b2537e80d56fe..b68c5c8837d8f 100644 --- a/provisionersdk/proto/provisioner.proto +++ b/provisionersdk/proto/provisioner.proto @@ -216,6 +216,7 @@ message Metadata { string workspace_owner_oidc_access_token = 10; string workspace_owner_session_token = 11; string template_id = 12; + string workspace_owner_name = 13; } // Config represents execution configuration shared by all subsequent requests in the Session diff --git a/site/e2e/provisionerGenerated.ts b/site/e2e/provisionerGenerated.ts index 752685ec9739c..e96df52477b32 100644 --- a/site/e2e/provisionerGenerated.ts +++ b/site/e2e/provisionerGenerated.ts @@ -221,6 +221,7 @@ export interface Metadata { workspaceOwnerOidcAccessToken: string; workspaceOwnerSessionToken: string; templateId: string; + workspaceOwnerName: string; } /** Config represents execution configuration shared by all subsequent requests in the Session */ @@ -796,6 +797,9 @@ export const Metadata = { if (message.templateId !== "") { writer.uint32(98).string(message.templateId); } + if (message.workspaceOwnerName !== "") { + writer.uint32(106).string(message.workspaceOwnerName); + } return writer; }, }; From 7fd057710006f28158573e2e0c332cf50eecaa57 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 15:22:09 +0100 Subject: [PATCH 03/17] WIP --- coderd/database/db2sdk/db2sdk.go | 11 +++++++++-- coderd/users.go | 2 +- codersdk/users.go | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/coderd/database/db2sdk/db2sdk.go b/coderd/database/db2sdk/db2sdk.go index 6707b72a89e4b..6e57fbbc4742f 100644 --- a/coderd/database/db2sdk/db2sdk.go +++ b/coderd/database/db2sdk/db2sdk.go @@ -116,10 +116,17 @@ func TemplateVersionParameter(param database.TemplateVersionParameter) (codersdk }, nil } +func UserProfile(user database.User, organizationIDs []uuid.UUID) codersdk.User { + u := User(user, organizationIDs) + u.Name = "TODO" + return u +} + func User(user database.User, organizationIDs []uuid.UUID) codersdk.User { convertedUser := codersdk.User{ - ID: user.ID, - Email: user.Email, + ID: user.ID, + Email: user.Email, + // Name property is visible only for the account owner. CreatedAt: user.CreatedAt, LastSeenAt: user.LastSeenAt, Username: user.Username, diff --git a/coderd/users.go b/coderd/users.go index 4cfa7e7ead877..a663b70d88bea 100644 --- a/coderd/users.go +++ b/coderd/users.go @@ -670,7 +670,7 @@ func (api *API) putUserProfile(rw http.ResponseWriter, r *http.Request) { return } - httpapi.Write(ctx, rw, http.StatusOK, db2sdk.User(updatedUserProfile, organizationIDs)) + httpapi.Write(ctx, rw, http.StatusOK, db2sdk.UserProfile(updatedUserProfile, organizationIDs)) } // @Summary Suspend user account diff --git a/codersdk/users.go b/codersdk/users.go index 7b6492c811b25..9af8956d978fb 100644 --- a/codersdk/users.go +++ b/codersdk/users.go @@ -46,6 +46,7 @@ type MinimalUser struct { type User struct { ID uuid.UUID `json:"id" validate:"required" table:"id" format:"uuid"` Username string `json:"username" validate:"required" table:"username,default_sort"` + Name string `json:"name"` Email string `json:"email" validate:"required" table:"email" format:"email"` CreatedAt time.Time `json:"created_at" validate:"required" table:"created at" format:"date-time"` LastSeenAt time.Time `json:"last_seen_at" format:"date-time"` @@ -91,6 +92,7 @@ type CreateUserRequest struct { type UpdateUserProfileRequest struct { Username string `json:"username" validate:"required,username"` + Name string `json:"name"` } type UpdateUserAppearanceSettingsRequest struct { From 2defb89366596d66407bdc750cba694cb77ca611 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 16:05:23 +0100 Subject: [PATCH 04/17] make gen --- coderd/apidoc/docs.go | 9 +++++ coderd/apidoc/swagger.json | 9 +++++ coderd/database/dump.sql | 5 ++- .../migrations/000185_add_user_name.down.sql | 1 + .../migrations/000185_add_user_name.up.sql | 4 ++ coderd/database/modelqueries.go | 1 + coderd/database/models.go | 2 + coderd/database/queries.sql.go | 40 +++++++++++++------ coderd/httpapi/websocket.go | 3 +- coderd/workspaceagents_test.go | 2 +- docs/admin/audit-logs.md | 2 +- docs/api/audit.md | 1 + docs/api/enterprise.md | 13 ++++++ docs/api/schemas.md | 12 ++++++ docs/api/users.md | 11 +++++ enterprise/audit/table.go | 1 + site/src/api/typesGenerated.ts | 2 + 17 files changed, 101 insertions(+), 17 deletions(-) create mode 100644 coderd/database/migrations/000185_add_user_name.down.sql create mode 100644 coderd/database/migrations/000185_add_user_name.up.sql diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index bb29511d86a1b..f3531eccced53 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -11076,6 +11076,9 @@ const docTemplate = `{ "login_type": { "$ref": "#/definitions/codersdk.LoginType" }, + "name": { + "type": "string" + }, "organization_ids": { "type": "array", "items": { @@ -11482,6 +11485,9 @@ const docTemplate = `{ "username" ], "properties": { + "name": { + "type": "string" + }, "username": { "type": "string" } @@ -11580,6 +11586,9 @@ const docTemplate = `{ "login_type": { "$ref": "#/definitions/codersdk.LoginType" }, + "name": { + "type": "string" + }, "organization_ids": { "type": "array", "items": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 8ccff51017ee1..13f45447599df 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -10015,6 +10015,9 @@ "login_type": { "$ref": "#/definitions/codersdk.LoginType" }, + "name": { + "type": "string" + }, "organization_ids": { "type": "array", "items": { @@ -10389,6 +10392,9 @@ "type": "object", "required": ["username"], "properties": { + "name": { + "type": "string" + }, "username": { "type": "string" } @@ -10480,6 +10486,9 @@ "login_type": { "$ref": "#/definitions/codersdk.LoginType" }, + "name": { + "type": "string" + }, "organization_ids": { "type": "array", "items": { diff --git a/coderd/database/dump.sql b/coderd/database/dump.sql index ee0d9f92f42f2..f9d1e4311b2b2 100644 --- a/coderd/database/dump.sql +++ b/coderd/database/dump.sql @@ -774,13 +774,16 @@ CREATE TABLE users ( deleted boolean DEFAULT false NOT NULL, last_seen_at timestamp without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL, quiet_hours_schedule text DEFAULT ''::text NOT NULL, - theme_preference text DEFAULT ''::text NOT NULL + theme_preference text DEFAULT ''::text NOT NULL, + name text DEFAULT ''::text NOT NULL ); COMMENT ON COLUMN users.quiet_hours_schedule IS 'Daily (!) cron schedule (with optional CRON_TZ) signifying the start of the user''s quiet hours. If empty, the default quiet hours on the instance is used instead.'; COMMENT ON COLUMN users.theme_preference IS '"" can be interpreted as "the user does not care", falling back to the default theme'; +COMMENT ON COLUMN users.name IS 'Name of the Coder user'; + CREATE VIEW visible_users AS SELECT users.id, users.username, diff --git a/coderd/database/migrations/000185_add_user_name.down.sql b/coderd/database/migrations/000185_add_user_name.down.sql new file mode 100644 index 0000000000000..1592aac27486d --- /dev/null +++ b/coderd/database/migrations/000185_add_user_name.down.sql @@ -0,0 +1 @@ +ALTER TABLE users DROP COLUMN name; diff --git a/coderd/database/migrations/000185_add_user_name.up.sql b/coderd/database/migrations/000185_add_user_name.up.sql new file mode 100644 index 0000000000000..01ca0ea374f3b --- /dev/null +++ b/coderd/database/migrations/000185_add_user_name.up.sql @@ -0,0 +1,4 @@ +ALTER TABLE users ADD COLUMN name text NOT NULL DEFAULT ''; + +COMMENT ON COLUMN users.name IS 'Name of the Coder user'; + diff --git a/coderd/database/modelqueries.go b/coderd/database/modelqueries.go index 81375e66c88c5..7443f1231a848 100644 --- a/coderd/database/modelqueries.go +++ b/coderd/database/modelqueries.go @@ -318,6 +318,7 @@ func (q *sqlQuerier) GetAuthorizedUsers(ctx context.Context, arg GetUsersParams, &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, &i.Count, ); err != nil { return nil, err diff --git a/coderd/database/models.go b/coderd/database/models.go index cf9d8caaaea48..5308f88b35a79 100644 --- a/coderd/database/models.go +++ b/coderd/database/models.go @@ -2144,6 +2144,8 @@ type User struct { QuietHoursSchedule string `db:"quiet_hours_schedule" json:"quiet_hours_schedule"` // "" can be interpreted as "the user does not care", falling back to the default theme ThemePreference string `db:"theme_preference" json:"theme_preference"` + // Name of the Coder user + Name string `db:"name" json:"name"` } type UserLink struct { diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index f9287915d5438..9e3967b46c09d 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -1300,7 +1300,7 @@ func (q *sqlQuerier) DeleteGroupMembersByOrgAndUser(ctx context.Context, arg Del const getGroupMembers = `-- name: GetGroupMembers :many SELECT - users.id, users.email, users.username, users.hashed_password, users.created_at, users.updated_at, users.status, users.rbac_roles, users.login_type, users.avatar_url, users.deleted, users.last_seen_at, users.quiet_hours_schedule, users.theme_preference + users.id, users.email, users.username, users.hashed_password, users.created_at, users.updated_at, users.status, users.rbac_roles, users.login_type, users.avatar_url, users.deleted, users.last_seen_at, users.quiet_hours_schedule, users.theme_preference, users.name FROM users LEFT JOIN @@ -1348,6 +1348,7 @@ func (q *sqlQuerier) GetGroupMembers(ctx context.Context, groupID uuid.UUID) ([] &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ); err != nil { return nil, err } @@ -7333,7 +7334,7 @@ func (q *sqlQuerier) GetAuthorizationUserRoles(ctx context.Context, userID uuid. const getUserByEmailOrUsername = `-- name: GetUserByEmailOrUsername :one SELECT - id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference + id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name FROM users WHERE @@ -7366,13 +7367,14 @@ func (q *sqlQuerier) GetUserByEmailOrUsername(ctx context.Context, arg GetUserBy &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } const getUserByID = `-- name: GetUserByID :one SELECT - id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference + id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name FROM users WHERE @@ -7399,6 +7401,7 @@ func (q *sqlQuerier) GetUserByID(ctx context.Context, id uuid.UUID) (User, error &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -7421,7 +7424,7 @@ func (q *sqlQuerier) GetUserCount(ctx context.Context) (int64, error) { const getUsers = `-- name: GetUsers :many SELECT - id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, COUNT(*) OVER() AS count + id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name, COUNT(*) OVER() AS count FROM users WHERE @@ -7519,6 +7522,7 @@ type GetUsersRow struct { LastSeenAt time.Time `db:"last_seen_at" json:"last_seen_at"` QuietHoursSchedule string `db:"quiet_hours_schedule" json:"quiet_hours_schedule"` ThemePreference string `db:"theme_preference" json:"theme_preference"` + Name string `db:"name" json:"name"` Count int64 `db:"count" json:"count"` } @@ -7556,6 +7560,7 @@ func (q *sqlQuerier) GetUsers(ctx context.Context, arg GetUsersParams) ([]GetUse &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, &i.Count, ); err != nil { return nil, err @@ -7572,7 +7577,7 @@ func (q *sqlQuerier) GetUsers(ctx context.Context, arg GetUsersParams) ([]GetUse } const getUsersByIDs = `-- name: GetUsersByIDs :many -SELECT id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference FROM users WHERE id = ANY($1 :: uuid [ ]) +SELECT id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name FROM users WHERE id = ANY($1 :: uuid [ ]) ` // This shouldn't check for deleted, because it's frequently used @@ -7602,6 +7607,7 @@ func (q *sqlQuerier) GetUsersByIDs(ctx context.Context, ids []uuid.UUID) ([]User &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ); err != nil { return nil, err } @@ -7629,7 +7635,7 @@ INSERT INTO login_type ) VALUES - ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference + ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type InsertUserParams struct { @@ -7670,6 +7676,7 @@ func (q *sqlQuerier) InsertUser(ctx context.Context, arg InsertUserParams) (User &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -7728,7 +7735,7 @@ SET updated_at = $3 WHERE id = $1 -RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference +RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type UpdateUserAppearanceSettingsParams struct { @@ -7755,6 +7762,7 @@ func (q *sqlQuerier) UpdateUserAppearanceSettings(ctx context.Context, arg Updat &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -7804,7 +7812,7 @@ SET last_seen_at = $2, updated_at = $3 WHERE - id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference + id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type UpdateUserLastSeenAtParams struct { @@ -7831,6 +7839,7 @@ func (q *sqlQuerier) UpdateUserLastSeenAt(ctx context.Context, arg UpdateUserLas &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -7848,7 +7857,7 @@ SET '':: bytea END WHERE - id = $2 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference + id = $2 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type UpdateUserLoginTypeParams struct { @@ -7874,6 +7883,7 @@ func (q *sqlQuerier) UpdateUserLoginType(ctx context.Context, arg UpdateUserLogi &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -7888,7 +7898,7 @@ SET updated_at = $5 WHERE id = $1 -RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference +RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type UpdateUserProfileParams struct { @@ -7923,6 +7933,7 @@ func (q *sqlQuerier) UpdateUserProfile(ctx context.Context, arg UpdateUserProfil &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -7934,7 +7945,7 @@ SET quiet_hours_schedule = $2 WHERE id = $1 -RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference +RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type UpdateUserQuietHoursScheduleParams struct { @@ -7960,6 +7971,7 @@ func (q *sqlQuerier) UpdateUserQuietHoursSchedule(ctx context.Context, arg Updat &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -7972,7 +7984,7 @@ SET rbac_roles = ARRAY(SELECT DISTINCT UNNEST($1 :: text[])) WHERE id = $2 -RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference +RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type UpdateUserRolesParams struct { @@ -7998,6 +8010,7 @@ func (q *sqlQuerier) UpdateUserRoles(ctx context.Context, arg UpdateUserRolesPar &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } @@ -8009,7 +8022,7 @@ SET status = $2, updated_at = $3 WHERE - id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference + id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name ` type UpdateUserStatusParams struct { @@ -8036,6 +8049,7 @@ func (q *sqlQuerier) UpdateUserStatus(ctx context.Context, arg UpdateUserStatusP &i.LastSeenAt, &i.QuietHoursSchedule, &i.ThemePreference, + &i.Name, ) return i, err } diff --git a/coderd/httpapi/websocket.go b/coderd/httpapi/websocket.go index ad3b4b277dff4..629dcac8131f3 100644 --- a/coderd/httpapi/websocket.go +++ b/coderd/httpapi/websocket.go @@ -4,8 +4,9 @@ import ( "context" "time" - "cdr.dev/slog" "nhooyr.io/websocket" + + "cdr.dev/slog" ) // Heartbeat loops to ping a WebSocket to keep it alive. diff --git a/coderd/workspaceagents_test.go b/coderd/workspaceagents_test.go index 77fb6b1976ab9..0d620c991e6dd 100644 --- a/coderd/workspaceagents_test.go +++ b/coderd/workspaceagents_test.go @@ -1626,7 +1626,7 @@ func TestWorkspaceAgentExternalAuthListen(t *testing.T) { cancel() // We expect only 1 // In a failed test, you will likely see 9, as the last one - // gets cancelled. + // gets canceled. require.Equal(t, 1, validateCalls, "validate calls duplicated on same token") }) } diff --git a/docs/admin/audit-logs.md b/docs/admin/audit-logs.md index 71d233e8f9546..c09c829f3b765 100644 --- a/docs/admin/audit-logs.md +++ b/docs/admin/audit-logs.md @@ -18,7 +18,7 @@ We track the following resources: | 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
autostart_block_days_of_weektrue
autostop_requirement_days_of_weektrue
autostop_requirement_weekstrue
created_atfalse
created_bytrue
created_by_avatar_urlfalse
created_by_usernamefalse
default_ttltrue
deletedfalse
deprecatedtrue
descriptiontrue
display_nametrue
failure_ttltrue
group_acltrue
icontrue
idtrue
max_ttltrue
nametrue
organization_idfalse
provisionertrue
require_active_versiontrue
time_til_dormanttrue
time_til_dormant_autodeletetrue
updated_atfalse
use_max_ttltrue
user_acltrue
| | TemplateVersion
create, write |
FieldTracked
archivedtrue
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
theme_preferencefalse
updated_atfalse
usernametrue
| +| User
create, write, delete |
FieldTracked
avatar_urlfalse
created_atfalse
deletedtrue
emailtrue
hashed_passwordtrue
idtrue
last_seen_atfalse
login_typetrue
nametrue
quiet_hours_scheduletrue
rbac_rolestrue
statustrue
theme_preferencefalse
updated_atfalse
usernametrue
| | Workspace
create, write, delete |
FieldTracked
automatic_updatestrue
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
| | WorkspaceProxy
|
FieldTracked
created_attrue
deletedfalse
derp_enabledtrue
derp_onlytrue
display_nametrue
icontrue
idtrue
nametrue
region_idtrue
token_hashed_secrettrue
updated_atfalse
urltrue
versiontrue
wildcard_hostnametrue
| diff --git a/docs/api/audit.md b/docs/api/audit.md index 7cad786be105e..ba725ed79bbcc 100644 --- a/docs/api/audit.md +++ b/docs/api/audit.md @@ -63,6 +63,7 @@ curl -X GET http://coder-server:8080/api/v2/audit \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { diff --git a/docs/api/enterprise.md b/docs/api/enterprise.md index 11f463ad4e4f1..956bb75653dca 100644 --- a/docs/api/enterprise.md +++ b/docs/api/enterprise.md @@ -188,6 +188,7 @@ curl -X GET http://coder-server:8080/api/v2/groups/{group} \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -251,6 +252,7 @@ curl -X DELETE http://coder-server:8080/api/v2/groups/{group} \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -329,6 +331,7 @@ curl -X PATCH http://coder-server:8080/api/v2/groups/{group} \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -813,6 +816,7 @@ curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/groups "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -856,6 +860,7 @@ Status Code **200** | `»» id` | string(uuid) | true | | | | `»» last_seen_at` | string(date-time) | false | | | | `»» login_type` | [codersdk.LoginType](schemas.md#codersdklogintype) | false | | | +| `»» name` | string | false | | | | `»» organization_ids` | array | false | | | | `»» roles` | array | false | | | | `»»» display_name` | string | false | | | @@ -934,6 +939,7 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/groups "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -998,6 +1004,7 @@ curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/groups/ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1361,6 +1368,7 @@ curl -X PATCH http://coder-server:8080/api/v2/scim/v2/Users/{id} \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1414,6 +1422,7 @@ curl -X GET http://coder-server:8080/api/v2/templates/{template}/acl \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "role": "admin", "roles": [ @@ -1448,6 +1457,7 @@ Status Code **200** | `» id` | string(uuid) | true | | | | `» last_seen_at` | string(date-time) | false | | | | `» login_type` | [codersdk.LoginType](schemas.md#codersdklogintype) | false | | | +| `» name` | string | false | | | | `» organization_ids` | array | false | | | | `» role` | [codersdk.TemplateRole](schemas.md#codersdktemplaterole) | false | | | | `» roles` | array | false | | | @@ -1574,6 +1584,7 @@ curl -X GET http://coder-server:8080/api/v2/templates/{template}/acl/available \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1600,6 +1611,7 @@ curl -X GET http://coder-server:8080/api/v2/templates/{template}/acl/available \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1640,6 +1652,7 @@ Status Code **200** | `»»» id` | string(uuid) | true | | | | `»»» last_seen_at` | string(date-time) | false | | | | `»»» login_type` | [codersdk.LoginType](schemas.md#codersdklogintype) | false | | | +| `»»» name` | string | false | | | | `»»» organization_ids` | array | false | | | | `»»» roles` | array | false | | | | `»»»» display_name` | string | false | | | diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 5d2409372824d..fbfb9b093b032 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -861,6 +861,7 @@ _None_ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -887,6 +888,7 @@ _None_ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1173,6 +1175,7 @@ _None_ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1251,6 +1254,7 @@ _None_ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -3105,6 +3109,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -3162,6 +3167,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -4985,6 +4991,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "role": "admin", "roles": [ @@ -5009,6 +5016,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `id` | string | true | | | | `last_seen_at` | string | false | | | | `login_type` | [codersdk.LoginType](#codersdklogintype) | false | | | +| `name` | string | false | | | | `organization_ids` | array of string | false | | | | `role` | [codersdk.TemplateRole](#codersdktemplaterole) | false | | | | `roles` | array of [codersdk.Role](#codersdkrole) | false | | | @@ -5426,6 +5434,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ```json { + "name": "string", "username": "string" } ``` @@ -5434,6 +5443,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | Name | Type | Required | Restrictions | Description | | ---------- | ------ | -------- | ------------ | ----------- | +| `name` | string | false | | | | `username` | string | true | | | ## codersdk.UpdateUserQuietHoursScheduleRequest @@ -5547,6 +5557,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -5570,6 +5581,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `id` | string | true | | | | `last_seen_at` | string | false | | | | `login_type` | [codersdk.LoginType](#codersdklogintype) | false | | | +| `name` | string | false | | | | `organization_ids` | array of string | false | | | | `roles` | array of [codersdk.Role](#codersdkrole) | false | | | | `status` | [codersdk.UserStatus](#codersdkuserstatus) | false | | | diff --git a/docs/api/users.md b/docs/api/users.md index 13ffd813c5545..d7242d95ca8d4 100644 --- a/docs/api/users.md +++ b/docs/api/users.md @@ -37,6 +37,7 @@ curl -X GET http://coder-server:8080/api/v2/users \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -105,6 +106,7 @@ curl -X POST http://coder-server:8080/api/v2/users \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -364,6 +366,7 @@ curl -X GET http://coder-server:8080/api/v2/users/{user} \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -416,6 +419,7 @@ curl -X DELETE http://coder-server:8080/api/v2/users/{user} \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -478,6 +482,7 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/appearance \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1050,6 +1055,7 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/profile \ ```json { + "name": "string", "username": "string" } ``` @@ -1073,6 +1079,7 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/profile \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1125,6 +1132,7 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/roles \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1187,6 +1195,7 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/roles \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1239,6 +1248,7 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/status/activate \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { @@ -1291,6 +1301,7 @@ curl -X PUT http://coder-server:8080/api/v2/users/{user}/status/suspend \ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", + "name": "string", "organization_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"], "roles": [ { diff --git a/enterprise/audit/table.go b/enterprise/audit/table.go index 0f5e5eef01dc5..c7e9272adfe40 100644 --- a/enterprise/audit/table.go +++ b/enterprise/audit/table.go @@ -120,6 +120,7 @@ var auditableResourcesTypes = map[any]map[string]Action{ "deleted": ActionTrack, "quiet_hours_schedule": ActionTrack, "theme_preference": ActionIgnore, + "name": ActionTrack, }, &database.Workspace{}: { "id": ActionTrack, diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index a5a7663d0de9f..1d120b2f8b459 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -1282,6 +1282,7 @@ export interface UpdateUserPasswordRequest { // From codersdk/users.go export interface UpdateUserProfileRequest { readonly username: string; + readonly name: string; } // From codersdk/users.go @@ -1329,6 +1330,7 @@ export interface UploadResponse { export interface User { readonly id: string; readonly username: string; + readonly name: string; readonly email: string; readonly created_at: string; readonly last_seen_at: string; From 06208e552fdf2cec6e12aa48d3775dcc5805c8f1 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 16:07:46 +0100 Subject: [PATCH 05/17] Fix TODO --- coderd/database/db2sdk/db2sdk.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/coderd/database/db2sdk/db2sdk.go b/coderd/database/db2sdk/db2sdk.go index 6e57fbbc4742f..4187f475e996c 100644 --- a/coderd/database/db2sdk/db2sdk.go +++ b/coderd/database/db2sdk/db2sdk.go @@ -116,17 +116,17 @@ func TemplateVersionParameter(param database.TemplateVersionParameter) (codersdk }, nil } -func UserProfile(user database.User, organizationIDs []uuid.UUID) codersdk.User { - u := User(user, organizationIDs) - u.Name = "TODO" +func User(user database.User, organizationIDs []uuid.UUID) codersdk.User { + u := UserProfile(user, organizationIDs) + u.Name = "" // Name property is accessible only via User Profile API. return u } -func User(user database.User, organizationIDs []uuid.UUID) codersdk.User { +func UserProfile(user database.User, organizationIDs []uuid.UUID) codersdk.User { convertedUser := codersdk.User{ - ID: user.ID, - Email: user.Email, - // Name property is visible only for the account owner. + ID: user.ID, + Email: user.Email, + Name: user.Name, CreatedAt: user.CreatedAt, LastSeenAt: user.LastSeenAt, Username: user.Username, From e0d8551144f7e5d729ad77654b239555834e1421 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 16:29:13 +0100 Subject: [PATCH 06/17] UpdateUserProfile name --- coderd/database/dbmem/dbmem.go | 1 + coderd/database/queries.sql.go | 5 ++++- coderd/database/queries/users.sql | 3 ++- coderd/users.go | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/coderd/database/dbmem/dbmem.go b/coderd/database/dbmem/dbmem.go index 3aaa0455a5be9..7554734f0c31f 100644 --- a/coderd/database/dbmem/dbmem.go +++ b/coderd/database/dbmem/dbmem.go @@ -6668,6 +6668,7 @@ func (q *FakeQuerier) UpdateUserProfile(_ context.Context, arg database.UpdateUs user.Email = arg.Email user.Username = arg.Username user.AvatarURL = arg.AvatarURL + user.Name = arg.Name q.users[index] = user return user, nil } diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index 9e3967b46c09d..622f6ac35577c 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -7895,7 +7895,8 @@ SET email = $2, username = $3, avatar_url = $4, - updated_at = $5 + updated_at = $5, + name = $6 WHERE id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url, deleted, last_seen_at, quiet_hours_schedule, theme_preference, name @@ -7907,6 +7908,7 @@ type UpdateUserProfileParams struct { Username string `db:"username" json:"username"` AvatarURL string `db:"avatar_url" json:"avatar_url"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` + Name string `db:"name" json:"name"` } func (q *sqlQuerier) UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) (User, error) { @@ -7916,6 +7918,7 @@ func (q *sqlQuerier) UpdateUserProfile(ctx context.Context, arg UpdateUserProfil arg.Username, arg.AvatarURL, arg.UpdatedAt, + arg.Name, ) var i User err := row.Scan( diff --git a/coderd/database/queries/users.sql b/coderd/database/queries/users.sql index 4708fd4f00344..80fe137142da0 100644 --- a/coderd/database/queries/users.sql +++ b/coderd/database/queries/users.sql @@ -78,7 +78,8 @@ SET email = $2, username = $3, avatar_url = $4, - updated_at = $5 + updated_at = $5, + name = $6 WHERE id = $1 RETURNING *; diff --git a/coderd/users.go b/coderd/users.go index a663b70d88bea..fb07c8d387137 100644 --- a/coderd/users.go +++ b/coderd/users.go @@ -647,6 +647,7 @@ func (api *API) putUserProfile(rw http.ResponseWriter, r *http.Request) { updatedUserProfile, err := api.Database.UpdateUserProfile(ctx, database.UpdateUserProfileParams{ ID: user.ID, Email: user.Email, + Name: params.Name, AvatarURL: user.AvatarURL, Username: params.Username, UpdatedAt: dbtime.Now(), From e3565e6daa263b1f774f9ec9258533681cfd2b44 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 16:48:48 +0100 Subject: [PATCH 07/17] Patching frontend --- coderd/userauth.go | 1 + .../UserSettingsPage/AccountPage/AccountForm.stories.tsx | 1 + .../pages/UserSettingsPage/AccountPage/AccountForm.test.tsx | 1 + site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx | 2 +- site/src/testHelpers/entities.ts | 4 ++++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/coderd/userauth.go b/coderd/userauth.go index 54f10d7388f79..4c160c883e6e1 100644 --- a/coderd/userauth.go +++ b/coderd/userauth.go @@ -1501,6 +1501,7 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C user, err = tx.UpdateUserProfile(dbauthz.AsSystemRestricted(ctx), database.UpdateUserProfileParams{ ID: user.ID, Email: user.Email, + Name: user.Name, Username: user.Username, UpdatedAt: dbtime.Now(), AvatarURL: user.AvatarURL, diff --git a/site/src/pages/UserSettingsPage/AccountPage/AccountForm.stories.tsx b/site/src/pages/UserSettingsPage/AccountPage/AccountForm.stories.tsx index 70fba78867017..c6c5f4dc86c08 100644 --- a/site/src/pages/UserSettingsPage/AccountPage/AccountForm.stories.tsx +++ b/site/src/pages/UserSettingsPage/AccountPage/AccountForm.stories.tsx @@ -10,6 +10,7 @@ const meta: Meta = { isLoading: false, initialValues: { username: "test-user", + name: "", }, updateProfileError: undefined, }, diff --git a/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx b/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx index 3b6c9951b3a52..e1a686e6be83c 100644 --- a/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx +++ b/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx @@ -13,6 +13,7 @@ describe("AccountForm", () => { // Given const mockInitialValues: UpdateUserProfileRequest = { username: MockUser2.username, + name: "", }; // When diff --git a/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx b/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx index 60e88adad2434..863027a1c45bb 100644 --- a/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx +++ b/site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx @@ -32,7 +32,7 @@ export const AccountPage: FC = () => { email={me.email} updateProfileError={updateProfileError} isLoading={isUpdatingProfile} - initialValues={{ username: me.username }} + initialValues={{ username: me.username, name: me.name }} onSubmit={updateProfile} /> diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index 65be658bad575..d27d9f0223a4b 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -285,6 +285,7 @@ export const MockUser: TypesGen.User = { last_seen_at: "", login_type: "password", theme_preference: "", + name: "", }; export const MockUserAdmin: TypesGen.User = { @@ -299,6 +300,7 @@ export const MockUserAdmin: TypesGen.User = { last_seen_at: "", login_type: "password", theme_preference: "", + name: "", }; export const MockUser2: TypesGen.User = { @@ -313,6 +315,7 @@ export const MockUser2: TypesGen.User = { last_seen_at: "2022-09-14T19:12:21Z", login_type: "oidc", theme_preference: "", + name: "", }; export const SuspendedMockUser: TypesGen.User = { @@ -327,6 +330,7 @@ export const SuspendedMockUser: TypesGen.User = { last_seen_at: "", login_type: "password", theme_preference: "", + name: "", }; export const MockProvisioner: TypesGen.ProvisionerDaemon = { From e6c23aadc1f83d65f790fc9a61589385002d7d9e Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 17:39:41 +0100 Subject: [PATCH 08/17] name not confidential --- coderd/database/db2sdk/db2sdk.go | 6 ------ coderd/users.go | 2 +- .../pages/UserSettingsPage/AccountPage/AccountForm.test.tsx | 1 + 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/coderd/database/db2sdk/db2sdk.go b/coderd/database/db2sdk/db2sdk.go index 4187f475e996c..a000d6f861fd6 100644 --- a/coderd/database/db2sdk/db2sdk.go +++ b/coderd/database/db2sdk/db2sdk.go @@ -117,12 +117,6 @@ func TemplateVersionParameter(param database.TemplateVersionParameter) (codersdk } func User(user database.User, organizationIDs []uuid.UUID) codersdk.User { - u := UserProfile(user, organizationIDs) - u.Name = "" // Name property is accessible only via User Profile API. - return u -} - -func UserProfile(user database.User, organizationIDs []uuid.UUID) codersdk.User { convertedUser := codersdk.User{ ID: user.ID, Email: user.Email, diff --git a/coderd/users.go b/coderd/users.go index fb07c8d387137..f5300feadf35c 100644 --- a/coderd/users.go +++ b/coderd/users.go @@ -671,7 +671,7 @@ func (api *API) putUserProfile(rw http.ResponseWriter, r *http.Request) { return } - httpapi.Write(ctx, rw, http.StatusOK, db2sdk.UserProfile(updatedUserProfile, organizationIDs)) + httpapi.Write(ctx, rw, http.StatusOK, db2sdk.User(updatedUserProfile, organizationIDs)) } // @Summary Suspend user account diff --git a/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx b/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx index e1a686e6be83c..797dd5dab92f6 100644 --- a/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx +++ b/site/src/pages/UserSettingsPage/AccountPage/AccountForm.test.tsx @@ -44,6 +44,7 @@ describe("AccountForm", () => { // Given const mockInitialValues: UpdateUserProfileRequest = { username: MockUser2.username, + name: "", }; // When From 7df71de4b056ef3ffc88208e56f0f2070b7751bd Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 17:47:52 +0100 Subject: [PATCH 09/17] find and replace --- coderd/provisionerdserver/provisionerdserver.go | 1 + coderd/provisionerdserver/provisionerdserver_test.go | 1 + provisioner/terraform/provision.go | 1 + 3 files changed, 3 insertions(+) diff --git a/coderd/provisionerdserver/provisionerdserver.go b/coderd/provisionerdserver/provisionerdserver.go index 1330f370d6191..0619e99f1cb76 100644 --- a/coderd/provisionerdserver/provisionerdserver.go +++ b/coderd/provisionerdserver/provisionerdserver.go @@ -557,6 +557,7 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo WorkspaceName: workspace.Name, WorkspaceOwner: owner.Username, WorkspaceOwnerEmail: owner.Email, + WorkspaceOwnerName: owner.Name, WorkspaceOwnerOidcAccessToken: workspaceOwnerOIDCAccessToken, WorkspaceId: workspace.ID.String(), WorkspaceOwnerId: owner.ID.String(), diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 01a0837a4d028..738e9da8dbd2f 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -341,6 +341,7 @@ func TestAcquireJob(t *testing.T) { WorkspaceName: workspace.Name, WorkspaceOwner: user.Username, WorkspaceOwnerEmail: user.Email, + WorkspaceOwnerName: user.Name, WorkspaceOwnerOidcAccessToken: link.OAuthAccessToken, WorkspaceId: workspace.ID.String(), WorkspaceOwnerId: user.ID.String(), diff --git a/provisioner/terraform/provision.go b/provisioner/terraform/provision.go index e980a26d833fc..40f24ecfb8124 100644 --- a/provisioner/terraform/provision.go +++ b/provisioner/terraform/provision.go @@ -192,6 +192,7 @@ func provisionEnv( "CODER_WORKSPACE_NAME="+metadata.GetWorkspaceName(), "CODER_WORKSPACE_OWNER="+metadata.GetWorkspaceOwner(), "CODER_WORKSPACE_OWNER_EMAIL="+metadata.GetWorkspaceOwnerEmail(), + "CODER_WORKSPACE_OWNER_NAME="+metadata.GetWorkspaceOwnerName(), "CODER_WORKSPACE_OWNER_OIDC_ACCESS_TOKEN="+metadata.GetWorkspaceOwnerOidcAccessToken(), "CODER_WORKSPACE_ID="+metadata.GetWorkspaceId(), "CODER_WORKSPACE_OWNER_ID="+metadata.GetWorkspaceOwnerId(), From afced2afa130cc91002d06daab20a7ce0d96c4f5 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 18:03:55 +0100 Subject: [PATCH 10/17] Fix golden --- cli/testdata/coder_users_list_--output_json.golden | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/testdata/coder_users_list_--output_json.golden b/cli/testdata/coder_users_list_--output_json.golden index 7e06b98436ea7..1ec8f37cb5262 100644 --- a/cli/testdata/coder_users_list_--output_json.golden +++ b/cli/testdata/coder_users_list_--output_json.golden @@ -2,6 +2,7 @@ { "id": "[first user ID]", "username": "testuser", + "name": "", "email": "testuser@coder.com", "created_at": "[timestamp]", "last_seen_at": "[timestamp]", @@ -22,6 +23,7 @@ { "id": "[second user ID]", "username": "testuser2", + "name": "", "email": "testuser2@coder.com", "created_at": "[timestamp]", "last_seen_at": "[timestamp]", From 8e6f929b260bd7aa2a573a72dff2a4e7ee06ec39 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 16 Jan 2024 18:16:04 +0100 Subject: [PATCH 11/17] Fix ts --- site/src/pages/UserSettingsPage/AccountPage/AccountPage.test.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/site/src/pages/UserSettingsPage/AccountPage/AccountPage.test.tsx b/site/src/pages/UserSettingsPage/AccountPage/AccountPage.test.tsx index 28ad208fed61a..e98d1f116b2a5 100644 --- a/site/src/pages/UserSettingsPage/AccountPage/AccountPage.test.tsx +++ b/site/src/pages/UserSettingsPage/AccountPage/AccountPage.test.tsx @@ -7,6 +7,7 @@ import { mockApiError } from "testHelpers/entities"; const newData = { username: "user", + name: "", }; const fillAndSubmitForm = async () => { From 4d8934d1f59202c6cfb25eee1e734d0d9801a473 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 17 Jan 2024 10:51:45 +0100 Subject: [PATCH 12/17] bad linting --- coderd/workspaceagents_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/workspaceagents_test.go b/coderd/workspaceagents_test.go index 0d620c991e6dd..77fb6b1976ab9 100644 --- a/coderd/workspaceagents_test.go +++ b/coderd/workspaceagents_test.go @@ -1626,7 +1626,7 @@ func TestWorkspaceAgentExternalAuthListen(t *testing.T) { cancel() // We expect only 1 // In a failed test, you will likely see 9, as the last one - // gets canceled. + // gets cancelled. require.Equal(t, 1, validateCalls, "validate calls duplicated on same token") }) } From 15367f016f4d217f2154628ef36314d3a2be6e7b Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 17 Jan 2024 11:07:11 +0100 Subject: [PATCH 13/17] Unit test --- coderd/users_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coderd/users_test.go b/coderd/users_test.go index d0f8c36484843..2b82f7dc44146 100644 --- a/coderd/users_test.go +++ b/coderd/users_test.go @@ -677,7 +677,7 @@ func TestUpdateUserProfile(t *testing.T) { require.Equal(t, http.StatusConflict, apiErr.StatusCode()) }) - t.Run("UpdateUsername", func(t *testing.T) { + t.Run("UpdateUser", func(t *testing.T) { t.Parallel() auditor := audit.NewMock() client := coderdtest.New(t, &coderdtest.Options{Auditor: auditor}) @@ -692,9 +692,11 @@ func TestUpdateUserProfile(t *testing.T) { _, _ = client.User(ctx, codersdk.Me) userProfile, err := client.UpdateUserProfile(ctx, codersdk.Me, codersdk.UpdateUserProfileRequest{ Username: "newusername", + Name: "Mr User", }) require.NoError(t, err) require.Equal(t, userProfile.Username, "newusername") + require.Equal(t, userProfile.Name, "Mr User") numLogs++ // add an audit log for user update require.Len(t, auditor.AuditLogs(), numLogs) From 891705f14f19ad30dcd81569b70b128f1e63c6b4 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 17 Jan 2024 11:31:22 +0100 Subject: [PATCH 14/17] Validate real name --- coderd/httpapi/httpapi.go | 14 ++++++++++++++ coderd/httpapi/name.go | 13 +++++++++++++ coderd/httpapi/name_test.go | 29 +++++++++++++++++++++++++++++ coderd/users_test.go | 23 +++++++++++++++++++++++ codersdk/users.go | 2 +- 5 files changed, 80 insertions(+), 1 deletion(-) diff --git a/coderd/httpapi/httpapi.go b/coderd/httpapi/httpapi.go index e6c63451a0df9..fb5e4361ec32c 100644 --- a/coderd/httpapi/httpapi.go +++ b/coderd/httpapi/httpapi.go @@ -80,6 +80,20 @@ func init() { if err != nil { panic(err) } + + userRealNameValidator := func(fl validator.FieldLevel) bool { + f := fl.Field().Interface() + str, ok := f.(string) + if !ok { + return false + } + valid := UserRealNameValid(str) + return valid == nil + } + err = Validate.RegisterValidation("user_real_name", userRealNameValidator) + if err != nil { + panic(err) + } } // Is404Error returns true if the given error should return a 404 status code. diff --git a/coderd/httpapi/name.go b/coderd/httpapi/name.go index bea9c17a8b6f3..199139d1fce72 100644 --- a/coderd/httpapi/name.go +++ b/coderd/httpapi/name.go @@ -79,3 +79,16 @@ func TemplateDisplayNameValid(str string) error { } return nil } + +// UserRealNameValid returns whether the input string is a valid real user name. +func UserRealNameValid(str string) error { + if len(str) > 64 { + return xerrors.New("must be <= 64 characters") + } + + trimmed := strings.TrimSpace(str) + if trimmed != str { + return xerrors.New("must not have leading or trailing white spaces") + } + return nil +} diff --git a/coderd/httpapi/name_test.go b/coderd/httpapi/name_test.go index e28115eecbbd7..c1ac5eac6f696 100644 --- a/coderd/httpapi/name_test.go +++ b/coderd/httpapi/name_test.go @@ -209,3 +209,32 @@ func TestFrom(t *testing.T) { }) } } + +func TestUserRealNameValid(t *testing.T) { + t.Parallel() + + testCases := []struct { + Name string + Valid bool + }{ + {"1", true}, + {"A", true}, + {"A1", true}, + {".", true}, + {"Mr Bean", true}, + {"John Doe", true}, + {". .", true}, + + {"John Doe ", false}, + {" John Doe", false}, + {" ", false}, + } + for _, testCase := range testCases { + testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { + t.Parallel() + valid := httpapi.UserRealNameValid(testCase.Name) + require.Equal(t, testCase.Valid, valid == nil) + }) + } +} diff --git a/coderd/users_test.go b/coderd/users_test.go index 2b82f7dc44146..c73bd3014dc05 100644 --- a/coderd/users_test.go +++ b/coderd/users_test.go @@ -702,6 +702,29 @@ func TestUpdateUserProfile(t *testing.T) { require.Len(t, auditor.AuditLogs(), numLogs) require.Equal(t, database.AuditActionWrite, auditor.AuditLogs()[numLogs-1].Action) }) + + t.Run("InvalidRealUserName", func(t *testing.T) { + t.Parallel() + client := coderdtest.New(t, nil) + user := coderdtest.CreateFirstUser(t, client) + + ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) + defer cancel() + + _, err := client.CreateUser(ctx, codersdk.CreateUserRequest{ + Email: "john@coder.com", + Username: "john", + Password: "SomeSecurePassword!", + OrganizationID: user.OrganizationID, + }) + require.NoError(t, err) + _, err = client.UpdateUserProfile(ctx, codersdk.Me, codersdk.UpdateUserProfileRequest{ + Name: " Mr Bean", // must not have leading space + }) + var apiErr *codersdk.Error + require.ErrorAs(t, err, &apiErr) + require.Equal(t, http.StatusBadRequest, apiErr.StatusCode()) + }) } func TestUpdateUserPassword(t *testing.T) { diff --git a/codersdk/users.go b/codersdk/users.go index 991d0550b69bb..a43b197c747f1 100644 --- a/codersdk/users.go +++ b/codersdk/users.go @@ -119,7 +119,7 @@ type CreateUserRequest struct { type UpdateUserProfileRequest struct { Username string `json:"username" validate:"required,username"` - Name string `json:"name"` + Name string `json:"name" validate:"user_real_name"` } type UpdateUserAppearanceSettingsRequest struct { From f3c0c42ee3f1a2ea102047b976147aa0dee9cea6 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 17 Jan 2024 11:36:57 +0100 Subject: [PATCH 15/17] Fix --- coderd/httpapi/name_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/coderd/httpapi/name_test.go b/coderd/httpapi/name_test.go index c1ac5eac6f696..83aa85d85d6f4 100644 --- a/coderd/httpapi/name_test.go +++ b/coderd/httpapi/name_test.go @@ -222,11 +222,12 @@ func TestUserRealNameValid(t *testing.T) { {"A1", true}, {".", true}, {"Mr Bean", true}, - {"John Doe", true}, + {"Severus Snape", true}, + {"Prof. Albus Percival Wulfric Brian Dumbledore", true}, {". .", true}, - {"John Doe ", false}, - {" John Doe", false}, + {"Lord Voldemort ", false}, + {" Bellatrix Lestrange", false}, {" ", false}, } for _, testCase := range testCases { From d1165664a1a7fce9990db1c44d054971e15c109c Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 17 Jan 2024 12:20:24 +0100 Subject: [PATCH 16/17] Address PR comments --- coderd/httpapi/name.go | 4 ++-- coderd/httpapi/name_test.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/coderd/httpapi/name.go b/coderd/httpapi/name.go index 199139d1fce72..db1e4b8edb8a7 100644 --- a/coderd/httpapi/name.go +++ b/coderd/httpapi/name.go @@ -82,8 +82,8 @@ func TemplateDisplayNameValid(str string) error { // UserRealNameValid returns whether the input string is a valid real user name. func UserRealNameValid(str string) error { - if len(str) > 64 { - return xerrors.New("must be <= 64 characters") + if len(str) > 128 { + return xerrors.New("must be <= 128 characters") } trimmed := strings.TrimSpace(str) diff --git a/coderd/httpapi/name_test.go b/coderd/httpapi/name_test.go index 83aa85d85d6f4..a6313c54034f5 100644 --- a/coderd/httpapi/name_test.go +++ b/coderd/httpapi/name_test.go @@ -224,6 +224,10 @@ func TestUserRealNameValid(t *testing.T) { {"Mr Bean", true}, {"Severus Snape", true}, {"Prof. Albus Percival Wulfric Brian Dumbledore", true}, + {"Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de la Santísima Trinidad Ruiz y Picasso", true}, + {"Hector Ó hEochagáin", true}, + {"Małgorzata Kalinowska-Iszkowska", true}, + {"成龍", true}, {". .", true}, {"Lord Voldemort ", false}, From 2bc609e359a9af11342068061ff04eb391740ec7 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 17 Jan 2024 13:11:42 +0100 Subject: [PATCH 17/17] Fix strings.TrimSpace --- coderd/httpapi/name.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/coderd/httpapi/name.go b/coderd/httpapi/name.go index db1e4b8edb8a7..85dbaa12e8ad9 100644 --- a/coderd/httpapi/name.go +++ b/coderd/httpapi/name.go @@ -86,8 +86,7 @@ func UserRealNameValid(str string) error { return xerrors.New("must be <= 128 characters") } - trimmed := strings.TrimSpace(str) - if trimmed != str { + if strings.TrimSpace(str) != str { return xerrors.New("must not have leading or trailing white spaces") } return nil