Skip to content

Kerberos auth method initial implementation of resources and ephemeral resources#2819

Open
vijayavelsekar wants to merge 41 commits intomainfrom
VAULT-42404-Kerberos-Auth-Method-Implementation
Open

Kerberos auth method initial implementation of resources and ephemeral resources#2819
vijayavelsekar wants to merge 41 commits intomainfrom
VAULT-42404-Kerberos-Auth-Method-Implementation

Conversation

@vijayavelsekar
Copy link
Copy Markdown
Contributor

@vijayavelsekar vijayavelsekar commented Mar 11, 2026

Description

Initial implementation for below resources and ephemeral resource.

  1. vault_kerberos_auth_backend_config (Resource)
  2. vault_kerberos_auth_backend_ldap_config (Resource)
  3. vault_kerberos_auth_backend_group (Resource)
  4. vault_kerberos_auth_backend_login (Ephemeral Resource)

Note:-
This PR updates the TestDataSourceAuthBackends acceptance test because it runs concurrently with Kerberos test cases. During concurrent execution, the auth backends created by the Kerberos tests conflict with those used by the data source auth backend tests. To avoid this conflict, the TestDataSourceAuthBackends test has been updated to validate only the backends that it explicitly creates.

Closes #1723

Checklist

  • Added CHANGELOG entry (only for user-facing changes)
  • Acceptance tests where run against all supported Vault Versions

Output from acceptance testing:

