-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jwks without algorithm * make jwksigner private * add msft jwks test
- Loading branch information
1 parent
8c9f67a
commit ee44e77
Showing
6 changed files
with
193 additions
and
85 deletions.
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,42 @@ | ||
import Foundation | ||
|
||
struct JWKSigner { | ||
let jwk: JWK | ||
|
||
init(jwk: JWK) { | ||
self.jwk = jwk | ||
} | ||
|
||
func signer(for algorithm: JWK.Algorithm? = nil) -> JWTSigner? { | ||
switch self.jwk.keyType { | ||
case .rsa: | ||
guard let modulus = self.jwk.modulus else { | ||
return nil | ||
} | ||
guard let exponent = self.jwk.exponent else { | ||
return nil | ||
} | ||
|
||
guard let rsaKey = RSAKey( | ||
modulus: modulus, | ||
exponent: exponent, | ||
privateExponent: self.jwk.privateExponent | ||
) else { | ||
return nil | ||
} | ||
|
||
guard let algorithm = algorithm ?? self.jwk.algorithm else { | ||
return nil | ||
} | ||
|
||
switch algorithm { | ||
case .rs256: | ||
return JWTSigner.rs256(key: rsaKey) | ||
case .rs384: | ||
return JWTSigner.rs384(key: rsaKey) | ||
case .rs512: | ||
return JWTSigner.rs512(key: rsaKey) | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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