This is the Canonical Identity Platform Hook Service used for handling Hydra Hooks and managing groups. It integrates with Ory Kratos for identity management, Ory Hydra for OAuth2/OIDC flows, OpenFGA for fine-grained authorization, and optional Salesforce for group management.
The application is configured via environment variables.
| Variable | Description | Default |
|---|---|---|
OTEL_GRPC_ENDPOINT |
OTel gRPC endpoint for traces | |
OTEL_HTTP_ENDPOINT |
OTel HTTP endpoint for traces | |
TRACING_ENABLED |
Enable tracing | true |
LOG_LEVEL |
Log level (debug, info, warn, error) |
error |
DEBUG |
Enable debug mode | false |
PORT |
HTTP server port | 8080 |
API_TOKEN |
Token for API authentication | |
OPENFGA_API_SCHEME |
OpenFGA API scheme | |
OPENFGA_API_HOST |
OpenFGA API host | |
OPENFGA_API_TOKEN |
OpenFGA API token | |
OPENFGA_STORE_ID |
OpenFGA store ID | |
OPENFGA_AUTHORIZATION_MODEL_ID |
OpenFGA authorization model ID | |
SALESFORCE_ENABLED |
Enable Salesforce integration | true |
SALESFORCE_DOMAIN |
Salesforce domain | |
SALESFORCE_CONSUMER_KEY |
Salesforce consumer key | |
SALESFORCE_CONSUMER_SECRET |
Salesforce consumer secret | |
AUTHORIZATION_ENABLED |
Enable authorization middleware | false |
OPENFGA_WORKERS_TOTAL |
Total OpenFGA workers | 150 |
AUTHENTICATION_ENABLED |
Enable JWT authentication for Groups/Authz APIs | true |
AUTHENTICATION_ISSUER |
Expected JWT issuer (e.g., https://auth.example.com) |
|
AUTHENTICATION_JWKS_URL |
Optional explicit JWKS URL (overrides OIDC discovery) | |
AUTHENTICATION_ALLOWED_SUBJECTS |
Comma-separated list of allowed JWT subjects | |
AUTHENTICATION_REQUIRED_SCOPE |
Required scope for access (e.g., hook-service:admin) |
|
DSN |
Database connection string (Required) | |
DB_MAX_CONNS |
Max DB connections | 25 |
DB_MIN_CONNS |
Min DB connections | 2 |
DB_MAX_CONN_LIFETIME |
Max DB connection lifetime | 1h |
DB_MAX_CONN_IDLE_TIME |
Max DB connection idle time | 30m |
The Groups and Authorization APIs (/api/v0/authz) are protected by JWT authentication middleware. When enabled, all requests to these endpoints must include a valid JWT token in the Authorization header.
Configuration:
AUTHENTICATION_ENABLED: Set totrueto enable JWT authentication (default:true)AUTHENTICATION_ISSUER: The expected JWT issuer URL. Used for OIDC metadata discovery to fetch JWKS or to verify theissclaim when using manual JWKS URLAUTHENTICATION_JWKS_URL: (Optional) Explicit JWKS URL. If set, fetches keys from this URL instead of using OIDC discoveryAUTHENTICATION_ALLOWED_SUBJECTS: Comma-separated list of allowed JWTsubclaimsAUTHENTICATION_REQUIRED_SCOPE: (Optional) A specific scope that grants access (e.g.,hook-service:admin)
JWKS Configuration:
The middleware supports two modes for fetching JWKS:
- OIDC Discovery (default): Discovers JWKS URL from
{AUTHENTICATION_ISSUER}/.well-known/openid-configuration - Manual JWKS URL: If
AUTHENTICATION_JWKS_URLis set, fetches keys directly from that URL
Use manual JWKS URL when the issuer is not an OIDC provider or when OIDC discovery is not available.
Authorization Logic:
A request is authorized if either:
- The JWT's
subclaim matches one of theAUTHENTICATION_ALLOWED_SUBJECTS, OR - The JWT's
scopeorscpclaim contains theAUTHENTICATION_REQUIRED_SCOPE
Usage:
# Include JWT token in Authorization header
curl -H "Authorization: Bearer <jwt-token>" http://localhost:8080/api/v0/authz/groups- Go 1.25+
- Make
- Docker
- Rockcraft (for building the container image)
To build the application binary:
make buildThis produces a binary named app in the current directory.
To build the OCI image using Rockcraft:
rockcraft packThis will produce a .rock file which can be imported into Docker.
The E2E tests are located in tests/e2e and run in a separate module to isolate test dependencies.
To run the E2E tests:
make test-e2eThis command will:
- Switch to the
tests/e2edirectory. - Spin up the required environment (Postgres, Hydra, Kratos, OpenFGA) using Testcontainers.
- Run the tests.
You can start a full local development environment including dependencies:
make dev
# or
./start.shThis starts Kratos, Hydra, OpenFGA, Postgres, and Mailslurper using docker-compose.dev.yml.
The service adds user groups to OAuth2/OIDC tokens via the Hydra token hook. By default, Hydra would nest custom claims under an ext namespace. To ensure groups appear as a top-level claim in access tokens, the Hydra configuration includes:
oauth2:
allowed_top_level_claims:
- groups
mirror_top_level_claims: falseThis configuration is set in docker/hydra/hydra.yml for local development. For production deployments, ensure your Hydra instance is configured with these settings to make the groups claim accessible at the top level of the token payload.
Please see SECURITY.md for guidelines on reporting security issues.