Skip to content
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

Closed
wants to merge 25 commits into from
Closed

[117] Allow JWK parameters of type [String] #120

wants to merge 25 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 24, 2018

Resolves #117.

Implemented this today throughout the day. Submitting the pull request now, so I can continue implementing feedback tomorrow at work.

  • Allows encoding and decoding of [String] JWK parameters in addition to String parameters.

Tell me what you think!


⚠️ This contains two API changes in JWS.swift (major release needed):

subscript(parameter: String) -> String?
// becomes
subscript(parameter: String) -> Any?
let parameters: [String: String]
// becomes
let parameters: [String: JWKParameterType]

@ghost ghost requested review from a user, carol-mohemian and mohemian-92817281 and removed request for a user October 25, 2018 08:05
@ghost ghost self-assigned this Oct 25, 2018
@ghost ghost requested review from a team and removed request for a user October 25, 2018 08:05
@ghost ghost requested review from a user and removed request for mohemian-92817281 November 28, 2018 13:08
ghost
ghost previously approved these changes Dec 19, 2018
Copy link

@ghost ghost left a 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!


/// 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 }
Copy link

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?

Copy link

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. 🙏

@ghost ghost added the WIP label Jan 22, 2019
@ghost ghost mentioned this pull request Jan 22, 2019
let certificateChain = key.X509CertificateChain

XCTAssertNotNil(certificateChain)
XCTAssertEqual(certificateChain!.count, 1)

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")

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==")

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)!

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)

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")

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")

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")

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")

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")

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")

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")

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)

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")

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")

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")

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")

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")

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")

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")

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)

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")

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==")

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)

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")

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

@Jose-ElRobot
Copy link

1 Warning
⚠️ Your pull request seems to introduce linting violations. Some of them may be fixable by running bundle exec fastlane format_code.
1 Message
📖 Any non-trivial changes to code should be reflected in the changelog. Please consider adding a note in the Unreleased section of the CHANGELOG.md.

Generated by 🚫 Danger

XCTAssertNotNil(certificateChain)
XCTAssertEqual(certificateChain!.count, 1)
XCTAssertEqual(certificateChain![0].prefix(5), "MIIDQ")
XCTAssertEqual(certificateChain![0].suffix(5), "OWA==")

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

@ghost
Copy link

ghost commented Aug 5, 2019

@daniel-mohemian what's the status of this PR?

@ghost
Copy link

ghost commented Aug 21, 2019

@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!

@ghost ghost closed this Aug 21, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow decoding of [String] JWK parameters
3 participants