-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow empty signature When encoding an Unsecured JWT with the "none" algorithm, the encoded signature is the empty string. * Add JWTSigner.unsecuredNone * Test that signature is empty when using `.unsecuredNone` * Add decoding test for the "none" algorithm
- Loading branch information
Showing
4 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extension JWTSigner { | ||
public static let unsecuredNone: JWTSigner = .init(algorithm: UnsecuredNoneSigner()) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Foundation | ||
|
||
internal struct UnsecuredNoneSigner: JWTAlgorithm { | ||
var name: String { | ||
"none" | ||
} | ||
|
||
func sign<Plaintext>(_ plaintext: Plaintext) throws -> [UInt8] | ||
where Plaintext: DataProtocol | ||
{ | ||
[] | ||
} | ||
|
||
func verify<Signature, Plaintext>(_ signature: Signature, signs plaintext: Plaintext) throws -> Bool | ||
where Signature: DataProtocol, Plaintext: DataProtocol | ||
{ | ||
signature.isEmpty | ||
} | ||
} |
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