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

Add closure to claim validation API #1

Closed
rrrodzilla opened this issue Oct 21, 2021 · 0 comments · Fixed by #5
Closed

Add closure to claim validation API #1

rrrodzilla opened this issue Oct 21, 2021 · 0 comments · Fixed by #5
Labels
enhancement New feature or request

Comments

@rrrodzilla
Copy link
Owner

Currently, claim validation is a simple check that the claim exists in the decrypted token and the decrypted value matches the provided value. The API needs to be extended to allow the user to provide their own validation closure in order to support more complex validation scenarios.

@rrrodzilla rrrodzilla added the enhancement New feature or request label Oct 21, 2021
@rrrodzilla rrrodzilla added this to the Version 0.2.0 Release milestone Oct 21, 2021
rrrodzilla added a commit that referenced this issue Oct 22, 2021
- add: Added an optional closure argument to the validate_claim method.
  To be used to allow the user to provide custom validation logic for a
  particular claim

- add: Added logic in the parse method to run custom validation closures
  if one is specified.  This means claim validators will verify the
  claim exists and verify the value matches what is expected.  If a
  custom closure is provided, the validator first checks the claim
  exists and then the value is provided to the closure for further
  validation by the end user.

- add: PasetoTokenParseError::InvalidClaimValueType(String) for claim
  values we try to convert to an invalid type

- add: PasetoTokenParseError::CustomClaimValidation for claims which
  fail in user provided custom validation closures

- add: Implement Default trait on all reserved claims so that they can
  be passed into custom validation closures

- add: Implement From(&str) for CustomClaim so that they can be passed
  into custom validation closures which always ignore passed in values
  when adding the claim to the validator

- chore: closes #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant