-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
There was a problem hiding this 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"} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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"} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK
This PR fixes JWT signature calculation for 1.8.x release branch