Skip to content

Security and compliance

This page sets the engineering security rules for ConnectSoft code, templates and pipelines. It is written for engineers and AI agents who write or review code that handles secrets, identity, tokens or sensitive data.

The company security and compliance policy (objectives, compliance roadmap, business responsibilities) stays in the CompanyDocumentation security and governance pages. The identity architecture is described in the ConnectSoft Identity Platform Blueprint and ADR-0101. What may be logged is set by CS-LOG-005.

Rules

CS-SEC-001: Never commit a secret

Severity: blocker · Applies to: service, library, api-client, blazor, template, docs, pipelines · Enforced by: manual (target: ENF-006, ENF-022) · Status: active

Why

A committed secret stays in Git history, and in every copy of a template, after the file is fixed. The only remedy is to revoke the secret, which can break every system that uses it. Templates multiply the damage, because they copy their files into every generated service.

Do

  • At runtime, load secrets from Azure Key Vault, environment variables or user secrets through the configuration providers.
  • In pipelines, use secret variables, variable groups linked to Key Vault, or service connections.
  • In nuget.config, authenticate feeds with NuGetAuthenticate@1 in pipelines and a credential provider locally. When a credential must be written in the file, reference an environment variable: value="%FEED_TOKEN%".
  • When a secret has been committed, revoke it first, then remove it from the files.

Don't

Commit any of these to a repository, in any file: - passwords and connection strings that contain credentials; - tokens and API keys; - client secrets; - private keys and certificates; - feed credentials.

The files where these turn up include nuget.config, appsettings*.json, pipeline YAML, test settings, scripts and documentation.

A licence key for a commercial package (for example AutoMapper or MassTransit) is not a credential. It does not grant access to any system, so it may be committed in appsettings*.json. Dependency licensing covers how to wire it.

Example

<!-- Don't -->
<add key="ClearTextPassword" value="pat-value-here" />

<!-- Do -->
<add key="ClearTextPassword" value="%CONNECTSOFT_FEED_TOKEN%" />

How to check

  • Search the diff for ClearTextPassword, Password=, pwd=, AccountKey=, SharedAccessKey=, client_secret, -----BEGIN and long random strings.
  • Every match is a placeholder or a reference to a secret store.

CS-SEC-002: Validate every token in the resource API

Severity: blocker · Applies to: service · Enforced by: manual · Status: active

Why

A resource API that accepts a token without checking issuer, audience, expiry and scope accepts tokens issued for other APIs, other tenants or by other issuers.

Do

  • Validate the issuer, audience, lifetime and signature of every bearer token. The ConnectSoft templates do this by default.
  • Check the tenant context and the required scopes or roles for the operation.
  • Treat the API Gateway's coarse checks as a first line, not as a replacement. Resource-level and record-level authorization happen in the backend API.

Don't

  • Turn off issuer, audience or lifetime validation, including in a non-production configuration that may be deployed.
  • Trust a user or tenant identifier taken from a request header or body in place of the validated token.

How to check

  • The authentication setup validates issuer, audience and lifetime.
  • Each protected endpoint requires the scope, role or policy for its operation.
  • The authentication setup also validates the signature: it does not set RequireSignedTokens or ValidateIssuerSigningKey to false.
  • New code takes user and tenant ids from the claims of the validated token, not from a request header or body.

CS-SEC-003: Trust gateway-propagated identity only on internal paths

Severity: blocker · Applies to: service · Enforced by: manual · Status: active

Why

The gateway forwards user and tenant context in headers. If a backend accepts those headers from any caller, anyone who can reach the backend can claim any identity.

Do

  • Accept gateway-propagated identity headers only on network paths that are reachable from the gateway alone.
  • Where bearer protection is required, validate the token even when identity headers are present.

Don't

  • Expose a backend that trusts identity headers to callers that bypass the gateway.

How to check

Code that reads identity from headers runs only behind the gateway, and the endpoint still requires a validated token where bearer protection applies.

CS-SEC-004: Use only the approved OAuth and OpenID Connect flows

Severity: major · Applies to: service, blazor, api-client, template · Enforced by: manual · Status: active

Why

The implicit flow and the resource owner password flow expose tokens or passwords to clients and are deprecated by the OAuth security best current practice.

Do

  • Use the authorization code flow with PKCE for browser and mobile clients, or a backend-for-frontend.
  • Use the client credentials flow, a service principal or a managed identity for service-to-service calls.
  • Require MFA for administrators and privileged operations.

Don't

  • Use the implicit flow or the resource owner password flow in new systems.
  • Store long-lived secrets in a Blazor WebAssembly, MAUI or other public client.

How to check

  • New client registrations and authentication handlers use authorization code with PKCE, or client credentials, and no public client holds a secret.
  • New administrator roles and privileged operations require MFA, through a policy or a claim check.

CS-SEC-005: Grant the least privilege

Severity: major · Applies to: service, pipelines, template · Enforced by: manual · Status: active

Why

Every extra permission widens what an attacker can do with a stolen token, identity or connection string.

Do

  • Give each client, service identity, database login and pipeline service connection only the scopes and permissions it uses.
  • Scope access tokens to the audiences and operations the caller needs.

Don't

  • Reuse one administrative identity, client secret or database login across several services.
  • Grant a wildcard scope or an owner role to make a call succeed.

How to check

New scopes, roles, database grants and service connections in the change are limited to what the code calls.

CS-SEC-006: Encrypt in transit and protect sensitive data

Severity: major · Applies to: service, template · Enforced by: manual · Status: active

Why

Confidential and sensitive data, such as personal and financial data, needs protection wherever it is sent or stored, including logs and test environments.

Do

  • Use HTTPS and TLS for every connection that leaves the process.
  • Classify the data a feature handles as public, internal, confidential or sensitive. Encrypt confidential and sensitive data at rest.
  • Mask or redact sensitive data in logs, audit events and test data.

Don't

  • Disable certificate validation, other than for a local development certificate in a development-only configuration.
  • Copy production personal data into development or test environments.

How to check

  • New outbound connections use HTTPS or TLS, and no certificate validation is disabled outside development.
  • Sensitive fields are not logged or copied into test data.
  • New columns or stores that hold confidential or sensitive data are encrypted at rest.