go test -v ./internal/vault/auth/kerberos -run="TestAccKerberosAuthBackendConfig|TestAccKerberosAuthBackendLDAPConfig|TestAccKerberosAuthBackendGroup" -count=1
=== RUN   TestAccKerberosAuthBackendConfig_basic
--- PASS: TestAccKerberosAuthBackendConfig_basic (1.32s)
=== RUN   TestAccKerberosAuthBackendConfig_update
--- PASS: TestAccKerberosAuthBackendConfig_update (1.99s)
=== RUN   TestAccKerberosAuthBackendConfig_keytabUpdate
--- PASS: TestAccKerberosAuthBackendConfig_keytabUpdate (1.93s)
=== RUN   TestAccKerberosAuthBackendConfig_import
--- PASS: TestAccKerberosAuthBackendConfig_import (1.41s)
=== RUN   TestAccKerberosAuthBackendConfig_defaultCheck
--- PASS: TestAccKerberosAuthBackendConfig_defaultCheck (1.15s)
=== RUN   TestAccKerberosAuthBackendConfig_pathChange
--- PASS: TestAccKerberosAuthBackendConfig_pathChange (3.11s)
=== RUN   TestAccKerberosAuthBackendConfig_validationErrors
--- PASS: TestAccKerberosAuthBackendConfig_validationErrors (1.20s)
=== RUN   TestAccKerberosAuthBackendConfig_runtimeErrors
--- PASS: TestAccKerberosAuthBackendConfig_runtimeErrors (0.97s)
=== RUN   TestAccKerberosAuthBackendConfig_importErrors
--- PASS: TestAccKerberosAuthBackendConfig_importErrors (0.71s)
=== RUN   TestAccKerberosAuthBackendConfig_namespace
--- PASS: TestAccKerberosAuthBackendConfig_namespace (2.52s)
=== RUN   TestAccKerberosAuthBackendConfig_importWithNamespace
--- PASS: TestAccKerberosAuthBackendConfig_importWithNamespace (2.97s)
=== RUN   TestAccKerberosAuthBackendGroup_basic
--- PASS: TestAccKerberosAuthBackendGroup_basic (2.53s)
=== RUN   TestAccKerberosAuthBackendGroup_defaultCheck
--- PASS: TestAccKerberosAuthBackendGroup_defaultCheck (1.17s)
=== RUN   TestAccKerberosAuthBackendGroup_pathChange
--- PASS: TestAccKerberosAuthBackendGroup_pathChange (3.44s)
=== RUN   TestAccKerberosAuthBackendGroup_nameChange
--- PASS: TestAccKerberosAuthBackendGroup_nameChange (2.61s)
=== RUN   TestAccKerberosAuthBackendGroup_noPolicies
--- PASS: TestAccKerberosAuthBackendGroup_noPolicies (1.41s)
=== RUN   TestAccKerberosAuthBackendGroup_namespace
--- PASS: TestAccKerberosAuthBackendGroup_namespace (3.10s)
=== RUN   TestAccKerberosAuthBackendGroup_invalid
--- PASS: TestAccKerberosAuthBackendGroup_invalid (0.57s)
=== RUN   TestAccKerberosAuthBackendGroup_invalidNamespace
--- PASS: TestAccKerberosAuthBackendGroup_invalidNamespace (0.88s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_basic
--- PASS: TestAccKerberosAuthBackendLDAPConfig_basic (1.31s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_update
--- PASS: TestAccKerberosAuthBackendLDAPConfig_update (2.14s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_bindPassUpdate
--- PASS: TestAccKerberosAuthBackendLDAPConfig_bindPassUpdate (2.33s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_import
--- PASS: TestAccKerberosAuthBackendLDAPConfig_import (1.59s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_defaultCheck
--- PASS: TestAccKerberosAuthBackendLDAPConfig_defaultCheck (1.23s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_pathChange
--- PASS: TestAccKerberosAuthBackendLDAPConfig_pathChange (3.36s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_validationErrors
--- PASS: TestAccKerberosAuthBackendLDAPConfig_validationErrors (0.32s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_runtimeErrors
--- PASS: TestAccKerberosAuthBackendLDAPConfig_runtimeErrors (0.38s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_batchTokenWithNumUses
--- PASS: TestAccKerberosAuthBackendLDAPConfig_batchTokenWithNumUses (0.64s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_configNotFound
--- PASS: TestAccKerberosAuthBackendLDAPConfig_configNotFound (1.77s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_importErrors
--- PASS: TestAccKerberosAuthBackendLDAPConfig_importErrors (0.75s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_allFields
--- PASS: TestAccKerberosAuthBackendLDAPConfig_allFields (1.15s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_aliasMetadata
    kerberos_ldap_config_resource_test.go:464: Vault server version "1.21.0+ent"
--- PASS: TestAccKerberosAuthBackendLDAPConfig_aliasMetadata (2.21s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_enableSAMAccountNameLogin
    kerberos_ldap_config_resource_test.go:502: Vault server version "1.21.0+ent"
--- PASS: TestAccKerberosAuthBackendLDAPConfig_enableSAMAccountNameLogin (2.41s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_namespace
--- PASS: TestAccKerberosAuthBackendLDAPConfig_namespace (2.80s)
=== RUN   TestAccKerberosAuthBackendLDAPConfig_importWithNamespace
--- PASS: TestAccKerberosAuthBackendLDAPConfig_importWithNamespace (3.22s)
PASS
ok      github.com/hashicorp/terraform-provider-vault/internal/vault/auth/kerberos      63.278s

go test -v ./internal/vault/auth/ephemeral -run TestAccKerberosAuthBackendLoginEphemeralResource -count=1
=== RUN   TestAccKerberosAuthBackendLoginEphemeralResource_basic
    kerberos_login_test.go:57: Vault server version "1.21.0+ent"
--- PASS: TestAccKerberosAuthBackendLoginEphemeralResource_basic (3.47s)
=== RUN   TestAccKerberosAuthBackendLoginEphemeralResource_withOptions
    kerberos_login_test.go:181: Vault server version "1.21.0+ent"
--- PASS: TestAccKerberosAuthBackendLoginEphemeralResource_withOptions (3.31s)
=== RUN   TestAccKerberosAuthBackendLoginEphemeralResource_namespace
    kerberos_login_test.go:286: Vault server version "1.21.0+ent"
--- PASS: TestAccKerberosAuthBackendLoginEphemeralResource_namespace (4.17s)
PASS
ok      github.com/hashicorp/terraform-provider-vault/internal/vault/auth/ephemeral     12.412s

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@vijayavelsekar vijayavelsekar changed the title Vault 42404 kerberos auth method implementation Kerberos auth method initial implementation of resources and ephemeral resources Mar 11, 2026
@vijayavelsekar vijayavelsekar marked this pull request as ready for review March 11, 2026 14:49
@vijayavelsekar vijayavelsekar requested review from a team as code owners March 11, 2026 14:49
Copy link
Copy Markdown
Contributor

@harshit-nema harshit-nema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review comments for config_resource.

Comment thread internal/vault/auth/kerberos/kerberos_config_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_config_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_config_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_config_resource_test.go
Comment thread internal/vault/auth/kerberos/kerberos_config_resource_test.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_config_resource_test.go
Copy link
Copy Markdown
Contributor

@harshit-nema harshit-nema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sharing few review comments for kerberos_ldap_config_resource.

Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource_test.go
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource_test.go
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource_test.go
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource_test.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial Terraform Plugin Framework support for Vault’s Kerberos auth method, including 3 new managed resources (backend config, LDAP config, group mappings) and 1 new ephemeral resource for Kerberos login/token issuance, plus accompanying docs and acceptance tests.

Changes:

  • Introduce Kerberos auth resources: vault_kerberos_auth_backend_config, vault_kerberos_auth_backend_ldap_config, vault_kerberos_auth_backend_group.
  • Add Kerberos login ephemeral resource: vault_kerberos_auth_backend_login (revokes token on close).
  • Add new docs + acceptance tests, and adjust vault_auth_backends data source test to avoid concurrent backend conflicts.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
website/docs/r/kerberos_auth_backend_ldap_config.html.md New resource docs for Kerberos LDAP configuration, including token fields and import instructions.
website/docs/r/kerberos_auth_backend_group.html.md New resource docs for mapping LDAP groups to Vault policies under Kerberos auth.
website/docs/r/kerberos_auth_backend_config.html.md New resource docs for configuring Kerberos backend (keytab/service account).
website/docs/ephemeral-resources/kerberos_auth_backend_login.html.md New ephemeral resource docs for Kerberos login and ephemeral token usage.
vault/data_source_auth_backends_test.go Updates acceptance test assertions to avoid conflicts with concurrently-created Kerberos backends.
testutil/testutil.go Adds helper + struct for skipping Kerberos tests unless required env vars are present.
internal/vault/auth/kerberos/kerberos_ldap_config_resource_test.go Adds acceptance test coverage for Kerberos LDAP config resource (defaults, updates, import, namespace, etc.).
internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Implements Kerberos LDAP config resource using the Plugin Framework + token field helpers.
internal/vault/auth/kerberos/kerberos_group_resource_test.go Adds acceptance tests for Kerberos group resource behavior (CRUD/import/namespace/errors).
internal/vault/auth/kerberos/kerberos_group_resource.go Implements Kerberos group mapping resource (policies for LDAP groups).
internal/vault/auth/kerberos/kerberos_config_resource_test.go Adds acceptance tests for Kerberos backend config resource (CRUD/import/defaults/errors/namespace).
internal/vault/auth/kerberos/kerberos_config_resource.go Implements Kerberos backend config resource (write-only keytab, service account, options).
internal/vault/auth/ephemeral/kerberos_login_test.go Adds acceptance tests for Kerberos login ephemeral resource (basic/options/namespace).
internal/vault/auth/ephemeral/kerberos_login.go Implements Kerberos login ephemeral resource (SPNEGO auth header + token revocation on Close).
internal/provider/fwprovider/provider.go Registers the new Kerberos resources and ephemeral resource with the framework provider.
internal/consts/consts.go Adds missing consts used by Kerberos resources/ephemeral outputs (e.g., identity_policies, keytab, client TLS WO fields).
CHANGELOG.md Adds changelog entry for the new Kerberos resources and ephemeral login.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/docs/r/kerberos_auth_backend_config.html.md Outdated
Comment thread website/docs/r/kerberos_auth_backend_ldap_config.html.md Outdated
Comment thread website/docs/r/kerberos_auth_backend_ldap_config.html.md Outdated
Comment thread internal/vault/auth/kerberos/kerberos_login.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_login.go Outdated
Comment thread website/docs/ephemeral-resources/kerberos_auth_backend_login.html.md Outdated
Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource_test.go Outdated
@vijayavelsekar vijayavelsekar added this to the 5.9.0 milestone Mar 13, 2026
@vijayavelsekar vijayavelsekar force-pushed the VAULT-42404-Kerberos-Auth-Method-Implementation branch from ddd802e to 84b9313 Compare March 13, 2026 07:41
Copy link
Copy Markdown
Contributor

@harshit-nema harshit-nema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review comments for kerberos_group_resource

Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_group_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_group_resource_test.go Outdated
Copy link
Copy Markdown
Contributor

@harshit-nema harshit-nema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ephemeral resource : Kerberos_login review.
Also will there be any modifications required for vault.erb file for this new implementation on Vault Kerberos auth method

Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_login.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_login_test.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource_test.go Outdated
Comment thread testutil/testutil.go Outdated
@hashicorp-cla-app
Copy link
Copy Markdown

hashicorp-cla-app Bot commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@siyer-corp siyer-corp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provided some comments on the first pass. For the ldap_config_resource, can we check if the functionality is similar to ldap_auth resource?

Comment thread internal/vault/auth/kerberos/kerberos_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Outdated
Comment thread website/docs/ephemeral-resources/kerberos_auth_backend_login.html.md Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go Outdated
Comment thread internal/vault/auth/kerberos/kerberos_ldap_config_resource.go
Comment thread testutil/testutil.go Outdated
Copy link
Copy Markdown
Contributor

@siyer-corp siyer-corp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, let's check if changes in vault/data_source_auth_backends_test.go are required. Provided some additional comments.

Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread website/docs/ephemeral-resources/kerberos_auth_backend_login.html.md Outdated
Comment thread website/docs/ephemeral-resources/kerberos_auth_backend_login.html.md Outdated
Comment thread internal/vault/auth/kerberos/kerberos_login_ephemeral_resource.go
Comment thread website/docs/r/kerberos_auth_backend_ldap_config.html.md
Copy link
Copy Markdown
Contributor

@siyer-corp siyer-corp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, can we refactor the tests accordingly?

},
consts.FieldEnableSamaccountnameLogin: schema.BoolAttribute{
Optional: true,
Description: "If true, matching sAMAccountName attribute values will be allowed to login when upndomain is defined. Default: false. **Note:** This field is only supported in Vault 1.19.0 and above. Do not configure this attribute if your Vault version is below 1.19.0.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this consise? We can update the note to say "Requires Vault 1.19.0+"

Optional: true,
WriteOnly: true,
Sensitive: true,
Description: "Client certificate key to provide to the LDAP server, must be x509 PEM encoded (write-only). Must be used together with client_tls_key_wo_version.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split these into multi-line for better readability?

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package ephemeralauth
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these two files inside the kerberos directory?

}

// TestAccKerberosAuthBackendConfig_runtimeErrors tests runtime errors
func TestAccKerberosAuthBackendConfig_runtimeErrors(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this as it's testing vault functionality, not TFVP?

}

// TestAccKerberosAuthBackendLDAPConfig_runtimeErrors tests runtime errors
func TestAccKerberosAuthBackendLDAPConfig_runtimeErrors(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this as it's testing vault functionality, not TFVP?

Comment thread internal/vault/auth/kerberos/kerberos_config_resource_test.go
})
}

func TestAccKerberosAuthBackendGroup_invalid(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this as it's testing vault functionality, not TFVP?

Comment thread internal/vault/auth/kerberos/kerberos_group_resource_test.go
@vijayavelsekar vijayavelsekar force-pushed the VAULT-42404-Kerberos-Auth-Method-Implementation branch 2 times, most recently from b9ccbe1 to 9c79a2d Compare March 31, 2026 11:14
vijayavelsekar and others added 27 commits April 7, 2026 16:00
@vijayavelsekar vijayavelsekar force-pushed the VAULT-42404-Kerberos-Auth-Method-Implementation branch from 161070d to 108b7fc Compare April 7, 2026 10:31
@vijayavelsekar vijayavelsekar modified the milestones: 5.9.0, 5.10.0 Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Allow configuration of kerberos authentication backend

4 participants