Skip to main content

Platform Configuration

This guide provides details about the configuration setup for the platform, including the logger, services , and server configurations.

The platform leverages viper to help load configuration.

Deployment Mode

The platform is designed as a modular monolith, meaning that all services are built into and run from the same binary. However, these services can be grouped and run together based on specific needs. The available service groups are:

  • all: Runs every service that is registered within the platform.
  • core: Runs essential services, including policy, authorization, and wellknown services.
  • kas: Runs the Key Access Server (KAS) service.
FieldDescriptionDefaultEnvironment Variable
modeDrives which services to run. Following modes are supported. (all, core, kas)allOPENTDF_MODE

SDK Configuration

The sdk configuration is used when operating the service in mode kas. When running in mode core or all an in-process communication is leveraged over an in-memory grpc server.

Root level key sdk_config

FieldDescriptionDefaultEnvironment Variable
core.endpointThe core platform endpoint to connect toOPENTDF_SDK_CONFIG_ENDPOINT
core.plaintextUse a plaintext grpc connectionfalseOPENTDF_SDK_CONFIG_PLAINTEXT
core.insecureUse an insecure tls connectionfalse
entityresolution.endpointThe entityresolution endpoint to connect to
entityresolution.plaintextUse a plaintext ERS grpc connectionfalse
entityresolution.insecureUse an insecure tls connectionfalse
client_idOAuth client idOPENTDF_SDK_CONFIG_CLIENT_ID
client_secretThe clients credentialsOPENTDF_SDK_CONFIG_CLIENT_SECRET

Logger Configuration

The logger configuration is used to define how the application logs its output.

Root level key logger

FieldDescriptionDefaultEnvironment Variable
levelThe logging level.infoOPENTDF_LOGGER_LEVEL
typeThe format of the log output.jsonOPENTDF_LOGGER_TYPE
outputThe output destination for logs.stdoutOPENTDF_LOGGER_OUTPUT

Example:

logger:
level: debug
type: text
output: stdout

Server Configuration

The server configuration is used to define how the application runs its server.

Root level key server

FieldDescriptionDefaultEnvironment Variable
auth.audienceThe audience for the IDP.OPENTDF_SERVER_AUTH_AUDIENCE
auth.issuerThe issuer for the IDP.OPENTDF_SERVER_AUTH_ISSUER
auth.policyThe Casbin policy for enforcing authorization on endpoints. Described below
auth.cache_refreshInterval in which the IDP jwks should be refreshed15mOPENTDF_SERVER_AUTH_CACHE_REFRESH
auth.dpopskewThe amount of time drift allowed between when the client generated a dpop proof and the server time.1hOPENTDF_SERVER_AUTH
auth.skewThe amount of time drift allowed between a tokens exp claim and the server time.1mOPENTDF_SERVER_AUTH_SKEW
auth.public_client_idThe oidc client id. This is leveraged by otdfctl.OPENTDF_SERVER_AUTH_PUBLIC_CLIENT_ID
auth.enforceDPoPIf true, DPoP bindings on Access Tokens are enforced.falseOPENTDF_SERVER_AUTH_ENFORCEDPOP
cryptoProviderA list of public/private keypairs and their use. Described belowempty
enable_pprofEnable golang performance profilingfalseOPENTDF_SERVER_ENABLE_PPROF
grpc.reflectionThe configuration for the grpc server.trueOPENTDF_SERVER_GRPC_REFLECTION
hostThe host address for the server.""OPENTDF_SERVER_HOST
portThe port number for the server.9000OPENTDF_SERVER_PORT
tls.enabledEnable tls.falseOPENTDF_SERVER_TLS_ENABLED
tls.certThe path to the tls certificate.OPENTDF_SERVER_TLS_CERT
tls.keyThe path to the tls key.OPENTDF_SERVER_TLS_KEY

Example:

server:
grpc:
reflection: true
port: 8081
tls:
enabled: true
cert: /path/to/cert
key: /path/to/key
auth:
enabled: true
audience: https://example.com
issuer: https://example.com
cryptoProvider:
standard:
keys:
- kid: r1
alg: rsa:2048
private: kas-private.pem
cert: kas-cert.pem
- kid: e1
alg: ec:secp256r1
private: kas-ec-private.pem
cert: kas-ec-cert.pem

Crypto Provider

To configure the Key Access Server, you must define a set of one or more public keypairs and a method for loading and using them.

The crypto provider is implemented as an interface, allowing multiple implementations.

Root level key cryptoProvider

Environment Variable: OPENTDF_SERVER_CRYPTOPROVIDER_STANDARD='[{"alg":"rsa:2048","kid":"k1","private":"kas-private.pem","cert":"kas-cert.pem"}]'

FieldDescriptionDefault
cryptoProvider.typeThe type of crypto provider to use.standard
cryptoProvider.standard.*.algAn enum for the associated crypto type. E.g. rsa:2048 or ec:secp256r1
cryptoProvider.standard.*.kidA short, globally unique, stable identifier for this keypair.
cryptoProvider.standard.*.privatePath to the private key as a PEM file.
cryptoProvider.standard.*.cert(Optional) Path to a public cert for the keypair.

Database Configuration

The database configuration is used to define how the application connects to its database.

Root level key db

