Skip to content
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

chore: remove unused validateAudience function #314

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tenstad
Copy link

@tenstad tenstad commented Sep 5, 2024

Overview

Removes the unused validateAudience function

// validateAudience checks whether any of the audiences in audClaim match those
// in boundAudiences. If strict is true and there are no bound audiences, then the
// presence of any audience in the received claim is considered an error.
func validateAudience(boundAudiences, audClaim []string, strict bool) error {
if strict && len(boundAudiences) == 0 && len(audClaim) > 0 {
return errors.New("audience claim found in JWT but no audiences bound to the role")
}
if len(boundAudiences) > 0 {
for _, v := range boundAudiences {
if strutil.StrListContains(audClaim, v) {
return nil
}
}
return errors.New("aud claim does not match any bound audience")
}
return nil
}

as the one in hashicorp/cap/jwt/jwt.go is used instead, as part of

// Validate the JWT by verifying its signature and asserting expected claims values
allClaims, err := validator.Validate(ctx, token, expected)
if err != nil {
return logical.ErrorResponse("error validating token: %s", err.Error()), nil
}

Design of Change

To not confuse those reading the source and expecting this repo's validateAudience to be in use.

Contributor Checklist

  • Add relevant docs to upstream Vault repository, or sufficient reasoning why docs won’t be added yet
  • Add output for any tests not ran in CI to the PR description (eg, acceptance tests)
  • Backwards compatible

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.

1 participant