Repository navigation
Description
Summary
Make every sample under samples/ (and the sample launchers under tools/) secure by default, with one consistent, easy switch to opt into insecure demo access (anonymous users, SecurityPolicy None, auto-accepted certificates) through an environment variable or a command-line parameter.
Samples are copied into real projects, so their defaults become production defaults. Today many of them start with relaxed settings hard-coded, and each sample enables them differently. The redundancy samples already use a gated pattern (HA_INSECURE plus loopback only). This issue proposes to generalize it.
Proposed default behaviour (no switch set)
- Endpoints: only secure endpoints (Sign / SignAndEncrypt with the default policies). No
SecurityPolicy#Noneendpoint. - Users: no anonymous user token. Use UserName or X.509 user tokens. Where a sample needs demo accounts, take them from configuration or environment, or generate a password at first start and print it once. Do not hard-code accounts in code or container images.
- Certificates: no auto-accept of untrusted certificates in servers or clients, and no accept-all
CertificateValidationcallbacks in client samples. Document how to trust the peer (copy into the trusted store, or a--trust <thumbprint>style option). - Binding: listen on loopback for
localhostendpoint URLs. Containers, compose files and Helm charts should not publish on all interfaces unless the deployment sets it explicitly. - PKI location: the per-user default PKI root, not a folder under the shared temp directory.
- Roles: do not map Anonymous to elevated roles (e.g. Operator).
Opt-in for demos
One shared helper, used by all samples, for example in a common sample project or as a hosting option:
| Switch | Environment variable | CLI parameter |
|---|---|---|
| All of the below | OPCUA_SAMPLE_INSECURE=1 |
--insecure |
| Anonymous access | OPCUA_SAMPLE_ALLOW_ANONYMOUS=1 |
--allow-anonymous |
| SecurityPolicy None endpoint | OPCUA_SAMPLE_ALLOW_SECURITY_NONE=1 |
--allow-security-none |
| Auto-accept untrusted certificates | OPCUA_SAMPLE_AUTO_ACCEPT=1 |
--auto-accept |
(Names are a suggestion.)
When any switch is on, the sample logs a clear warning at startup that names what is relaxed. Docker, compose and Helm files that need the relaxed mode set the variable explicitly and visibly.
Affected samples (first pass, from master)
Servers that currently enable one or more of anonymous / None / auto-accept in code or configuration:
AI ModelManagementServer, AMB AmbServer, AutoID AutoIdServer, CranesHoists CranesHoistsServer, Di PumpDeviceIntegrationServer (incl. kubernetes.yaml), FluentApi BasicFluentApiServer, Gds OnboardingRegistrar, ISA95 MinimalIsa95Server, LADS LadsServer, Lds ConsoleLdsServer, Machinery MachineryServer, MinimalApi MinimalBoilerServer / MinimalCalcServer, Network NetworkModelSample, OpenUsd GeneratorServer / SiteCompositionServer, PADIM PadimDemo, PackML PackMLSample, Pumps PumpsServer, Quickstarts ReferenceServer (container image), Reference ConsoleReferenceServer, Robotics BinPickingCell / IntentEnabledRobot / MinimalRobotServer, Scales ScalesServer, Vision MachineVisionServer / VisualInspectionCell, WotCon AggregationServer / FlatTagServer, ECM EcmServer (allow-all authorize delegates), PubSub ConsoleReferencePubSubClient (unsecured modes, demo keys).
Clients: AI ModelManagementClient, AMB AmbClient, Machinery MachineryClient, ECM EcmClient, MinimalApi MinimalClient, Vision MachineVisionClient / VisualInspectionAgent, WotCon AggregationClient.
Also: the Lens AppHost pump server launcher, the redundancy compose files, and the sample PKI roots under the temp directory (MinimalApi, FluentApi, Network, Gds Onboarding*, Redundancy).
Acceptance criteria
- A shared helper implements the switches above, and all samples use it.
- With no switch set, every sample server exposes no None endpoint, no anonymous token and no auto-accept, and every sample client validates certificates.
- No hard-coded user accounts in samples or sample container images.
- A startup warning when any insecure switch is enabled.
- Each sample README documents how to connect securely and how to enable demo mode.
- CI sample smoke tests (if any) set the switch explicitly where they need it.
Activity