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 support for custom JWS algorithms #1410

Merged
merged 6 commits into from
Sep 17, 2024

Conversation

frederikrothenberger
Copy link

@frederikrothenberger frederikrothenberger commented Sep 11, 2024

This PR introduces a feature custom_alg to identity_jose (disabled by default) that allows it to process JWS with custom alg values.

Switching on custom_alg makes quite a few changes to JwsAlgorithm:

  • The type is no longer Copy
  • name() takes only a reference and returns a String rather than &'static str
  • The constant ALL is removed as it is no longer possible to enumerate all variants

Fixes issue #1406.

Type of change

Add an x to the boxes that are relevant to your changes.

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Added a new integration test to identity_jose that exercises the functionality.

Note: requires CI changes to be run with cargo test --test custom_alg --features="custom_alg"

Change checklist

Add an x to the boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

This PR introduces a feature `custom_alg` to `identity_jose` (disabled
by default) that allows it to process JWS with custom `alg` values.

Switching on `custom_alg` makes quite a few changes to `JwsAlgorithm`:
- The type is no longer `Copy`
- `name()` takes only a reference and returns a `String` rather than
  `&'static str`
- The constant `ALL` is removed as it is no longer possible to enumerate
  all variants
@frederikrothenberger frederikrothenberger requested a review from a team as a code owner September 11, 2024 14:18
@frederikrothenberger
Copy link
Author

@itsyaasir, @eike-hass: The change using a feature flag seems to be quite reasonable. What do you think?

@eike-hass eike-hass added Added A new feature that requires a minor release. Part of "Added" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. labels Sep 16, 2024
Copy link
Contributor

@itsyaasir itsyaasir left a comment

Choose a reason for hiding this comment

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

Thank you for contributing to this :) Everything looks good to me!

Just some few comments here and there.

identity_jose/tests/custom_alg.rs Show resolved Hide resolved
identity_jose/src/jws/algorithm.rs Outdated Show resolved Hide resolved
@itsyaasir
Copy link
Contributor

Thanks for this @frederikrothenberger

@itsyaasir itsyaasir merged commit 26afa2c into iotaledger:main Sep 17, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added A new feature that requires a minor release. Part of "Added" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants