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

Fixed JWT signature calculation (1.8.x release) #615

Merged
merged 5 commits into from
Sep 12, 2024

Conversation

hvge
Copy link
Member

@hvge hvge commented Aug 13, 2024

This PR fixes JWT signature calculation for 1.8.x release branch

@hvge hvge requested a review from petrdvorak August 13, 2024 13:27
@hvge hvge requested a review from kober32 September 9, 2024 10:56
Copy link
Member

@petrdvorak petrdvorak left a comment

Choose a reason for hiding this comment

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

Looks OK, I have two comments on style (using inline constant feels a bit arbitrary).

@@ -2530,22 +2545,16 @@ public void onBiometricDialogFailed(@NonNull PowerAuthErrorException error) {
@Nullable
public ICancelable signJwtWithDevicePrivateKey(@NonNull Context context, @NonNull PowerAuthAuthentication authentication, @NonNull Map<String, Object> claims, @NonNull IJwtSignatureListener listener) {
final JsonSerialization serialization = new JsonSerialization();
final byte[] serializedClaims = serialization.serializeObject(claims);
return signDataWithDevicePrivateKey(context, authentication, serializedClaims, new IDataSignatureListener() {
final String jwtHeader = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9"; // {"alg":"ES256","typ":"JWT"}
Copy link
Member

Choose a reason for hiding this comment

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

This feels a bit arbitrary, could we extract it to some constant, i.e., JwtHeader.ES256?

Copy link
Member Author

@hvge hvge Sep 11, 2024

Choose a reason for hiding this comment

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

Java / Objective-C is already ugly enough language, so adding 4-5 more lines just to be "nice" makes no sense to me :)

Copy link
Member

Choose a reason for hiding this comment

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

Well, we intend to publish it to the world, I will leave it up to you - review is approved.

- (id<PowerAuthOperationTask>) signJwtWithDevicePrivateKey:(PowerAuthAuthentication*)authentication
claims:(NSDictionary<NSString*, NSObject*>*)claims
callback:(void(^)(NSString *jwt, NSError *error))callback
{
// Prepare JWT Header
NSString * jwtHeader = @"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9."; // {"alg":"ES256","typ":"JWT"}
Copy link
Member

Choose a reason for hiding this comment

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

dtto, extraction to some constant would probably be helpful.

Copy link
Member

@kober32 kober32 left a comment

Choose a reason for hiding this comment

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

Looks OK

@hvge hvge merged commit e7d67b0 into release/1.8.x Sep 12, 2024
1 check passed
@hvge hvge deleted the issues/614-jwt-signature-1.8.x branch September 12, 2024 13:40
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.

3 participants