FieldDescriptionDefaultEnvironment Variables
hostThe host address for the database.localhostOPENTDF_DB_HOST
portThe port number for the database.5432OPENTDF_DB_PORT
databaseThe name of the database.opentdfOPENTDF_DB_DATABASE
userThe username for the database.postgresOPENTDF_DB_USER
passwordThe password for the database.changemeOPENTDF_DB_PASSWORD
sslmodeThe ssl mode for the databasepreferOPENTDF_DB_SSLMODE
schemaThe schema for the database.opentdfOPENTDF_DB_SCHEMA
runMigrationWhether to run the database migration or not.trueOPENTDF_DB_RUNMIGRATION

Example:

db:
host: localhost
port: 5432
database: opentdf
user: postgres
password: changeme
sslmode: require
schema: opentdf
runMigration: false

Services Configuration

Root level key services

Key Access Server (KAS)

Root level key kas

Environment Variable: OPENTDF_SERVICES_KAS_KEYRING='[{"kid":"k1","alg":"rsa:2048"},{"kid":"k2","alg":"ec:secp256r1"}]'

FieldDescriptionDefault
keyring.*.kidWhich key id this is binding
keyring.*.alg(Optional) Associated algorithm. (Allows reusing KID with different algorithms)
keyring.*.legacyIndicates this may be used for TDFs with no key ID; default if all unspecified.inferred

Example:

services:
kas:
enabled: true
keyring:
- kid: e2
alg: ec:secp256r1
- kid: e1
alg: ec:secp256r1
legacy: true
- kid: r2f
alg: rsa:2048
- kid: r1
alg: rsa:2048
legacy: true

Authorization

Root level key authorization

FieldDescriptionDefaultEnvironment Variables
rego.pathPath to rego policy fileLeverages embedded rego policyOPENTDF_SERVICES_AUTHORIZATION_REGO_PATH
rego.queryRego query to execute in policydata.opentdf.entitlements.attributesOPENTDF_SERVICES_AUTHORIZATION_REGO_QUERY

Example:

services:
authorization:
rego:
path: /path/to/policy.rego
query: data.opentdf.entitlements.attributes

Policy

Root level key policy

FieldDescriptionDefaultEnvironment Variables
list_request_limit_defaultPolicy List request limit default when not provided1000OPENTDF_SERVICES_POLICY_LIST_REQUEST_LIMIT_DEFAULT
list_request_limit_maxPolicy List request limit maximum enforced by services2500OPENTDF_SERVICES_POLICY_LIST_REQUEST_LIMIT_MAX

Example:

services:
policy:
list_request_limit_default: 1000
list_request_limit_max: 2500

Casbin Endpoint Authorization

OpenTDF uses Casbin to manage authorization policies. This document provides an overview of how to configure and manage the default authorization policy in OpenTDF.

Key Aspects of Authorization Configuration

  1. Username Claim: The claim in the OIDC token that should be used to extract a username.
  2. Group Claim: The claim in the OIDC token that should be used to find the group claims.
  3. Map (Deprecated): Mapping between policy roles and IdP roles.
  4. Extension: Policy that will extend the builtin policy
  5. CSV: The authorization policy in CSV format. This will override the builtin policy.
  6. Model: The Casbin policy model. This should only be set if you have a deep understanding of how casbin works.

Configuration in opentdf-example.yaml

Below is an example configuration snippet from opentdf-example.yaml:

server:
auth:
enabled: true
enforceDPoP: false
public_client_id: 'opentdf-public'
audience: 'http://localhost:8080'
issuer: http://keycloak:8888/auth/realms/opentdf
policy:

## Deprecated
## Dot notation is used to access nested claims (i.e. realm_access.roles)
claim: "realm_access.roles"

## Dot notation is used to access the username claim
username_claim: "email"

## Dot notation is used to access the groups claim
group_claim: "realm_access.roles"

## Deprecated: Use standard casbin policy groupings (g, <user/group>, <role>)
## Maps the external role to the OpenTDF role
## Note: left side is used in the policy, right side is the external role
map:
standard: opentdf-standard
admin: opentdf-admin

## Policy that will extend the builtin policy.
extension: |
p, role:admin, *, *, allow
p, role:standard, policy:attributes, read, allow
p, role:standard, policy:subject-mappings, read, allow
g, opentdf-admin, role:admin
g, alice@opentdf.io, role:standard

## Custom policy (see examples https://github.com/casbin/casbin/tree/master/examples)
## This will overwrite the builtin policy. Use with caution.
csv: |
p, role:admin, *, *, allow
p, role:standard, policy:attributes, read, allow
p, role:standard, policy:subject-mappings, read, allow
p, role:standard, policy:resource-mappings, read, allow
p, role:standard, policy:kas-registry, read, allow
p, role:unknown, entityresolution.EntityResolutionService.ResolveEntities, write, allow
p, role:unknown, kas.AccessService/Rewrap, *, allow

## Custom model (see https://casbin.org/docs/syntax-for-models/)
## Avoid setting this unless you have a deep understanding of how casbin works.
model: |
[request_definition]
r = sub, res, act, obj

[policy_definition]
p = sub, res, act, obj, eft

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow)) && !some(where (p.eft == deny))

[matchers]
m = g(r.sub, p.sub) && globOrRegexMatch(r.res, p.res) && globOrRegexMatch(r.act, p.act) && globOrRegexMatch(r.obj, p.obj)

Role Permissions

  • Admin: Can perform all operations.
  • Standard User: Can read.
  • Public Endpoints: Accessible without specific roles.

Managing Authorization Policy

Admins can manage the authorization policy directly in the YAML configuration file. For detailed configuration options, refer to the Casbin documentation.