Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/cli-go/internal/functions/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool,
function, ok := utils.Config.Functions[name]
if !ok {
function.Enabled = true
function.VerifyJWT = true
// Don't set VerifyJWT when not in config, so the API preserves the existing server-side setting
}
// Precedence order: flag > config > fallback
functionDir := filepath.Join(utils.FunctionsDir, name)
Expand All @@ -137,7 +137,8 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool,
}
}
if noVerifyJWT != nil {
function.VerifyJWT = !*noVerifyJWT
val := !*noVerifyJWT
function.VerifyJWT = &val
}
functionConfig[name] = function
}
Expand Down
6 changes: 5 additions & 1 deletion apps/cli-go/internal/functions/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ func PopulatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fs
return nil, "", err
}
binds = append(binds, modules...)
verifyJWT := true
if fc.VerifyJWT != nil {
verifyJWT = *fc.VerifyJWT
}
enabled := dockerFunction{
VerifyJWT: fc.VerifyJWT,
VerifyJWT: verifyJWT,
EntrypointPath: utils.ToDockerPath(fc.Entrypoint),
ImportMapPath: utils.ToDockerPath(fc.ImportMap),
StaticFiles: make([]string, len(fc.StaticFiles)),
Expand Down
2 changes: 1 addition & 1 deletion apps/cli-go/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ type (

function struct {
Enabled bool `toml:"enabled" json:"enabled"`
VerifyJWT bool `toml:"verify_jwt" json:"verify_jwt"`
VerifyJWT *bool `toml:"verify_jwt" json:"verify_jwt"`
ImportMap string `toml:"import_map" json:"import_map"`
Entrypoint string `toml:"entrypoint" json:"entrypoint"`
StaticFiles Glob `toml:"static_files" json:"static_files"`
Expand Down
4 changes: 2 additions & 2 deletions apps/cli-go/pkg/function/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ OUTER:
} else if err != nil {
return err
}
meta.VerifyJwt = &function.VerifyJWT
meta.VerifyJwt = function.VerifyJWT
bodyHash := sha256.Sum256(body.Bytes())
meta.SHA256 = hex.EncodeToString(bodyHash[:])
// Skip if function has not changed
if i, exists := slugToIndex[slug]; exists && i >= 0 &&
result[i].EzbrSha256 != nil && *result[i].EzbrSha256 == meta.SHA256 &&
result[i].VerifyJwt != nil && *result[i].VerifyJwt == function.VerifyJWT {
result[i].VerifyJwt != nil && function.VerifyJWT != nil && *result[i].VerifyJwt == *function.VerifyJWT {
fmt.Fprintln(os.Stderr, "No change found in Function:", slug)
continue
}
Expand Down
2 changes: 1 addition & 1 deletion apps/cli-go/pkg/function/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestUpsertFunctions(t *testing.T) {
}})
// Run test
err := client.UpsertFunctions(context.Background(), config.FunctionConfig{
"test-a": {Enabled: true, VerifyJWT: true},
"test-a": {Enabled: true, VerifyJWT: cast.Ptr(true)},
"test-b": {Enabled: false},
})
// Check error
Expand Down
2 changes: 1 addition & 1 deletion apps/cli-go/pkg/function/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *EdgeRuntimeAPI) Deploy(ctx context.Context, functionConfig config.Funct
Name: &slug,
EntrypointPath: toRelPath(fc.Entrypoint),
ImportMapPath: cast.Ptr(toRelPath(fc.ImportMap)),
VerifyJwt: &fc.VerifyJWT,
VerifyJwt: fc.VerifyJWT,
}
files := make([]string, len(fc.StaticFiles))
for i, sf := range fc.StaticFiles {
Expand Down