Skip to content

Credentials

Credentials Reference

This page documents all supported credential fields for connecting to a Keycloak instance.

Supported Fields

The credential fields map directly to the Keycloak Terraform Provider configuration.

FieldTypeRequiredDescription
urlstringYesKeycloak server URL
client_idstringYesOAuth2 client ID for authentication
usernamestringConditionalAdmin username
passwordstringConditionalAdmin password
client_secretstringConditionalClient secret (for client credentials grant)
realmstringNoAuthentication realm (defaults to master)
base_pathstringNoURL path prefix (e.g., /auth)
admin_urlstringNoSeparate admin API URL if different from url
root_ca_certificatestringNoPEM-encoded CA certificate for TLS

Authentication Methods

Password Grant (Admin CLI)

The most common method using username and password:

{
  "client_id": "admin-cli",
  "username": "admin",
  "password": "admin",
  "url": "https://keycloak.example.com",
  "realm": "master"
}

Client Credentials Grant

For automated systems using a service account:

{
  "client_id": "my-service-account",
  "client_secret": "client-secret-value",
  "url": "https://keycloak.example.com",
  "realm": "master"
}

URL Validation and Normalization

The provider validates URLs before use:

RuleExample
Must be absolute with schemehttps://keycloak.example.com
No query parametershttps://keycloak.example.com?foo=bar
No fragmentshttps://keycloak.example.com#section
Trailing slash removedhttps://kc.example.com/https://kc.example.com
base_path must start with //auth
base_path: "/" normalized to empty/ → ``
Trailing slash on base_path removed/auth//auth

Custom TLS Certificate

For self-signed or internal CA certificates:

{
  "client_id": "admin-cli",
  "username": "admin",
  "password": "admin",
  "url": "https://keycloak.internal.example.com",
  "root_ca_certificate": "-----BEGIN CERTIFICATE-----\nMIIC...\n-----END CERTIFICATE-----"
}

Base Path

Older versions of Keycloak (before v17) served the application under /auth. Modern versions (Quarkus-based) typically serve at the root path.

Keycloak VersionBase Path
< 17 (WildFly)/auth
≥ 17 (Quarkus)`` (empty)