-
Notifications
You must be signed in to change notification settings - Fork 113
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
[117] Allow JWK parameters of type [String] #120
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.
These seem like pretty slick changes overall, nice work!
JOSESwift/Sources/JWK.swift
Outdated
|
||
/// Accesses the specified parameter. | ||
/// The parameters of the JWK representing the properties of the key(s), including the value(s). | ||
/// Check [RFC 7517, Section 4](https://tools.ietf.org/html/rfc7517#section-4) and | ||
/// [RFC 7518, Section 6](https://tools.ietf.org/html/rfc7518#section-6) for possible parameters. | ||
/// | ||
/// - Parameter parameter: The desired parameter. | ||
subscript(parameter: String) -> String? { get } | ||
subscript(parameter: String) -> Any? { get } |
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.
Why use Any?
here instead of JWKParameterType?
? Are there non [String]?
or String?
return types?
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.
I think you're right! I'll need to investigate what I did exactly back then but yeah I think you're right. Will update.
The whole parameter stuff in JWK and in the JOSE header is not exactly nice. We'd love to update all of that some time. 🙏
let certificateChain = key.X509CertificateChain | ||
|
||
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) |
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.
Force unwrapping should be avoided.force_unwrapping JWKRSAParameterTypeTests.swift:87 |
|
||
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) | ||
XCTAssertEqual(certificateChain![0].prefix(5), "MIIDQ") |
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.
Force unwrapping should be avoided.force_unwrapping JWKRSAParameterTypeTests.swift:88 |
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) | ||
XCTAssertEqual(certificateChain![0].prefix(5), "MIIDQ") | ||
XCTAssertEqual(certificateChain![0].suffix(5), "OWA==") |
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.
Force unwrapping should be avoided.force_unwrapping JWKRSAParameterTypeTests.swift:89 |
swb4ECNIKG0CETTUxmXl9KUL+9gGlqCz5iWLOgWsnrcKcY0vXPG9J1r9AqBNTqNgHq2G03X09266X5CpOe1zFo+Owb1zxtp3PehFdfQJ610CDLE\ | ||
aS9V9Rqp17hCyybEpOGVwe8fnk+fbEL2Bo3UPGrpsHzUoaGpDftmWssZkhpBJKVMJyf/RuP2SmmaIzmnw9JiSlYhzo4tpzd5rFXhjRbg4zW9C+2\ | ||
qok+2+qDM1iJ684gPHMIY8aLWrdgQTxkumGmTqgawR+N5MDtdPTEQ0XfIBc2cJEUyMTY5MPvACWpkA6SdS4xSvdXK3IVfOWA=="]} | ||
""".data(using: .utf8)! |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:26 |
let keyOperations = key["key_ops"] as? [String] | ||
|
||
XCTAssertNotNil(keyOperations) | ||
XCTAssertEqual(keyOperations!.count, 7) |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:48 |
|
||
XCTAssertNotNil(keyOperations) | ||
XCTAssertEqual(keyOperations!.count, 7) | ||
XCTAssertEqual(keyOperations![0], "sign") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:49 |
XCTAssertNotNil(keyOperations) | ||
XCTAssertEqual(keyOperations!.count, 7) | ||
XCTAssertEqual(keyOperations![0], "sign") | ||
XCTAssertEqual(keyOperations![1], "encrypt") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:50 |
XCTAssertEqual(keyOperations!.count, 7) | ||
XCTAssertEqual(keyOperations![0], "sign") | ||
XCTAssertEqual(keyOperations![1], "encrypt") | ||
XCTAssertEqual(keyOperations![2], "decrypt") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:51 |
XCTAssertEqual(keyOperations![0], "sign") | ||
XCTAssertEqual(keyOperations![1], "encrypt") | ||
XCTAssertEqual(keyOperations![2], "decrypt") | ||
XCTAssertEqual(keyOperations![3], "wrapKey") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:52 |
XCTAssertEqual(keyOperations![1], "encrypt") | ||
XCTAssertEqual(keyOperations![2], "decrypt") | ||
XCTAssertEqual(keyOperations![3], "wrapKey") | ||
XCTAssertEqual(keyOperations![4], "unwrapKey") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:53 |
XCTAssertEqual(keyOperations![2], "decrypt") | ||
XCTAssertEqual(keyOperations![3], "wrapKey") | ||
XCTAssertEqual(keyOperations![4], "unwrapKey") | ||
XCTAssertEqual(keyOperations![5], "deriveKey") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:54 |
XCTAssertEqual(keyOperations![3], "wrapKey") | ||
XCTAssertEqual(keyOperations![4], "unwrapKey") | ||
XCTAssertEqual(keyOperations![5], "deriveKey") | ||
XCTAssertEqual(keyOperations![6], "deriveBits") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:55 |
let keyOperations = key.keyOperations | ||
|
||
XCTAssertNotNil(keyOperations) | ||
XCTAssertEqual(keyOperations!.count, 7) |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:64 |
|
||
XCTAssertNotNil(keyOperations) | ||
XCTAssertEqual(keyOperations!.count, 7) | ||
XCTAssertEqual(keyOperations![0], "sign") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:65 |
XCTAssertNotNil(keyOperations) | ||
XCTAssertEqual(keyOperations!.count, 7) | ||
XCTAssertEqual(keyOperations![0], "sign") | ||
XCTAssertEqual(keyOperations![1], "encrypt") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:66 |
XCTAssertEqual(keyOperations!.count, 7) | ||
XCTAssertEqual(keyOperations![0], "sign") | ||
XCTAssertEqual(keyOperations![1], "encrypt") | ||
XCTAssertEqual(keyOperations![2], "decrypt") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:67 |
XCTAssertEqual(keyOperations![0], "sign") | ||
XCTAssertEqual(keyOperations![1], "encrypt") | ||
XCTAssertEqual(keyOperations![2], "decrypt") | ||
XCTAssertEqual(keyOperations![3], "wrapKey") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:68 |
XCTAssertEqual(keyOperations![1], "encrypt") | ||
XCTAssertEqual(keyOperations![2], "decrypt") | ||
XCTAssertEqual(keyOperations![3], "wrapKey") | ||
XCTAssertEqual(keyOperations![4], "unwrapKey") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:69 |
XCTAssertEqual(keyOperations![2], "decrypt") | ||
XCTAssertEqual(keyOperations![3], "wrapKey") | ||
XCTAssertEqual(keyOperations![4], "unwrapKey") | ||
XCTAssertEqual(keyOperations![5], "deriveKey") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:70 |
XCTAssertEqual(keyOperations![3], "wrapKey") | ||
XCTAssertEqual(keyOperations![4], "unwrapKey") | ||
XCTAssertEqual(keyOperations![5], "deriveKey") | ||
XCTAssertEqual(keyOperations![6], "deriveBits") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:71 |
let certificateChain = key["x5c"] as? [String] | ||
|
||
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:80 |
|
||
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) | ||
XCTAssertEqual(certificateChain![0].prefix(5), "MIIDQ") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:81 |
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) | ||
XCTAssertEqual(certificateChain![0].prefix(5), "MIIDQ") | ||
XCTAssertEqual(certificateChain![0].suffix(5), "OWA==") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:82 |
let certificateChain = key.X509CertificateChain | ||
|
||
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:91 |
|
||
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) | ||
XCTAssertEqual(certificateChain![0].prefix(5), "MIIDQ") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:92 |
Generated by 🚫 Danger |
XCTAssertNotNil(certificateChain) | ||
XCTAssertEqual(certificateChain!.count, 1) | ||
XCTAssertEqual(certificateChain![0].prefix(5), "MIIDQ") | ||
XCTAssertEqual(certificateChain![0].suffix(5), "OWA==") |
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.
Force unwrapping should be avoided.force_unwrapping JWKSymmetricParameterTypeTests.swift:93 |
@daniel-mohemian what's the status of this PR? |
I need to find time to revisit it and check into which major release we put it. I'll close the PR for now as it obviously is stale. Thanks for reminding me about it! |
Resolves #117.
Implemented this today throughout the day. Submitting the pull request now, so I can continue implementing feedback tomorrow at work.
[String]
JWK parameters in addition toString
parameters.Tell me what you think!
JWS.swift
(major release needed):