From eb9abe7694a5453b64a1d8e85ceb2e3b663816c8 Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Mon, 17 Jul 2023 19:21:17 +0000 Subject: [PATCH] chore(coderd): require api key to access derpmap --- coderd/coderd.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/coderd/coderd.go b/coderd/coderd.go index 7104049187235..3d41d62fded00 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -727,7 +727,14 @@ func New(options *Options) *API { r.Post("/azure-instance-identity", api.postWorkspaceAuthAzureInstanceIdentity) r.Post("/aws-instance-identity", api.postWorkspaceAuthAWSInstanceIdentity) r.Post("/google-instance-identity", api.postWorkspaceAuthGoogleInstanceIdentity) - r.Get("/connection", api.workspaceAgentConnectionGeneric) + r.With( + apiKeyMiddlewareOptional, + httpmw.ExtractWorkspaceProxy(httpmw.ExtractWorkspaceProxyConfig{ + DB: options.Database, + Optional: true, + }), + httpmw.RequireAPIKeyOrWorkspaceProxyAuth(), + ).Get("/connection", api.workspaceAgentConnectionGeneric) r.Route("/me", func(r chi.Router) { r.Use(httpmw.ExtractWorkspaceAgent(httpmw.ExtractWorkspaceAgentConfig{ DB: options.Database,