Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Custom Tokens generated by this are invalid #19

Open
jpeiffer opened this issue Jul 13, 2021 · 0 comments
Open

Firebase Custom Tokens generated by this are invalid #19

jpeiffer opened this issue Jul 13, 2021 · 0 comments

Comments

@jpeiffer
Copy link

Version: firebase_admin: ^0.2.0-dev.1

The Firebase custom tokens generated by this library result in an auth error from the Firebase servers:

The custom token format is incorrect. Please check the documentation.

It appears this library is putting in extra attributes that are not put in via the Java SDK. Specifically, this puts in a kid and a typ attribute in the header that the Java SDK doesn't.

I tried generating a token manually without those attributes and it was accepted by Firebase. Through some more experimentation, it's the typ attribute that's causing Firebase to reject the token as invalid as it accepts it still with the kid in place.

It looks like all that needs to change is to remove the typ header. The fix would be to change: lib/src/auth/token_tenerator.dart

Around lines 68-70... from:

    var builder = JsonWebSignatureBuilder()
      ..jsonContent = claims
      ..setProtectedHeader('typ', 'JWT')
      ..addRecipient(certificate.privateKey, algorithm: 'RS256');

... to ...

    var builder = JsonWebSignatureBuilder()
      ..jsonContent = claims
      ..addRecipient(certificate.privateKey, algorithm: 'RS256');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant