Octopus
1.x
Docs/Octopus/Authentication & authorization
Open

Reading6 min
Updated31 Jul 2026
Sourcev1/configuration/auth.mdx

Authentication & authorization

This page is the configuration reference for the auth_providers, auth, and cors sections. For the request flow and conceptual depth, see the Security section.

Authentication providers are declared once under auth_providers (a map keyed by provider name) and referenced by name from the global auth block or from a route's auth_provider field. A single auth-gateway middleware enforces both authentication and authorization; it is enabled when any provider is defined or when auth.global_enforce is true.

auth_providers:
  primary-jwt:
    type: jwt
    secret: "${JWT_SECRET}"
    algorithm: HS256
    issuer: https://auth.example.com

auth:
  default_provider: primary-jwt
  global_enforce: true
  skip_paths: ["/health", "/public/*"]
  authz:
    engine: rhai

Auth providers01

auth_providers is a map from provider name to a provider definition. Each definition is tagged by a type field (jwt, oidc, api_key, forward_auth, or mtls).

yaml
auth_providers:
  primary-jwt:
    type: jwt
    secret: "${JWT_SECRET}"
    algorithm: HS256
    issuer: https://auth.example.com
    audience: my-api

auth02

Global authentication settings. All fields have defaults, so the whole block is optional.

auth:
  default_provider: primary-jwt
  global_enforce: true
  skip_paths: ["/health", "/public/*"]
  token_cache_ttl: 60s
  error_format: json
KeyTypeDefaultDescription
default_providerstringnoneProvider applied to routes without an explicit auth_provider.
global_enforcebooleanfalseRequire auth on all routes unless skip_auth or matched by skip_paths.
skip_pathsarray of string[]Paths exempt from authentication (supports wildcards).
principal_headerstringX-Auth-PrincipalHeader injected with the authenticated principal ID.
roles_headerstringX-Auth-RolesHeader injected with the principal's roles.
scopes_headerstringX-Auth-ScopesHeader injected with the authenticated scopes.
token_cache_ttlduration60sCache validated tokens for this duration.
error_formatstringjsonError response format: json or text.
authzobjectRhai engineAuthorization settings. See below.

Authz03

auth.authz selects the authorization engine and holds global rules.

auth:
  authz:
    engine: both
    global_rules:
      - name: deny-internal
        rule: 'request.path.starts_with("/internal")'
        action: deny
    opa:
      endpoint: http://opa:8181/v1/data/octopus/allow
      timeout: 100ms
      cache_ttl: 5m
      fail_open: false
KeyTypeDefaultDescription
enginestringrhaiAuthorization engine: rhai, opa, or both.
global_rulesarray[]Rules applied to all authenticated requests. See below.
opaobjectnoneOPA integration settings. See below.

global_rules[] entries (AuthzRule):

KeyTypeDefaultDescription
namestringRule name. Required.
descriptionstringnoneOptional description.
enginestringinheritsOverride engine for this rule (rhai, opa, or both).
rulestringRhai expression or OPA policy path. Required.
actionstringallowAction when the rule matches: allow or deny.

opa object (OpaConfig):

KeyTypeDefaultDescription
endpointstringOPA REST API endpoint. Required.
timeoutduration100msRequest timeout.
cache_ttlduration5mCache OPA decisions for this duration.
fail_openbooleanfalseAllow the request if OPA is unreachable.

Global CORS04

The top-level cors section sets a global CORS policy. Individual routes can override it with routes[].cors (see Routes).

cors:
  allowed_origins: ["https://app.example.com"]
  allowed_methods: [GET, POST, PUT, DELETE, OPTIONS]
  allowed_headers: [Authorization, Content-Type]
  exposed_headers: [X-Request-Id]
  max_age: 3600
  allow_credentials: true
KeyTypeDefaultDescription
allowed_originsarray of string[]Permitted origins (use ["*"] with care).
allowed_methodsarray of string[GET, POST, PUT, DELETE, OPTIONS]Permitted HTTP methods.
allowed_headersarray of string[]Permitted request headers.
exposed_headersarray of string[]Response headers exposed to the browser.
max_ageinteger (seconds)3600Preflight cache max age.
allow_credentialsbooleanfalseAllow credentials (cookies, auth headers).
Note

Authorization rules use the embedded Rhai engine, an external OPA service, or both. See Security for guidance on writing rules and policies.