Fix bug when sign JWT on Android platform#193
Fix bug when sign JWT on Android platform#193laurentyhuel wants to merge 2 commits intoauth0:masterfrom
Conversation
|
Ughh! |
|
Our use case: So yes, you need to sign JWT on Android (it's not just for the fun). I'm agree with you reflection, is not sexy, but in this case it seems to be the more robust way to do it. I could add unit tests to coverage this part. |
|
There's no way to keep the secret/private_key secure in Android (anyone can see/modify it) so what's the point in signing the JWT? Ok, you could make the server use the public_key (in the case of HMAC) to verify the incoming signature, but even then anyone can sign tokens with your private_key as you're keeping it on the device, meaning your server would trust anything blindfolded. The tokens must always be signed on the server. |
Fix bug #131 , #191, #185 : cannot sign JWT on Android platform.
I choose reflection to check if code is execute on Android platform why:
dependencies {
compileOnly "com.google.android:android:4.1.1.4"
}
It' also possible to get platform with System.getProperty() : https://stackoverflow.com/questions/4519556/how-to-determine-if-my-app-is-running-on-android
but result could differ depends on os version, manufacturer, ...