keenauth_directory

The keenauth_directory resource creates a SCIM 2.0 directory for an organization. A directory is the endpoint that the organization's identity provider (Okta, Entra ID and others) provisions users and groups to.

resource "keenauth_directory" "acme_okta" {
  organization_id = keenauth_organization.acme.id
  name            = "Okta"
  scim_host       = "acme.eu.keenauth.app"
}

output "scim_base_url" {
  value = keenauth_directory.acme_okta.base_url
}

base_url is https://<scim_host>/scim/v2/<id>. Give it to the identity provider together with a SCIM token.

Changes in place and replacements

name and the directory settings change in place. The provider sends a JSON merge patch with only the changed fields and the ETag of the last read as If-Match; if the directory changed outside this configuration after that read, the API answers 412, nothing is changed, and you run plan again. The API takes no settings when it creates a directory, so the settings you configure are applied right after the create, in the same apply.

Changing organization_id, scim_host or type replaces the directory.

Settings

resource "keenauth_directory" "acme_okta" {
  organization_id = keenauth_organization.acme.id
  name            = "Okta"
  scim_host       = "acme.eu.keenauth.app"

  provisioning_mode   = "user_store"
  attribute_allowlist = ["title", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:user:department"]
  delete_action       = "remove_membership"

  mass_deprovision_guard = {
    percent      = 20
    absolute_min = 50
  }
}
Setting Values Default
provisioning_mode user_store (environment users, organization memberships and group roles are written) or mirror (only directory records are kept) user_store
attribute_allowlist Up to 40 optional SCIM attributes kept on directory users: title, usertype, phonenumbers and the enterprise extension keys empty
unverified_domain_action invite or mirror_only, for a user whose email domain is not verified for the organization invite
delete_action remove_membership or delete_user, for a SCIM DELETE /Users remove_membership
on_delete_memberships keep, suspend or remove, for memberships from the directory when it is deleted keep
mass_deprovision_guard enabled, percent (5 to 50) and absolute_min (10 to 1000); more deprovisionings than both within 5 minutes are held for approval on, 10, 25
send_welcome_email true or false: an account activation email for new directory users false

SCIM tokens

The SCIM token is a secret. The API returns it once, in the response that creates the directory, and no endpoint can read it afterwards. The provider never writes it to state, a plan file, an output or a log. To keep that guarantee, and so that no valid credential exists that nobody holds, the provider revokes the token that the create returns right away.

Create the token for your identity provider with keenauth_directory_token. It keeps the token in state only encrypted to your RSA public key, and you decrypt it with your private key.

If the provider cannot revoke the initial token, the apply still succeeds and prints a warning with the command that revokes it (keenauth directories tokens delete <directory_id> <token_id>).

Arguments

Import

Import by directory ID:

tofu import keenauth_directory.acme_okta dir_01j9zq3v8c5m2x7k4t6r1n0b3d