Skip to content

Commit f60327e

Browse files
committed
Address PR feedback: document RFC 7638 JWK-minimality invariant, log canonicalization failure
- Add in-context comment tying jwkThumbprint's correctness to jwkP256's output being minimal ({crv, kty, x, y} only). Optional JWK fields would silently break the authorize↔token binding; this makes the dependency visible to a future jwkP256 author. - Log a warn line when JSON canonicalization or SHA-256 hashing fails before throwing thumbprintFailed, matching the diagnosability style of the coordinator's appendDPoPJktIfNeededTo: soft-fail path.
1 parent a08e267 commit f60327e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

libs/SalesforceSDKCore/SalesforceSDKCore/Classes/OAuth/DPoP/DPoPProofBuilder.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,16 @@ public final class DPoPProofBuilder: NSObject {
119119
} catch {
120120
throw DPoPProofBuilderError.jwkExportFailed
121121
}
122-
// RFC 7638: canonical JSON with lexicographic key ordering, UTF-8, no whitespace.
122+
// RFC 7638 §3.2: canonical JSON must contain ONLY the required members
123+
// for the key type — for P-256 that is exactly {crv, kty, x, y}. If
124+
// Encryptor.jwkP256 ever grows optional fields (kid, use, key_ops...)
125+
// the thumbprint computed here will silently diverge from what the
126+
// server derives off the DPoP proof's `jwk` claim, breaking the
127+
// authorize↔token binding. Keep jwkP256's output minimal.
123128
guard let canonicalData = try? JSONSerialization.data(withJSONObject: jwk,
124129
options: [.sortedKeys, .withoutEscapingSlashes]),
125130
let digest = (canonicalData as NSData).sfsdk_sha256() else {
131+
SFSDKCoreLogger.w(Self.self, message: "DPoP jwkThumbprint: JWK canonicalization or SHA-256 hash failed")
126132
throw DPoPProofBuilderError.thumbprintFailed
127133
}
128134
return (digest as NSData).sfsdk_base64UrlString()

0 commit comments

Comments
 (0)