-
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
Closed
Closed
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
722937b
Implement decoding of String and [String] parameters
dlggr 0478b7c
Adapt tests
dlggr 9d98e85
Add new test case
dlggr 32c1e11
Remove key type computed property
dlggr 0bcdd26
Update tests
dlggr daedd4b
Fix long lines
dlggr c27f7fa
Update readme
dlggr 82ca0c2
Move parameter getter extension
dlggr 9a6eaa7
Add doc comments to param getters
dlggr 2cf0c6a
Remove old array parameter test
dlggr 3e7ea46
Merge branch 'master' into feature/string-array-jwk-parameters
2d75cc2
Merge branch 'master' into feature/string-array-jwk-parameters
bf2539b
Use Codable for JWKPArameterType
daniel-moh 763c67f
Use JWKPArameterType instsead of Any for subscript
daniel-moh 5ad7f1a
Merge branch 'master' into feature/string-array-jwk-parameters
daniel-moh f006882
Adapt EC keys for String arary parameters
daniel-moh fcee76c
Adapt tests
daniel-moh da05a0c
Add symmetric key parsing tests
daniel-moh df830e1
Merge branch 'master' into feature/string-array-jwk-parameters
99b7b0a
Add rsa tests to test target
daniel-moh 3044537
Switch on parameter type in a single loop
daniel-moh 575d31a
Add single loop decoding for ec private key as well
daniel-moh fe2dfe3
Add single loop decoding for rsa private key as well
daniel-moh 3ae5424
Merge branch 'master' into feature/string-array-jwk-parameters
b75f698
Resolve conflicts
daniel-moh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -26,7 +26,7 @@ import Foundation | |||
// MARK: Subscript | ||||
|
||||
public extension JWK { | ||||
subscript(parameter: String) -> String? { | ||||
subscript(parameter: String) -> Any? { | ||||
return parameters[parameter] | ||||
} | ||||
} | ||||
|
@@ -46,3 +46,59 @@ public extension JWK { | |||
return try? JSONEncoder().encode(self) | ||||
} | ||||
} | ||||
|
||||
// MARK: Parameter getters | ||||
|
||||
extension JWK { | ||||
/// The public key use parameter identifies the intended use of a public key. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.2). | ||||
var keyUse: String? { | ||||
return parameters[JWKParameter.keyUse.rawValue] as? String | ||||
} | ||||
|
||||
/// The key operations parameter identifies the operation(s) for which the key is intended to be used. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.3). | ||||
var keyOperations: [String]? { | ||||
return parameters[JWKParameter.keyOperations.rawValue] as? [String] | ||||
} | ||||
|
||||
/// The algorithm parameter identifies the algorithm intended for use with the key. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.4). | ||||
var algorithm: String? { | ||||
return parameters[JWKParameter.algorithm.rawValue] as? String | ||||
} | ||||
|
||||
/// The key identifier parameter is used to match a specific key. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.5). | ||||
var keyIdentifier: String? { | ||||
return parameters[JWKParameter.keyIdentifier.rawValue] as? String | ||||
} | ||||
|
||||
/// The X.509 URL parameter is a URI that refers to a resource for an X.509 public key certificate | ||||
/// or certificate chain. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.6). | ||||
var X509URL: String? { | ||||
return parameters[JWKParameter.X509URL.rawValue] as? String | ||||
} | ||||
|
||||
/// The X.509 certificate chain parameter contains a chain of one or more PKIX certificates. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.7). | ||||
var X509CertificateChain: [String]? { | ||||
return parameters[JWKParameter.X509CertificateChain.rawValue] as? [String] | ||||
} | ||||
|
||||
/// The X.509 certificate SHA-1 thumbprint parameter is a base64url-encoded SHA-1 thumbprint (a.k.a. digest) | ||||
/// of the DER encoding of an X.509 certificate. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.8). | ||||
var X509CertificateSHA1Thumbprint: String? { | ||||
return parameters[JWKParameter.X509CertificateSHA1Thumbprint.rawValue] as? String | ||||
} | ||||
|
||||
/// The X.509 certificate SHA-256 thumbprint parameter is a base64url-encoded SHA-256 thumbprint (a.k.a. digest) | ||||
/// of the DER encoding of an X.509 certificate. | ||||
/// See [RFC-7517](https://tools.ietf.org/html/rfc7517#section-4.9). | ||||
var X509CertificateSHA256Thumbprint: String? { | ||||
return parameters[JWKParameter.X509CertificateSHA256Thumbprint.rawValue] as? String | ||||
} | ||||
} | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofJWKParameterType?
? Are there non[String]?
orString?
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. 🙏