Token Introspect configuration
Token Introspect validates access tokens and retrieves associated identity data from your Identity Knowledge Graph (IKG).
This Terraform configuration creates a Token Introspect setup that:
1. Accepts an access token containing an email claim.
2. Matches the email claim to a Person node in the IKG.
3. Returns the Person node data if a match is found.
Use case
Scenario: Your application receives access tokens from an identity provider and needs to enrich them with IKG data.
When a user authenticates, the Token Introspect configuration matches the token's email claim to a Person node, allowing your application to access identity attributes and relationships stored in the graph.
Requirements
- ServiceAccount credentials created in the IndyKite Hub for your organization.
- IndyKite Terraform provider 0.49.0 or later, the release the example pins in required_providers; the Terraform guide lists the version each feature first appeared in.
- A Person node with an email property must exist in the IKG for matching to succeed.
Steps
1. Create the Token Introspect configuration using the Terraform file below.
2. Apply the Terraform configuration to your IndyKite project.
3. Call the Token Introspect endpoint with an access token containing an email claim.
4. Receive the matched Person node data in the response.
Create a Token Introspect configuration for a Person node with email claim.
terraform {
required_providers {
indykite = {
source = "indykite/indykite"
version = ">= 0.49.0" # or a later release
}
}
}
# indykite provider integrates IndyKite platform with Terraform scripting.
# Provider for now does not support any parameters and all is set within service account credential file.
provider "indykite" {}
resource "indykite_token_introspect" "token_config" {
name = "terraform-token-introspect"
display_name = "Terraform token introspect"
description = "Token introspect for DigitalTwin access token"
project_id = "gid:AAAAAmluZHlraURlgAABDwAAAAA" # your project GID
jwt_matcher {
issuer = "https://example.com"
audience = "client-id"
}
offline_validation {}
ikg_node_type = "Person"
claims_mapping = {
"email" = "email"
}
perform_upsert = true
}
A standalone alternative to main.tf, for an authorization server that exposes an RFC 7662 token introspection endpoint instead of userinfo; apply it in its own directory, since Terraform loads every .tf file of a directory together and the provider blocks would clash. online_oauth2_validation posts the token to introspection_endpoint with HTTP Basic authentication (client_secret_basic) and accepts it only when the response carries active: true. client_secret is sensitive and write-only, so keep it in a variable; a later apply that changes neither introspection_endpoint nor client_id keeps the stored secret. The endpoint must be https; cache_ttl is in seconds, at most 3600. Needs provider 0.49.0.
terraform {
required_providers {
indykite = {
source = "indykite/indykite"
version = ">= 0.49.0" # online_oauth2_validation exists from 0.49.0
}
}
}
provider "indykite" {}
resource "indykite_token_introspect" "oauth2_introspection" {
name = "oauth2-token-introspect"
display_name = "OAuth 2.0 introspection"
description = "Validates opaque tokens at the authorization server's RFC 7662 introspection endpoint"
project_id = "gid:AAAAAmluZHlraURlgAABDwAAAAA" # your project GID
# An opaque token carries no claims of its own, so it needs one of the two online modes.
opaque_matcher {
hint = "my.domain.com"
}
online_oauth2_validation {
introspection_endpoint = "https://auth.example.com/oauth2/introspect" # must be https
secret_basic {
client_id = "indykite-introspector"
client_secret = var.introspection_client_secret # sensitive, write-only: never returned by the API
}
cache_ttl = 300 # seconds, at most 3600; omit to introspect on every request
}
ikg_node_type = "Person"
perform_upsert = true
}
variable "introspection_client_secret" {
type = string
sensitive = true
}
A standalone alternative to main.tf, for a JWT issuer that publishes RFC 8414 authorization-server metadata rather than an OpenID Connect document; apply it in its own directory for the same reason. offline_validation.discovery = "rfc8414" makes the platform read the jwks_uri from <scheme>://<host>/.well-known/oauth-authorization-server/<issuer path>. Leave discovery out, or set "oidc", for an OpenID issuer; it is ignored when public_jwks pins the keys. Needs provider 0.49.0.
terraform {
required_providers {
indykite = {
source = "indykite/indykite"
version = ">= 0.49.0" # offline_validation.discovery exists from 0.49.0
}
}
}
provider "indykite" {}
resource "indykite_token_introspect" "rfc8414_discovery" {
name = "rfc8414-token-introspect"
display_name = "RFC 8414 discovery"
description = "Validates JWTs with the keys published by the issuer's OAuth 2.0 authorization server metadata"
project_id = "gid:AAAAAmluZHlraURlgAABDwAAAAA" # your project GID
jwt_matcher {
issuer = "https://auth.example.com/tenant-a"
audience = "client-id-of-your-app"
}
# Without public_jwks the keys are fetched from the jwks_uri of a metadata document.
# "oidc" (the default) reads <issuer>/.well-known/openid-configuration;
# "rfc8414" reads https://auth.example.com/.well-known/oauth-authorization-server/tenant-a,
# the well-known suffix inserted between the host and the path of the issuer.
offline_validation {
discovery = "rfc8414"
}
ikg_node_type = "Person"
perform_upsert = true
}