Repository navigation
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 38 |
🟢 Coverage 100.00% diff coverage · +0.27% coverage variation
Metric Results Coverage variation ✅ +0.27% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (a2f9b5b) 95037 29290 30.82% Head commit (cde7ec7) 95048 (+11) 29554 (+264) 31.09% (+0.27%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#4117) 11 11 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
pbleser-oc
left a comment
There was a problem hiding this comment.
Thanks, looks good to me. The check matches what it should do, and the tests fail without the fix.
One thing for a follow-up, not for this PR: OC_GRPC_CLIENT_TLS_MODE=insecure is also passed to the reva gRPC clients (pool.WithTLSMode in several services, and tls_mode/permissionssvc_tls_mode in the reva configs), and those still skip the certificate check without OC_INSECURE. So services that only use reva clients keep running in that mode. Maybe worth an issue to guard those too, or to check it once at startup for all services?
| case "insecure": | ||
| // Skipping the server certificate check is only meant for development | ||
| // setups, so it has to be allowed explicitly. | ||
| if insecure, _ := strconv.ParseBool(os.Getenv("OC_INSECURE")); !insecure { |
There was a problem hiding this comment.
A suggestion: everywhere else, OC_INSECURE is an env alias on a config setting (tls_insecure, insecure, ...), so those can also be set in the YAML config, and opencloud init --insecure writes them there without setting any env var. The mode itself can be set in YAML too (grpc_client_tls: mode: insecure), but this check only looks at the env var.
What do you think about a field on shared.GRPCClientTLS, e.g. Insecure bool with yaml:"insecure" env:"OC_INSECURE", passed on through GetClientOptions as a client option and checked here? Then it works the same way as the other insecure switches, from YAML or the env.
There was a problem hiding this comment.
Good point, thanks. I'll move it into the config: an Insecure field on shared.GRPCClientTLS (yaml:"insecure", env:"OC_INSECURE"), passed through GetClientOptions and checked in NewClient instead of reading the env var directly. That way the YAML config and opencloud init --insecure work the same as for the other insecure settings.
There was a problem hiding this comment.
|
On the For labelling it breaking:
Against labelling it breaking:
|
|
@pbleser-oc Thanks! There's an issue for the reva clients now: opencloud-eu/reva#1072. I'll add the paths you mention (permissionssvc_tls_mode in the storage-users config, the reva grpc_client_options) and the idea of a single check at startup to it. |
Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
pbleser-oc
left a comment
There was a problem hiding this comment.
Thanks Sara, the config option works nicely, and opencloud init --insecure writing it is a good addition. Only two small wording points inline.
The three new commits only have a subject line. af4aa22 in particular could say in its body why the check moved from the environment into the configuration (so that it also works through the YAML config and opencloud init --insecure).
| // Skipping the server certificate check is only meant for development | ||
| // setups, so it has to be allowed explicitly. | ||
| if !options.tlsInsecure { | ||
| return nil, errors.New("grpc client TLS mode 'insecure' disables server certificate verification and requires OC_INSECURE=true; use OC_GRPC_CLIENT_TLS_MODE=on with a trusted certificate otherwise") |
There was a problem hiding this comment.
Now that the check reads the config option, the message only names OC_INSECURE=true: someone who configures this through the YAML file won't find grpc_client_tls.insecure from it. Maybe something like "... requires OC_INSECURE=true (or grpc_client_tls.insecure: true in the config file)"?
There was a problem hiding this comment.
Good point, done in cde7ec7. The message now reads "… requires OC_INSECURE=true or grpc_client_tls.insecure: true in the config file; use OC_GRPC_CLIENT_TLS_MODE=on with a trusted certificate otherwise", and the tests check that both are named.
| type GRPCClientTLS struct { | ||
| Mode string `yaml:"mode" env:"OC_GRPC_CLIENT_TLS_MODE" desc:"TLS mode for grpc connection to the go-micro based grpc services. Possible values are 'off', 'insecure' and 'on'. 'off': disables transport security for the clients. 'insecure' allows using transport security, but disables certificate verification (to be used with the autogenerated self-signed certificates). 'on' enables transport security, including server certificate verification." introductionVersion:"1.0.0"` | ||
| CACert string `yaml:"cacert" env:"OC_GRPC_CLIENT_TLS_CACERT" desc:"Path/File name for the root CA certificate (in PEM format) used to validate TLS server certificates of the go-micro based grpc services." introductionVersion:"1.0.0"` | ||
| Mode string `yaml:"mode" env:"OC_GRPC_CLIENT_TLS_MODE" desc:"TLS mode for grpc connection to the go-micro based grpc services. Possible values are 'off', 'insecure' and 'on'. 'off': disables transport security for the clients. 'insecure' allows using transport security, but disables certificate verification (to be used with the autogenerated self-signed certificates). 'insecure' is only accepted when OC_INSECURE is set to 'true', otherwise the services fail to start. 'on' enables transport security, including server certificate verification." introductionVersion:"1.0.0"` |
There was a problem hiding this comment.
The description of the mode still says "'insecure' is only accepted when OC_INSECURE is set to 'true'". It could name the new insecure option as well, since the docs of the env vars and of the config file are generated from it.
There was a problem hiding this comment.
Done in cde7ec7: the description of OC_GRPC_CLIENT_TLS_MODE now names grpc_client_tls.insecure as well. I changed the description of OC_GRPC_TLS_ENABLED the same way, since it had the same sentence about OC_INSECURE.
Assisted-by: Claude Code:claude-opus-5-5
|
@pbleser-oc As discussed, I've kept the commit messages to one line each; the details on why the check moved into the configuration, and what |
Description
OC_GRPC_CLIENT_TLS_MODE=insecuremakes the go-micro gRPC clients use TLS without verifying the server certificate. Until now, any installation could set it.The
insecuremode now has to be allowed explicitly, with the new settinggrpc_client_tls.insecure. It works like the other insecure switches of the configuration:grpc_client_tls: insecure: true) or per service;OC_INSECURE=true, which is parsed like everywhere else in the configuration:true,TRUEand1count as true;opencloud init --insecure yeswrites it into the generated config. It only writes the permission, not the mode.Without it, creating the gRPC client in the
insecuremode fails with an error that names bothOC_INSECUREandgrpc_client_tls.insecure, and the services that use such a client don't start.The descriptions of
OC_GRPC_CLIENT_TLS_MODEandOC_GRPC_TLS_ENABLEDnow mention this requirement, with both the env var and the config option. The second one also gets a typo fix ("certifcate").Nothing else changes: the modes
off(the default) andonwork as before, with or without the new setting.Related Issue
Motivation and Context
Skipping the certificate check means that the gRPC traffic between the services is encrypted, but a man-in-the-middle can still read and change it. That is fine for development setups with the auto-generated self-signed certificates, but it should not be possible to switch it on in production by accident.
OC_INSECUREandopencloud init --insecurealready mark a setup as insecure for development, so the gRPC clients now require the same.Breaking change: installations that run with
OC_GRPC_CLIENT_TLS_MODE=insecure(for example together withOC_GRPC_TLS_ENABLED=trueand the auto-generated certificate) no longer start unless they also setOC_INSECURE=trueorgrpc_client_tls.insecure: true. Production setups should useOC_GRPC_CLIENT_TLS_MODE=onwith a certificate that the clients can verify (OC_GRPC_CLIENT_TLS_CACERT). The default modeoffis not affected.How Has This Been Tested?
pkg/service/grpc/client_test.go:TestNewClientInsecureTLSMode, modeinsecure: allowed through the client option, a client is created; not allowed or not given, an error namingOC_INSECUREandgrpc_client_tls.insecure, and no client. Also not allowed when onlyOC_INSECURE=trueis set in the environment, since the client only looks at the configuration.TestNewClientOtherTLSModesIgnoreInsecure: the modes"",offandonstill create a client without the setting.TestGetClientOptionsInsecure: the setting is passed on fromshared.GRPCClientTLS.pkg/shared/shared_types_test.go,TestGRPCClientTLSInsecureFromEnv:OC_INSECUREtrue,1andfalseset the field.pkg/config/helpers_test.go,TestBindSourcesToStructs_GRPCClientTLSInsecure: the setting is read from the YAML config.opencloud/pkg/init/init_test.go,TestCreateConfigGRPCClientTLS:initwith--insecurewritesgrpc_client_tls.insecure: trueand no mode, without it nogrpc_client_tlssection.go testandgo test -racepass for the changed packages and for./opencloud/...,pkg/config/..., the auth-guest service and the revaconfigs of storage-users and storage-system.go build ./pkg/... ./opencloud/... ./services/...passes.go vetreports nothing for the changed packages.git diff --checkis clean. The env var annotations are valid.golangci-lint, the unit tests of all services, and the acceptance tests. The CI doesn't setOC_GRPC_CLIENT_TLS_MODE, so the acceptance tests don't reach the changed code.Types of changes
Checklist:
AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the code, the tests and this description; I reviewed and adjusted them.