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

refactor: TokenGenerationService takes key ID instead of PrivateKey #4395

Conversation

paullatzelsperger
Copy link
Member

@paullatzelsperger paullatzelsperger commented Aug 5, 2024

What this PR changes/adds

Refactors the TokenGenerationService to take a privateKeyId instead of a Supplier<PrivateKey>. In addition, a new interface JwsSignerProvider was added, that can be used to plug in custom JWSSigner implementations.

If no custom impl is provided, a default JWSSigner is created, that resolves the private key from the vault, same as now.

Why it does that

Being able to contribute a custom JWSSigner is a precondition for having tokens signed by a remote service, such as a HSM

Further notes

Do not review yet - this is just a PoC!

Linked Issue(s)

Closes # <-- insert Issue number if one exists

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

@paullatzelsperger paullatzelsperger added the enhancement New feature or request label Aug 5, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.

Project coverage is 74.94%. Comparing base (7f20ba5) to head (70570fb).
Report is 379 commits behind head on main.

Files Patch % Lines
.../org/eclipse/edc/token/TokenServicesExtension.java 0.00% 2 Missing ⚠️
...ramework/DataPlaneDefaultIamServicesExtension.java 0.00% 2 Missing ⚠️
...rust/sts/defaults/StsDefaultServicesExtension.java 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4395      +/-   ##
==========================================
+ Coverage   71.74%   74.94%   +3.20%     
==========================================
  Files         919     1072     +153     
  Lines       18457    21455    +2998     
  Branches     1037     1172     +135     
==========================================
+ Hits        13242    16080    +2838     
- Misses       4756     4852      +96     
- Partials      459      523      +64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@paullatzelsperger paullatzelsperger force-pushed the refactor/tokengenerator_service branch from bd06217 to bc239d1 Compare August 7, 2024 09:18
Copy link
Contributor

@wolf4ood wolf4ood left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor nit

…gner/spi/JwsSignerProvider.java

Co-authored-by: Enrico Risa <enrico.risa@gmail.com>
…GenerationService.java

Co-authored-by: ndr_brt <andrea.bertagnolli@gmail.com>
@paullatzelsperger paullatzelsperger force-pushed the refactor/tokengenerator_service branch from 1820248 to b76fcf0 Compare August 7, 2024 09:52
@paullatzelsperger paullatzelsperger force-pushed the refactor/tokengenerator_service branch 2 times, most recently from c670e3f to 90600fd Compare August 7, 2024 13:34
@paullatzelsperger paullatzelsperger force-pushed the refactor/tokengenerator_service branch from 90600fd to 70570fb Compare August 7, 2024 13:41
Comment on lines +76 to +77
client -> new JwtGenerationService(keyId -> privateKeyResolver.resolvePrivateKey(keyId)
.compose(pk -> Result.ofThrowable(() -> CryptoConverter.createSignerFor(pk)))),
Copy link
Member

Choose a reason for hiding this comment

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

this is the same as the one instantiated in the TokenServicesExtension, it could be extracted in a separate class to avoid the duplication

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, clicked "merge" too fast. will do this in another PR down the line.

@paullatzelsperger paullatzelsperger merged commit 7f51a3d into eclipse-edc:main Aug 8, 2024
23 checks passed
@paullatzelsperger paullatzelsperger deleted the refactor/tokengenerator_service branch August 8, 2024 07:29
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 this pull request may close these issues.

4 participants