Closed andriajensen closed 7 years ago
@andriajensen Hi! Am I right that this could be solved by adding string streamers/coders in dataHolders?
In perspective:
- (id<JWTStringCoder>)coder {
return _coder;
}
- (NSData *)dataFromString:(NSString *)string {
NSData *result = [self.coder dataWithString:string];
return result ?: [JWTDefaultStringCoder dateWithString:string]
}
@andriajensen
Could you check latest master?
This seems like a sane approach.
Looks like it works with latest master. However, I'm seeing a new issue that I'll open another for.
New Issue Checklist
Issue Info
Issue Description and Steps
I have been migrating from version 2.2.0 to 3.0.0-beta.2. In doing so, it appears the encoding no longer behaves the same. We were previously using a secret without base64 encoding. However, when sending that same secret to the encoder in 3.0.0-beta.2, a different signature is produced. In digging further, it seems that in 3.x, the
secret
andsecretData
properties both store a base64 encoded version of the secret. So, the signature is always produced with a base64 encoded version of the given secret. The server I'm communicating with is not expecting the secret to be base64 encoded, and therefore it cannot validate the signature.The relevant code is highlighted below. Note that
secret
is presumably the non-base64 encoded string. However, it is calling todataFromString
which is then base64 encoding it. So, presumably, there is no way to create a JWT encoding that does not use a base64 encoded secret.