Closed icedice closed 6 years ago
@icedice Hi! Nice to hear, I have not found any appropriate invocation of SuccessResult with claimsSet. It seems a bug.
Could you describe an expected behavior more precisely? Should claims be mixed with headers and payload?
I would simply expect that when I decode a JWT with the JWTDecodingBuilder, and the decoding is a success, then I should be able to access standard claims in the ClaimSet in successResult.claimsSet like the issuer and the subject, but the claimSet seems to be nil always which is what is puzzling me...
Here is my code:
var crypto: JWTCryptoKeyProtocol? = nil
do {
crypto = try JWTCryptoKeyPublic(pemEncoded: publickey, parameters: nil)
}
catch let error {
NSLog("error: \(error)")
}
guard let theCrypto = crypto else {
return
}
let algorithm = JWTAlgorithmNameRS256
guard let holder = JWTAlgorithmRSFamilyDataHolder().signKey(theCrypto)?.verifyKey(theCrypto)?.secretData(publickey.data(using: .utf8)!)?.algorithmName(algorithm) else {
return
}
let claimsSet = JWTClaimsSet()
claimsSet.issuer = "MY ISSUER GOES HERE";
claimsSet.audience = "AUD GOES HERE";
guard let decoding = JWTDecodingBuilder.decodeMessage(token).claimsSet(claimsSet)?.addHolder(holder) as? JWTDecodingBuilder else{
return
}
let result = decoding.decode
let claims = result!.successResult!.claimsSet // nil
@icedice try latest master
@icedice could be closed?
Yes. sorry. The issue is resolved and can be closed.
New Issue Checklist
Issue Description and Steps
I'm missing something. When i decode a jwt the claimSet in result!.successResult.claimsSet always end up as nil, this happens even though i pass a claimSet to my JTWDecoindBuilder and it validates perfectly against the JWT. What am I missing here I just need to access the subject and thought I would be able to do it like so: result!.successResult.claimsSet.subject I guess I could dig it out of the headerAndPayloadDictionary, but surely thats not the right way to do it.