Skip to content

Add token_auth_metadata field for built-in Auth methods #31327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

victorr
Copy link
Contributor

@victorr victorr commented Jul 17, 2025

Description

Add token_auth_metadata field for built-in Auth methods.

In tokenutil.go, add support for generic Auth metadata:

  • Add a TokenMetadata map[string]string field to struct TokenParams.

  • Update method ParseTokenFields to populate the metadata field using request data.

  • Update method PopulateTokenAuth to add the metadata to field Auth.Metadata.

  • Update other helper methods.

The changes are described in RFC VLT-353.

Please note that external Auth methods and documentation updates will be addressed in separate pull requests.

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

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.

@victorr victorr added this to the 1.21.0-rc1 milestone Jul 17, 2025
@victorr victorr self-assigned this Jul 17, 2025
@victorr victorr requested review from a team as code owners July 17, 2025 19:58
@victorr victorr requested a review from mladlow July 17, 2025 19:58
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jul 17, 2025
@victorr victorr requested a review from a team July 17, 2025 19:59
@victorr
Copy link
Contributor Author

victorr commented Jul 17, 2025

In case there are ENT only tests affected by these changes, I have created PR https://github.com/hashicorp/vault-enterprise/pull/8470.

Moreover, I have created a suit of bats tests that cover token auth metadata definition all built-in Auth methods:

test-token-auth-metadata.bats
 ✓ AppRole
   Creating a role
   Reading back the role
   Getting the role id
   Getting a secret ID with its own 'workload' metadata
   Logging in
 ✓ AWS
   Creating a role
   Reading back the role
 ✓ GitHub
   Setting config
   Reading back config
 ✓ LDAP
   Setting config
   Reading back config
 ✓ Okta
   Setting config
   Reading back config
 ✓ RADIUS
   Setting config
   Reading back config
 ✓ SCEP
   Setting config
   Reading back config
 ✓ Cert
   Creating CA certificate role
   Reading back role
 ✓ UserPass
   Creating a user
   Reading back the user
   Logging in
 ✓ Token
   Creating a role
   Creating a token

10 tests, 0 failures

These tests are available in vault-tools (see PR https://github.com/hashicorp/vault-tools/pull/258).

Copy link

github-actions bot commented Jul 17, 2025

Build Results:
All builds succeeded! ✅

Copy link

github-actions bot commented Jul 17, 2025

CI Results:
All Go tests succeeded! ✅

@victorr victorr force-pushed the victorr/vault-38008-token-auth-metadata branch from dd753de to f11f58f Compare July 17, 2025 20:25
@victorr victorr changed the title Add token_auth_metadata field for all Auth methods Add token_auth_metadata field for built-in Auth methods Jul 17, 2025
victorr added 2 commits July 17, 2025 16:51
In tokenutil.go, add support for generic Auth metadata:
  * Add a `TokenMetadata map[string]string` field to struct `TokenParams`.

  * Update method `ParseTokenFields` to populate the metadata field using
  request data.

  * Update method `PopulateTokenAuth` to add the metadata to field
  `Auth.Metadata`.

  * Update other helper methods.
@victorr victorr force-pushed the victorr/vault-38008-token-auth-metadata branch from f11f58f to 61b8eaa Compare July 17, 2025 20:51
stevendpclark
stevendpclark previously approved these changes Jul 18, 2025
Copy link
Contributor

@stevendpclark stevendpclark left a comment

Choose a reason for hiding this comment

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

Looks good to me, some nits but nothing I feel strongly about.

Doc updates will be handled using the new repo I assume?

Co-authored-by: Steven Clark <[email protected]>
@victorr
Copy link
Contributor Author

victorr commented Jul 18, 2025

Yes, the documentation changes will be in the new repository.

@@ -273,6 +273,10 @@ can only be set during role creation and once set, it can't be reset later.`,
Required: true,
Description: "The maximum number of times a token may be used, a value of zero means unlimited",
},
"token_auth_metadata": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Make this call the helper method.

@victorr
Copy link
Contributor Author

victorr commented Jul 30, 2025

We have decided to take a slightly different approach, so I am closing this PR without merging.

@victorr victorr closed this Jul 30, 2025
@victorr victorr deleted the victorr/vault-38008-token-auth-metadata branch July 30, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants