From fd7c019fff4c37ff4b61f7c7a28f70311566fc65 Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Mon, 17 Jul 2023 14:40:12 -0500 Subject: [PATCH] chore(coderd): require api key to access derpmap (#8569) --- coderd/coderd.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/coderd/coderd.go b/coderd/coderd.go index 7104049187..3d41d62fde 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,