-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1270 from modelix/fix/private-keys-from-disk
fix(authorization): verification against private keys from disk failed
- Loading branch information
Showing
4 changed files
with
72 additions
and
6 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
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 |
---|---|---|
|
@@ -318,4 +318,47 @@ class RSATest { | |
verifyingUtil.verifyToken(tokenString) | ||
} | ||
} | ||
|
||
@Test | ||
fun `can verify own tokens`() { | ||
val privateKeyPem1 = """ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEogIBAAKCAQEAyB+2c/hRX7lhcTKHOom13F7dVnujy1XndcYp4y42NIxRZDui | ||
mOU/inkH6tJsclIftPeYSWnSTWRc5ZG268pRMjD6rMCxCTyo1S7VGuXtdPbfL1ma | ||
kCYfpKALBZdLgrYVkor49CP2cBdKPldYUT7+EpqFxXkaeL073bS3vPPdxN/riuYu | ||
3df3tLe9+st6Tr6+rv1+HK+dRegPok8ryMOogT96QyF7ygLDQ1WW/v/CZI5y+jW1 | ||
xEpWnHRkRqHWTtIMjWN6WK+ez1kg4tlQDWmMn4bywmTPRs38weLEMnTUrjfrOxOc | ||
59rWOyE7b186RrDf1F1ezLiVUlLA9L7ThydM3QIDAQABAoIBAEXspsCgrDYpPP3j | ||
bNKsWWn1j5rvOo0KqARDyFEDzZbQzIOcPrTzrR8CKR0IhzHutftyY7iLDBtUjQz9 | ||
vA9pMrO532zLK1CR7GAIrBdo7W5n8BXIVjQ1zeqkrRU4B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iayl7WALnEpGhh2+aKkDVIy7JSTOm3fkO | ||
P1Z2sotIDXrYJrdKl/BvWh80ifVYjHp9J/cOhMSyj/HCMhxexhY= | ||
-----END RSA PRIVATE KEY----- | ||
""".trimIndent().trim() | ||
|
||
val privateKeyFile = File.createTempFile("modelix_rsa_test", ".pem") | ||
privateKeyFile.deleteOnExit() | ||
privateKeyFile.writeText(privateKeyPem1) | ||
|
||
val util = ModelixJWTUtil() | ||
util.loadKeysFromFiles(privateKeyFile) | ||
|
||
val tokenString = util.createAccessToken("[email protected]", listOf()) | ||
util.verifyToken(tokenString) | ||
} | ||
} |
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