Skip to content

Commit cbe77a2

Browse files
authored
Allow query path on disableWriteActions (#2601)
1 parent afcc7b0 commit cbe77a2

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

  • server
  • src/routes/(app)/namespaces/[namespace]/workflows/start-workflow

server/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/temporalio/ui-server/v2
22

33
go 1.23
4+
45
require (
56
github.com/coreos/go-oidc/v3 v3.11.0
67
github.com/gomarkdown/markdown v0.0.0-20241105142532-d03b89096d81

server/server/route/api.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package route
2525
import (
2626
"fmt"
2727
"net/http"
28+
"strings"
2829

2930
"github.com/labstack/echo/v4"
3031

@@ -40,7 +41,19 @@ func DisableWriteMiddleware(cfgProvider *config.ConfigProviderWithRefresh) echo.
4041
return c.JSON(http.StatusInternalServerError, err)
4142
}
4243

43-
if cfg.DisableWriteActions && c.Request().Method != http.MethodGet {
44+
if c.Request().Method == http.MethodGet {
45+
return next(c)
46+
}
47+
48+
if cfg.DisableWriteActions {
49+
path := c.Request().URL.Path
50+
method := c.Request().Method
51+
52+
if method == http.MethodPost && strings.HasPrefix(path, "/api/v1/namespaces/") &&
53+
strings.Contains(path, "/workflows/") && strings.Contains(path, "/query/") {
54+
return next(c)
55+
}
56+
4457
return echo.ErrMethodNotAllowed
4558
}
4659

src/routes/(app)/namespaces/[namespace]/workflows/start-workflow/+page.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { routeForWorkflows } from '$lib/utilities/route-for';
66

77
export const load: PageLoad = async function ({ params, parent }) {
88
const data = await parent();
9-
if (data.settings.startWorkflowDisabled) {
9+
const disabled =
10+
data?.settings?.disableWriteActions ||
11+
data?.settings?.startWorkflowDisabled;
12+
13+
if (disabled) {
1014
const { namespace } = params;
1115
redirect(302, routeForWorkflows({ namespace }));
1216
}

0 commit comments

Comments
 (0)