Skip to content

Commit 28deaca

Browse files
committed
Audit log proxy registers
1 parent fe66e57 commit 28deaca

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

coderd/database/queries/proxies.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SET
5151
WHEN length(@token_hashed_secret :: bytea) > 0 THEN @token_hashed_secret :: bytea
5252
ELSE workspace_proxies.token_hashed_secret
5353
END,
54-
-- Always update this timestamp.
54+
-- Always update this timestamp.
5555
updated_at = Now()
5656
WHERE
5757
id = @id
@@ -85,7 +85,7 @@ SELECT
8585
FROM
8686
workspace_proxies
8787
WHERE
88-
deleted = false;
88+
deleted = false;
8989

9090
-- Finds a workspace proxy that has an access URL or app hostname that matches
9191
-- the provided hostname. This is to check if a hostname matches any workspace

enterprise/cli/workspaceproxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (r *RootCmd) patchProxy() *clibase.Cmd {
9696
},
9797
clibase.Option{
9898
Flag: "display-name",
99-
Description: "(Optional) Display of the proxy. If omitted, the name is reused as the display name.",
99+
Description: "(Optional) Display of the proxy. A more human friendly name to be displayed.",
100100
Value: clibase.StringOf(&displayName),
101101
},
102102
clibase.Option{

enterprise/coderd/workspaceproxy.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,18 @@ func (api *API) workspaceProxyIssueSignedAppToken(rw http.ResponseWriter, r *htt
410410
// @x-apidocgen {"skip": true}
411411
func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request) {
412412
var (
413-
ctx = r.Context()
414-
proxy = httpmw.WorkspaceProxy(r)
413+
ctx = r.Context()
414+
proxy = httpmw.WorkspaceProxy(r)
415+
auditor = api.AGPL.Auditor.Load()
416+
aReq, commitAudit = audit.InitRequest[database.WorkspaceProxy](rw, &audit.RequestParams{
417+
Audit: *auditor,
418+
Log: api.Logger,
419+
Request: r,
420+
Action: database.AuditActionWrite,
421+
})
415422
)
423+
aReq.Old = proxy
424+
defer commitAudit()
416425

417426
var req wsproxysdk.RegisterWorkspaceProxyRequest
418427
if !httpapi.Read(ctx, rw, r, &req) {
@@ -437,7 +446,7 @@ func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request)
437446
}
438447
}
439448

440-
_, err := api.Database.RegisterWorkspaceProxy(ctx, database.RegisterWorkspaceProxyParams{
449+
updatedProxy, err := api.Database.RegisterWorkspaceProxy(ctx, database.RegisterWorkspaceProxyParams{
441450
ID: proxy.ID,
442451
Url: req.AccessURL,
443452
WildcardHostname: req.WildcardHostname,
@@ -451,6 +460,7 @@ func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request)
451460
return
452461
}
453462

463+
aReq.New = updatedProxy
454464
httpapi.Write(ctx, rw, http.StatusCreated, wsproxysdk.RegisterWorkspaceProxyResponse{
455465
AppSecurityKey: api.AppSecurityKey.String(),
456466
})

0 commit comments

Comments
 (0)