garyburgmann / drf-firebase-auth

Firebase backend to receive a user idToken and authenticate via Django REST Framework 'authentication.BaseAuthentication'. Optionally, a new local user can be created in the process.
MIT License
127 stars 61 forks source link

Facebook id Token can't be verified on Firebase #18

Closed hrqnogueira closed 4 years ago

hrqnogueira commented 4 years ago

Hi,

The call to verify_id_token is failing here:

return firebase_auth.verify_id_token( firebase_token, check_revoked=api_settings.FIREBASE_CHECK_JWT_REVOKED )

The root cause seems to be in the following line in the pkcs1.py:

def verify(message, signature, pub_key): ... method_name = _find_method_hash(clearsig)

where it tries to find the hash method for the payload based on the following headers:

HASH_ASN1 = { 'MD5': b'\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10', 'SHA-1': b'\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14', 'SHA-224': b'\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04\x05\x00\x04\x1c', 'SHA-256': b'\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20', 'SHA-384': b'\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30', 'SHA-512': b'\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40', }

and it is not able to find the corresponding hash method (which I think it is SHA-256).

Let me know if I can help further.

Thanks!